#discord-bots

1 messages Β· Page 998 of 1

maiden fable
#

U don't need get_role anymore

slate swan
#

wait

little ivy
slate swan
#

so, getting a channel/whatever is proved useless isnt t?

little ivy
#

youre the only usefull guy here

slate swan
slate swan
slate swan
#

u made my day... uff

slate swan
#

but in case you want to "not" make useless requests you can use get_x s to check if that channel exists or not

slate swan
maiden fable
lofty tide
#

ammm @slate swan
it says it has a mistake on this line:
async def ping(ctx: commands.Context):

maiden fable
slate swan
#

u just got whoosed bro... :'/

#

anyways, ok :")

lofty tide
slate swan
#

lmao

maiden fable
lofty tide
#

where is the "closing bracket"?

#

tha im missing

maiden fable
#

@lofty tide paste yr code

lofty tide
#

import discord
from discord.ext import commands
bot = commands.Bot(command_prefix="ip", intents=discord.Intents.default())

@bot.command()
async def ping(ctx: commands.Context):
await ctx.send("HI")

@bot.listen("on_ready")
async def on_ready_ip():
print("online")

bot.run("my token")

slate swan
#

!code for next time...

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

maiden fable
#
import discord 
from discord.ext import commands 
bot = commands.Bot(command_prefix="ip", intents=discord.Intents.default()) 

@bot.command() 
async def ping(ctx:  commands.Context): 
     await ctx.send("HI") 
     
@bot.listen("on_ready")
async def on_ready_ip():
       print("online") 

bot.run("my token")
#

@lofty tide mind showing the error?

lofty tide
slate swan
#

sidenote: intents=discord.Intents.default() this is useless since the intents are already defaulted to the same

slate swan
#

oh, makes sense

lofty tide
gaunt ice
#

sarth

slate swan
#

but why would they use .default in 2.0 without .message_content? πŸ™‚

maiden fable
paper sluice
gaunt ice
#

are u making a bot for some server

lofty tide
#

it says "bad input"

maiden fable
#

Ah, nvm

maiden fable
slate swan
paper sluice
unkempt canyonBOT
#

Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.

A full traceback could look like:

Traceback (most recent call last):
  File "my_file.py", line 5, in <module>
    add_three("6")
  File "my_file.py", line 2, in add_three
    a = num + 3
TypeError: can only concatenate str (not "int") to str

If the traceback is long, use our pastebin.

lofty tide
maiden fable
slate swan
#

is it the same you were working on a few months back?

maiden fable
slate swan
#

ok

lofty tide
#

@maiden fable ?

maiden fable
#

Yea bro

cold sonnet
#

wdym wdym show the whole error

ashen perch
#

hey so im making a bot and im having a problem basically my bot is printing the IDs of everyone with a certain role and from that im trying to assign a variable to every id but everything i have tried so far does not work as everyone's id in this group acts like its all a single value

lofty tide
#

wdym show the whole error @maiden fable

ashen perch
#

k ty

maiden fable
paper sluice
ashen perch
#

didnt know it was possible though to assign a varriable as a value in a dictionary

lofty tide
lofty tide
#

line*

paper sluice
# lofty tide i dont understand that

do u know any python, if not i would recommend learning that before making a discord bot.
Making a discord bot as ur first project is shooting urself in the foot

crimson nova
#

Hey guys!
IΒ΄m working with pyCharm to make a discord bot (I started a few weeks ago, so sorry if I make a silly mistake). But earlier everything worked and now I get this error message:
Traceback (most recent call last): File "/Users...", line 3, in <module> from discord_slash import SlashCommand File "/Users...", line 9, in <module> from .client import SlashCommand # noqa: F401 File "/Users...", line 12, in <module> from . import context, error, http, model File "/Users...", line 10, in <module> from . import error, http, model File "/Users...", line 12, in <module> from .dpy_overrides import ComponentMessage File "/Users...", line 4, in <module> from discord import AllowedMentions, File, InvalidArgument, abc, http, utils ImportError: cannot import name 'InvalidArgument' from 'discord' (/Users...)
Does anybody know, how to solve it? I tried to delete everything (of course I saved it), so that there is only the: import discord from discord.ext import commands bot.run("TOKEN")
As soon as I want to import the Slash Commands, there is this error message. So is there somebody, who know to solve it?

lofty tide
lofty tide
crimson nova
maiden fable
slate swan
#

should i give him whole a- z code

maiden fable
#

Sure

slate swan
#

alr then

crimson nova
slate swan
#
import discord
from discord.ext import commands
intents= discord.Intents.all()
bot = commands.bot(command_prefix="!",intents=intents)
@bot.listen()
async def on_message(m):
    if m.content.lower() == "whats the ip":
         await m.channel.send("ip is the play.tryserver.net")
bot.run("token")
``` do
#

just use bot.listen() so you wont have to process_commands

#

ye i was typing in dc so

lofty tide
slate swan
slate swan
lofty tide
#

yeah a saw

umbral night
#

whats the difference between .listen and .event

lofty tide
slate swan
#

uh

slate swan
umbral night
#

lmfao what

slate swan
#

😳

umbral night
#

lmao why of all examples

loud junco
#
@bot.command(name='hydrorico')
async def hydrorico(ctx, arg: int):
  userid = str(ctx.author.id)
  if userid == '757508305256972338':
    matches = db.prefix(arg)
    del db[matches]
    await ctx.send(f'**{matches}** deleted from db')
  else:
    await ctx.send('**ACCESS DENIED**')
#

gg

lofty tide
slate swan
#

nvmd

#

didnt see thats str

loud junco
#

KEKW

umbral night
loud junco
#

its intended btw

slate swan
loud junco
#

ok

#

whats his problem

lofty tide
#

here now u can see the error

#

the line on red

slate swan
#

add ()

loud junco
#

listen here kiddo

slate swan
#

@bot.listen()

loud junco
#

dont make discord bot when u havent learn all the basics

lofty tide
#

nope
didnt worked

loud junco
#

ur going to end up making a bot that u dont understand why is it working at all

slate swan
#

error

dusky pine
#

no need to make a command - everyone knows already

umbral night
#
import discord
from discord.ext import commands

intents = discord.Intents.all()
bot = commands.bot(command_prefix = '!', intents = intents)

@bot.listen()
async def on_message(m):
  if m.content.lower() == 'whats the ip':
    await m.channel.send('the ip is, play.tryserver.net')

bot.run('TOKEN')
slate swan
#

?

umbral night
#

space the shit out

#

so it's easier to read

loud junco
#

u dont need command for that just do
await ctx.send('100%')
KEKW

slate swan
umbral night
umbral night
loud junco
loud junco
dusky pine
#
import random

@bot.command()
async def percent(ctx):
    await ctx.reply(f"{random.randint(0, 100)}% gay")
loud junco
#

why m

#

just go ctx

umbral night
#

ikr

dusky pine
slate swan
dusky pine
#

as long as bot is defined

loud junco
#

num1 = random.randint(0, 100
then blahblah num1%gae

slate swan
#

!e
import random
print(random.randint(0, 100))

unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

54
loud junco
#

oo nice

#

learn something new

slate swan
#

!e
import random
print(random.randint(0, 100))

#

make it shorter by doing it in a single line

umbral night
slate swan
lofty tide
umbral night
lofty tide
#

async def on_message(m):

slate swan
#

we all are simple python coders

loud junco
#

i cant foresee the error in ur console 🀣

slate swan
umbral night
#

oh

slate swan
#

the function is the error somehow

lofty tide
supple thorn
#

!e print(import("random").randint(0, 100))

unkempt canyonBOT
#

@supple thorn :white_check_mark: Your eval job has completed with return code 0.

62
loud junco
unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

{__import__('random').randint(0,100)}%
loud junco
#

ur extracting the wrong part of error

slate swan
#

wait what

#

lol

loud junco
#

SARTH IS HERE

slate swan
#

ohhhh no, i forgot the f

supple thorn
loud junco
#

JESUS

loud junco
#

help him

lofty tide
#

import discord
from discord.ext import commands

intents = discord.Intents.all()
bot = commands.bot(command_prefix = '!', intents = intents)

@bot.listen()
async def on_message(m):
if m.content.lower() == 'whats the ip':
await m.channel.send('the ip is, play.tryserver.net')

bot.run('here is the bots token')

loud junco
#

and me after this kekw

slate swan
loud junco
#
import discord
from discord.ext import commands

intents = discord.Intents.all()
bot = commands.bot(command_prefix = '!', intents = intents)

@bot.listen()
async def on_message(m):
  if m.content.lower() == 'whats the ip':
    await m.channel.send('the ip is, play.tryserver.net')

bot.run('here is the bots token')
#

i helped u to colour it

lofty tide
#

ty

dusky pine
#

!e
globals()["__builtins__"].__import__("random").randint(0, 100)

slate swan
dusky pine
#

!e
print(globals()["__builtins__"].__import__("random").randint(0, 100))

unkempt canyonBOT
#

@dusky pine :white_check_mark: Your eval job has completed with return code 0.

5
slate swan
#

uh

lofty tide
supple thorn
loud junco
slate swan
#

on discord

loud junco
#

thats what he is asking

lofty tide
#

um

loud junco
#

prefix + command name

umbral night
#
@bot.event
async def on_message(msg : discord.Message):
  if msg.content == 'whats the ip':
    await msg.channel.send('the ip is, play.tryserver.net')
  await bot.process_commands(msg)```
loud junco
#

...

umbral night
#

id use this personally

cold sonnet
lofty tide
#

i think its that:
if m.content.lower() == 'whats the ip':
await m.channel.send('the ip is, play.tryserver.net')

slate swan
loud junco
#

but its not the part

#

the thing inside if is the problem

umbral night
loud junco
#

lol

umbral night
loud junco
#

just go (ctx)

umbral night
#

ig

slate swan
slate swan
# umbral night how

cause their bot is a discord.Client, and it does not have a process_commands method

loud junco
#

gg

#

pepo nowadays still use discord.client? 🀣

#

hunter told me to change to bot

#

to make life easier

slate swan
#

life is not easy ;<

loud junco
#

make life easier != life is easy

umbral night
slate swan
loud junco
#

erm ok

#

but the error is in the if loop

#

not the thing outside ;-;

slate swan
#

what error do you get actually?

slate swan
loud junco
slate swan
umbral night
loud junco
#

πŸ’€

slate swan
#

why is he "coding" in python then.

slate swan
#

i just gived him the code

umbral night
#

gived

slate swan
slate swan
# loud junco

the error is actually coming from your error handled, may i see what line 1733 ( oof huge file) is?

loud junco
slate swan
loud junco
#
elif isinstance(error, KeyError):
    await ctx.send(f'**{ctx.author.name}**, your account is either not created yet or is not in the latest version. Try `rpm start`')
slate swan
#

does the bot have permission to send messages in that channel?

loud junco
#

sure

slate swan
#

wait what's db.prefix?

loud junco
#
matches = db.prefix(arg)
    del db[matches]
    await ctx.send(f'**{matches}** deleted from db')
```this is the part that gets error
loud junco
slate swan
#

are you using replit db?

#

teplit

loud junco
#

no better option

slate swan
#

lmao

loud junco
#

i cant let my pc run 247

slate swan
loud junco
#

i use the keep_alive thing

slate swan
#

can u pls teach me

#

honestly i have no idea how replit db works

loud junco
#

gg

slate swan
#

lmao πŸ’€ ppl use repl db?

#

πŸ˜” and im not going to open that cursed website to check it

slate swan
slate swan
loud junco
slate swan
#

!pip aiosqlite

unkempt canyonBOT
slate swan
#

sorry dave

#

( dont mind me, im high)

loud junco
#

=.=

slate swan
#

im evil 😈 i will expose everyone

loud junco
#

alright its working @slate swan

slate swan
#

show code and full traceback

#

that's still not complete traceback

loud junco
#

i think matches might be a list so i added

for match in matches:
  del db[match]
```BIG BRAIN
slate swan
#

great yert

#

great very

#

woah nice emote

loud junco
#

gg output

slate swan
#

json?

#

damn, a lot of stuff deleted from db

loud junco
#

i think so

loud junco
slate swan
#

πŸ’€ json has curly brackets not tuple ...

loud junco
#

replit uses json i think

slate swan
#

replit db uses json like structures

#

owo?

slate swan
loud junco
slate swan
loud junco
#

there are soooooooo many

slate swan
loud junco
#

and the stupid error handler is not working

slate swan
#

i see.. i'm grateful for not using it then lmao

slate swan
#

nosql databases like mongodb use json files to save data

#

ngl, i feel SQL >>> nosql :")

slate swan
loud junco
#
@bot.event
async def on_command_error(ctx, error):
  if isinstance(error, commands.CommandOnCooldown):
    seccd = round(error.cooldown.get_retry_after())
    mincd = 0
    hrcd = 0
    rseccd = 0
    rmincd = 0

    if seccd > 59:  
      rseccd = int(seccd % 60)
      mincd = int((seccd - rseccd) / 60)
      if mincd > 59:
        rmincd = int(mincd % 60)
        hrcd = int((mincd - rmincd) / 60)
    else:
      rseccd = seccd
    await ctx.send(f'''
Dont spam :/ 
Try again in another **{hrcd}h {rmincd}m {rseccd}s**
''')
    
  elif isinstance(error, commands.CommandNotFound):
    await ctx.send(f'**{ctx.author.name}**, this command doesnt exist, check your spellling maybe??')
  elif isinstance(error, KeyError):
    await ctx.send(f'**{ctx.author.name}**, your account is either not created yet or is not in the latest version. Try `rpm start`')
    
  else:
    raise error
```the keyError handler isnt working
#

😭

slate swan
tropic flame
#

guys

regal pulsar
#

nosql >

slate swan
#

no database >

slate swan
slate swan
slate swan
lofty tide
#

@loud junco can u pls create a bot and try that code and send it when its work?

tropic flame
#

im coding an autotyper for discord so like its not a bot. i want to add a function when if someone sends STOP then it should quit() i need some help

regal pulsar
lofty tide
#

or someone else

slate swan
slate swan
loud junco
#

wdym send it when it works

loud junco
tropic flame
#

im coding an autotyper for discord so like its not a bot instead its connected to an account . i want to add a function when if someone sends STOP then it should quit() i need some help

slate swan
slate swan
loud junco
#

nonono

slate swan
regal pulsar
slate swan
#

for that keyerror.part

loud junco
regal pulsar
#

and in the autotyper bit

unkempt canyonBOT
#

Hey @slate swan!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

slate swan
regal pulsar
#

add if cancel == False:

loud junco
#

command is not defined

#

what does command even stand for

regal pulsar
slate swan
slate swan
regal pulsar
#

like

loud junco
slate swan
slate swan
regal pulsar
slate swan
regal pulsar
#

i might be wrong

slate swan
#

ae wtf @loud junco tell your gender bruh

loud junco
regal pulsar
slate swan
regal pulsar
#

self bot?

slate swan
#

uwu?

loud junco
regal pulsar
#

thats against tos

loud junco
#

whats that suppose to mean

slate swan
regal pulsar
#

so i cant help sadly

slate swan
#

uwu db

slate swan
slate swan
regal pulsar
slate swan
#

that's not complete traceback bro...

regal pulsar
#

send it all

slate swan
#

!traceback

unkempt canyonBOT
#

Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.

A full traceback could look like:

Traceback (most recent call last):
  File "my_file.py", line 5, in <module>
    add_three("6")
  File "my_file.py", line 2, in add_three
    a = num + 3
TypeError: can only concatenate str (not "int") to str

If the traceback is long, use our pastebin.

slate swan
#

^ @slate swan pls

#

uwu == json
return True

slate swan
#

scroll a lil bit

regal pulsar
slate swan
#

πŸ˜‚

slate swan
loud junco
slate swan
slate swan
#

not really

loud junco
regal pulsar
regal pulsar
#

you have to use the @bot.event decorator here

slate swan
#

404: Not Found means you didn't get a response for your request

loud junco
loud junco
#
@bot.event
async def on_command_error(ctx, error):
  if isinstance(error, commands.CommandOnCooldown):
    seccd = round(error.cooldown.get_retry_after())
    mincd = 0
    hrcd = 0
    rseccd = 0
    rmincd = 0

    if seccd > 59:  
      
      rseccd = int(seccd % 60)
      mincd = int((seccd - rseccd) / 60)
      if mincd > 59:
        rmincd = int(mincd % 60)
        hrcd = int((mincd - rmincd) / 60)
    else:
      rseccd = seccd
    await ctx.send(f'''
Dont spam :/ 
Try again in another **{hrcd}h {rmincd}m {rseccd}s**
''')
    
  elif isinstance(error, commands.CommandNotFound):
    await ctx.send(f'**{ctx.author.name}**, this command doesnt exist, check your spellling maybe??')
  elif isinstance(error, KeyError):
    await ctx.send(f'**{ctx.author.name}**, your account is either not created yet or is not in the latest version. Try `rpm start`')
    
  else:
    raise error
#

im giving up this keyerror handler

slate swan
loud junco
#

its been days and its not fixed

slate swan
#

i win

slate swan
regal pulsar
slate swan
slate swan
regal pulsar
slate swan
slate swan
regal pulsar
slate swan
slate swan
regal pulsar
#

oh wait

slate swan
slate swan
regal pulsar
#

nvm :/

slate swan
slate swan
#

πŸ˜‚

slate swan
#

....

#

i cant even type properly anymore, I'll just go study

#

im here from around 5 hours

#

get a life :")

regal pulsar
#

oh yeah

slate swan
regal pulsar
loud junco
slate swan
regal pulsar
#

behold

loud junco
#

after i reworked rpm start it just wont work anymore

slate swan
slate swan
regal pulsar
#

oh yeah i wanted to know

slate swan
regal pulsar
#

is it possible to delete an instance of a class within the class

#

something like

slate swan
#

wait what?

regal pulsar
#
class Test:
    def __init__(self):
        pass
    
    def delete(self):
        del self
slate swan
regal pulsar
#

this wont work but you get what i mean

slate swan
# regal pulsar

uhm... your 2nd & 3rd line.. one of them is sure useless :")

slate swan
slate swan
#

i mean it shows IDLE after some time right?

#

^ +1, if using extension

slate swan
regal pulsar
slate swan
slate swan
regal pulsar
#

ill never change it

regal pulsar
loud junco
#

it outputs

slate swan
# loud junco yes

add a print statement before ctx.send there to see if it gets triggered

loud junco
#

ok

#

put it at where

#

right above it?

slate swan
#

ok ill start coding now

#

my giv cmd

slate swan
loud junco
#

but it wont print i think

#

if it prints then the error wont spam my console

#

but i ttry

#

nope it doesnt print anything

#

@slate swan

paper sluice
loud junco
#

hi zebra

#

help me

slate swan
loud junco
#

;-; i hate repetitive work

slate swan
#

that would be better to use since KeyError can come from may other points too

brisk dune
#

?

slate swan
#

nothing

brisk dune
#

Bruh don't delete your messages

#

it makes me look stupid with the question mark

paper sluice
slate swan
#

hi ded chat

jade tartan
#

Hi can someone help me please?

slate swan
#

only when you mention your problem

jade tartan
#
Traceback (most recent call last):
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event   
    await coro(*args, **kwargs)
  File "c:\Users\thoma\OneDrive\Desktop\discord server bot\Bot2.py", line 91, in on_raw_reaction_remove
    for role_id, msg_id, emoji in client.reaction_roles:
AttributeError: 'Bot' object has no attribute 'reaction_roles'```
#
async def on_raw_reaction_remove(payload):
    for role_id, msg_id, emoji in client.reaction_roles:
        if msg_id == payload.message_id and emoji == str(payload.emoji.name.encode("utf-8")):
            guild = client.get_guild(payload.guild_id)
            await guild.get_member(payload.user_id).remove_roles(guild.get_role(role_id))
            return```
slate swan
#

Bot does not have a reaction_roles attribute

#

until you're assigning an attribute yourself

jade tartan
#

But I made me my bot where the member would need to click on the reaction emoji to get a reaction role to see the rest of my server channels

#

So

dusky pine
#

what do you expect client.reaction_roles to be

#

it's not a real discord.py feature, nor is it a discord api feature

#

first you have to check if the message being reacted/unreacted to is a reaction roles message

#

then you could possibly extract the role out of that

jade tartan
#

Ok how would i do that?

fleet sparrow
#

is there a way to check when a channel is created?

dusky pine
fleet sparrow
#

ty

jade tartan
#

How would i do that?

dusky pine
#

Sorry

fleet sparrow
#

huh

#

i made a script long time ago @jade tartan but dont give you a role just reply to you in dm

#

i can send it to you and you can edit it

#

Β―_(ツ)_/Β―

bleak karma
#

is there a way to check if theres nothing on a list (ex. nothing on a db yet)

bleak karma
bleak karma
#

oh thank you sm

dusky pine
#

empty lists are falsy

fleet sparrow
# jade tartan Ok
@bot.command(aliases=['download', 'DOWNLOAD'])
@commands.has_permissions(administrator=True)
async def download(ctx, link=None, *, title=None, desc='React to download'):
    if not link or not title:
        embed=discord.Embed(title='How to use the command', color=discord.Color.red())
        await ctx.channel.send(embed=embed)
        return
    else:
        embed=discord.Embed(title=f'{title}', description=f'{desc}', color=discord.Colour.red())
        message = await ctx.channel.send(embed=embed)
        await message.add_reaction('βœ…')
        def check(reaction, user):
            if user.id != bot.user.id:
                return user and str(reaction.emoji) == 'βœ…'
        while True:
            reaction, user = await bot.wait_for('reaction_add', check=check)
            dow=discord.Embed(title=f'{title}', description=f'Here is your {title} download link\n[Download click here]({link})', color=discord.Colour.green())
            dow.set_footer(text='・・')
            await user.send(embed=dow)
            channel=bot.get_channel(769990892894945332)
            await channel.send(f'{user.name} downloaded send')```
fleet sparrow
dusky pine
#

ctx.channel.send and ctx.send are both equivalent

supple thorn
slate swan
#

"how tu use"

supple thorn
#

I think i use too much python lmfao

slate swan
fleet sparrow
#

xD

dusky pine
supple thorn
slate swan
#

*phone, ash

slate swan
slate swan
supple thorn
#

Wait

#

Ashley?

dusky pine
slate swan
slate swan
supple thorn
#

Fuck i thought eito was just trying to catfish people with that avatar

jade tartan
#

Nah nvm I worked it out

slate swan
#

well he's ash atm

supple thorn
slate swan
#

lmao

supple thorn
#

Kek

jade tartan
#

I have a question would python let us add tags to our code? If that make sense

slate swan
#

tags?

slate swan
#

comments?

supple thorn
#

Comments?

slate swan
#

price tags?

jade tartan
#

Tags. Meaning to add or remove tags

supple thorn
#

Name tags?

jade tartan
#

As in roles

supple thorn
slate swan
jade tartan
#

Like tags the one that Carl bot has

supple thorn
supple thorn
#

What are tags that carl bot uses

slate swan
#

?roleadd @user @role like this?

#

int(message.content)
uh this will return bole right

supple thorn
#

Like wdym

supple thorn
jade tartan
#

Hang on I’ll show u a ss

slate swan
#

message.content.isdigit() returns a bool

#

ok thanks :D

slate swan
supple thorn
supple thorn
#

I'm having a stroke

jade tartan
slate swan
slate swan
#

i was not getting anything

supple thorn
slate swan
#

never used isdigit() thats why

slate swan
slate swan
jade tartan
supple thorn
slate swan
supple thorn
slate swan
slate swan
supple thorn
supple thorn
jade tartan
slate swan
#

lol edited msg

jade tartan
slate swan
#

he is asking fb?

#

ig he seen db as fb

jade tartan
supple thorn
jade tartan
slate swan
jade tartan
#

!ot

unkempt canyonBOT
slate swan
slate swan
supple thorn
#

Not unless that's what people use your bot for

supple thorn
#

Or reported

slate swan
slate swan
#

uh how do i exit a function? i forgot

slate swan
jade tartan
#

So am creating a role tag id have to go through db?

slate swan
#

dashboards are just meh until you have a bot with vast usage

slate swan
slate swan
#

thanks +1

#

.topic

lament depotBOT
#
**What unique features does your bot contain, if any?**

Suggest more topics here!

supple thorn
#

.topic

#

Sadge

jade tartan
slate swan
slate swan
jade tartan
#

At least it responded to you tho

jade tartan
#

Any way ama go add other cmds to my own python bot see ya

slate swan
#

πŸ‘‹

slate swan
warm tulip
#

guys how i can tell my bot to send the member joined server a private DM

slate swan
#

on member join event

#

!d discord.on_member_join gives you a member, you can use member.send

unkempt canyonBOT
#

discord.on_member_join(member)``````py

discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") join or leaves a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").

This requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
slate swan
#

!d
global

unkempt canyonBOT
#

7.12. The global statement


global_stmt ::=  "global" identifier ("," identifier)*
``` The [`global`](https://docs.python.org/3/reference/simple_stmts.html#global) statement is a declaration which holds for the entire current code block. It means that the listed identifiers are to be interpreted as globals. It would be impossible to assign to a global variable without `global`, although free variables may refer to globals without being declared global.

Names listed in a [`global`](https://docs.python.org/3/reference/simple_stmts.html#global) statement must not be used in the same code block textually preceding that `global` statement.

Names listed in a [`global`](https://docs.python.org/3/reference/simple_stmts.html#global) statement must not be defined as formal parameters, or as targets in [`with`](https://docs.python.org/3/reference/compound_stmts.html#with) statements or [`except`](https://docs.python.org/3/reference/compound_stmts.html#except) clauses, or in a [`for`](https://docs.python.org/3/reference/compound_stmts.html#for) target list, [`class`](https://docs.python.org/3/reference/compound_stmts.html#class) definition, function definition, [`import`](https://docs.python.org/3/reference/simple_stmts.html#import) statement, or variable annotation.
slate swan
#

and the last line, yes it needs member intents to work

tacit token
#

Slash command not work

import discord
from discord.ext import commands
from discord_slash import SlashCommand, SlashContext

bot = commands.Bot(command_prefix="!", intents=discord.Intents.all())
slash = SlashCommand(bot)

@slash.slash(name="test")
async def _test(ctx: SlashContext):
    embed = discord.Embed(title="embed test")
    await ctx.send(content="test", embeds=[embed])
boreal ravine
slate swan
#

2.0 is

#

what

boreal ravine
#

correct

slate swan
#

bruh just get the thing

#

lame

#

lmao

boreal ravine
#

snow #bot-commands

#

what do context managers have to do with subclassing bot?

slate swan
#

@slate swan @boreal ravine should have passed mathematics at least :)

slate swan
#

lol

tacit token
#

lmao

slate swan
#

πŸ’€ brh?

slate swan
#

also discord 2.0 is a str

#

str?

#

ye if u do

#

str can be anything :D

#

...

#

what.....

#

😭

zinc phoenix
#
@bot.command()
async def giftcode(ctx):
  await ctx.channel.send("NhαΊ₯n vΓ o để xem code: ",components = [Button(label="Xem gift code.")])
  interaction = await bot.wait_for("button_click", check= lambda i: i.component.label.startswith("Click", timeout=15.0))
  await interaction.respond("Gift code")```
#

Its throwing an error

#

Can anyone help

flat solstice
#

so I have this little mockup of a tag formatter. what I want to do is
a. identify when one of my tags is in the string
b. if one of my tags is in the string, identify which tag it is (used to determine what to do with the values stored in keep
c: find any times that :number: is found in the string, I'm using split for this atm but there's probs better ways
d. once i've found one of these :number: extract number from it and append number to my keep list
e. replace any tags in the string with the value from the tags dict
f. print the final string (or do something with it since this is for a discord bot
note: I'm going to iterate over every number in keep to try to resolve it to member, guild, role or channel, it might be better if keep is a dict so i can have separate keys for each type and just make the second list under each key however this will involve identifying which tag was used in the string

keep = []
tags = {
    "{user_name}": "(name tag)",
    "{user_id}": "1234",
}
text_b = "Hello World user_name:941314754851524639: It's almost my birthday user_id"
split_b = text_b.split(":")
b = ""
for string in split_b:
  # Need to check if any of the items in the list are ints (these will be the ID's like 941314754851524639
  if int(string) is True:
    keep.append(int(string))
  else: continue
  b = b + " " + string
for tag, val in tags.items():
  out_b = b.replace(tag, val)
print(f"split_b: {split_b}")
print(f"string_b: {b}")
print(f"out_b: {out_b}")
print(f"keep: {keep}")
slate swan
#

😳

#

o my

slate swan
unkempt canyonBOT
#

@slate swan :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 6, in <module>
003 | TypeError: __str__ returned non-string (type NoneType)
slate swan
#

lmao

#

she's just proving that not anything can be str LMAO

velvet haven
#
@commands.command(name='resume', help="Resumes music")
@commands.has_permissions(manage_guild=True)
 async def _resume(self, ctx: commands.Context):
        """Resumes a currently paused song."""

        if not ctx.voice_state.is_playing or ctx.voice_state.voice.is_paused():
            ctx.voice_state.voice.resume()
            await ctx.message.add_reaction(':play_pause:')```
i want the command to function only when i react
zinc phoenix
#

The error message is "Command raised an exception: TypeError: startswith() takes no keyword arguments"

slate swan
#

do common sense exists?

slate swan
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

slate swan
#

bruh

slate swan
slate swan
#

but nice try enter, you're good man

slate swan
velvet haven
#

i don't want help with music stuff

slate swan
#

ye panda

#

2 days still stuck in same problem sad

velvet haven
#

how do i make the bot respond to a command only when someone reacts to it

velvet haven
slate swan
velvet haven
paper sluice
#

!ytdl

unkempt canyonBOT
#

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
slate swan
slate swan
#

even ur acccount

velvet haven
#

why

slate swan
#

ytdl is illegal

slate swan
#

πŸ’€

#

I-

velvet haven
#

πŸ˜’

slate swan
#

scary

#

gets frightened

#

i hope u know that your deleted messsages must be getting logged in some channel set-up by staff here

#

just telling :")

paper sluice
#

!src log

unkempt canyonBOT
#
Bad argument

Unable to convert 'log' to valid command, tag, or Cog.

slate swan
#

there is no rule that u cant delete msg πŸ€·β€β™‚οΈ

#

so you're ready to show it to staff but not to us :'/ sad

slate swan
slate swan
slate swan
#

i mean, only at relevant places :")

#

..

#

i mean target abuse

#

nvm

#

MODS ONLY FOR TESTING PURPOSE NO HARM TO ANYONE

#

!of @slate swan :")

unkempt canyonBOT
slate swan
#

LMAO

slate swan
#

^ +1

#

(at least when not directed towards someone)

#

LMAO

velvet haven
#

how long will it take fr my bot to get banned lmao

slate swan
slate swan
#

after online

velvet haven
#

bruh

slate swan
#

api auto catch if ur using that

#

and ban

paper sluice
#

πŸ‘€ when did @unkempt canyon switch to dpy 2.0

velvet haven
#

its been 5 to 6 days already

#

bruh

slate swan
#

@velvet haven you wont get banned unless someone reports your application for doing so

#

^ +1

slate swan
#

im evil person 😈

#

πŸ’€

velvet haven
slate swan
slate swan
paper sluice
unkempt canyonBOT
#

bot/__main__.py line 62

case_insensitive=True,```
slate swan
#

LMAO

#

wtf

#

πŸ€” still wtf

slate swan
#

yo

#

im using ytdl then

#

in my private bot :O

#

for music in dc

velvet haven
#

bruh

slate swan
velvet haven
#

ye thank you

boreal ravine
paper sluice
#

πŸ‘

tired hinge
#

in an error handler cog, how can i get the name of the required argument when commands.MissingRequiredArgument is raised

slate swan
#

Why won't this work πŸ˜” and just returns an empty list?

[record['key'] for record in all_records if 967356333336690688 in record['users']]

this is the data

[{'key': '967356333336690688', 'users': [925079016174682200]}]
slate swan
boreal ravine
#

the id is a string

slate swan
#

its not

#

i checked the type

slate swan
#

uhhh

#

wth

boreal ravine
#

what ryuga said

slate swan
#

is gonna make me cry

tired hinge
#

how do i access the missing param in missingrequiredargument from an errorhandler cog

slate swan
#

!e
print(967356333336690688==967356333336690688)

unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

True
slate swan
#

its same

#

pardon?

#

they're different

#

i mean key

#

nvmd

#

u know im bad at list compre i understand late

paper sluice
#

all good

hushed galleon
slate swan
#

🀨

unkempt canyonBOT
#

@slate swan :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 2, in <module>
003 | TypeError: list indices must be integers or slices, not str
slate swan
#

wait what?

#

a list comprehension iterates

#

sory :<

hushed galleon
slate swan
#

!e

all_records = [{"key": 12345678, "users": [12345678, 12345678]}]

print([record['key'] for record in all_records])
#

wait

unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

[12345678]
slate swan
#

yeah....

hushed galleon
unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

['967356333336690688']
tired hinge
#

when i do print(error.param.name), nothing gets printed

slate swan
#

hm yeah, i know that works, but it doesnt really seem to work when I replace the id with author.id

tired hinge
#
elif isinstance(error, commands.MissingRequiredArgument):
          await ctx.send("You're missing a required parameter.")
          raise error
          print(str(error.param.name)) #---> this doesn't print anything.
slate swan
#

it is πŸ˜”

hushed galleon
slate swan
#

yeah gonna burn some of my own brain

tired hinge
slate swan
#

can anyone help me with this error
'discord.ext.commands.bot' has no attribute 'wait_for'

#

self,reaction, user = await bot.wait_for("reaction_add", timeout=60, check=check) on this line

#

the error comes

cold sonnet
#

commands.Bot

#

capitalized

slate swan
#

what shud i change?

cold sonnet
#

bot = commands.Bot

slate swan
#

ah

#

Client.wait_for() missing 1 required positional argument: 'event'

#

now i get this error

slate swan
unkempt canyonBOT
#

wait_for(event, /, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message,
or to react to a message, or to edit a message in a self-contained
way...
slate swan
#
TypeError: Client.wait_for() missing 1 required positional argument: 'event'```
slate swan
#

im stupid

slate swan
#

It should be reaction, user = ?

#

πŸ€”

slate swan
#

im doing it in a cog

slate swan
#

@slate swan @paper sluice thanks for the effort of trying to help, turns out my database is fucked up and is storing wrong values for no reason

#
AttributeError: 'Rules' object has no attribute 'bot'```
#

Why so many errors lol

slate swan
slate swan
stray carbon
#
class Welcome(discord.ui.View):

    def __init__(self, member):
        self.member = member
        super().__init__(timeout=300)

    @discord.ui.button(label="Welcome", custom_id="welcome")
    async def callback(self, interaction,button):
        await interaction.response.send_message(f'**{interaction.user.name}** has welcomed **{self.member.name}**')

How can i make it such that people can click only once?

slate swan
#

I feel like i lost some brain cellsπŸ˜­πŸ’€

paper sluice
slate swan
#
AttributeError: 'Rules' object has no attribute 'bot'```
paper sluice
slate swan
#

nvm

#

i won put ni a cog

stray carbon
paper sluice
stray carbon
#

what to do in the check lol

paper sluice
#

if interaction.user == author...

stray carbon
#

thats my question

tired hinge
#

just out of curiosity:
is it possible to run the same code on two bots by having multiple bot.run(token) in the code?

stuck lily
#

hello... is there any free hosting server that we can use to host our discord bot, so it can stay online 24/7??

slate swan
# stray carbon thats my question

Make a db? Or something else. if the author clicked on the button. Their id will append to the db list. And check if the author's id in the list

paper sluice
#

ehh?

slate swan
paper sluice
#
class Welcome(discord.ui.View):

    def __init__(self, member):
        self.member = member
        super().__init__(timeout=300)

    @discord.ui.button(label="Welcome", custom_id="welcome")
    async def callback(self, interaction,button):
        if interaction.user == self.member:
            await interaction.response.send_message(f'**{interaction.user.name}** has welcomed **{self.member.name}**')

assuming that self.member is the member u want to be able to use the buttons

slate swan
iron sorrel
#
class YesNoButton(ui.View):
    def __init__(self, *, timeout: float = 180, intended_user: disnake.user.User = None):
        super().__init__(timeout = timeout)
        self.intended_user = intended_user
        self.choice = None
    
    @ui.button(label="yes", style=ButtonStyle.green)
    async def _yes(self, button: Button, inter: MessageInteraction):
        if self.intended_user:
            if inter.author != self.intended_user:
                return
        self.choice = True
        self.stop()

    @ui.button(label="no", style=ButtonStyle.danger)
    async def _no(self, button: Button, inter: MessageInteraction):
        if self.intended_user:
            if inter.author != self.intended_user:
                return
        self.choice = False
        self.stop()

inside cog:

btn_confirm = YesNoButton()
if amount <= database[inter.author.id].money:
  await inter.send(embed = em_confirm, view = btn_confirm)
  await btn_confirm.wait()
 
  if btn_confirm.choice:
    # user clicked yes
  else:
    # user clicked no
iron sorrel
iron sorrel
#

you know when ppl enter servers

#

it says

slate swan
#

ye?

zinc phoenix
#

What does ephemeral mean in discord components

slate swan
#

dont mind the command

zinc phoenix
#

Oh

#

Thanks

slate swan
zinc phoenix
#

How do I change the button's color in discord_components

slate swan
# slate swan this

is this a command you made for tracking/stalking people with their messages? 😈

slate swan
#

don't use that library though, use discord.py master or a fork

slate swan
zinc phoenix
paper sluice
#

!d discord.ButtonStyle

unkempt canyonBOT
#

class discord.ButtonStyle```
Represents the style of the button component.

New in version 2.0.
slate swan
slate swan
slate swan
zinc phoenix
#

Thanks

slate swan
#

imagine just codes

slate swan
stray carbon
slate swan
slate swan
stray carbon
#

I mean the check

#

that a user can click only once

#

i am confused how to do that

slate swan
#

what a bot, that ask for welcome

stray carbon
#

wym?

zinc phoenix
slate swan
#

import

stray carbon
slate swan
zinc phoenix
#

Oh

#

Thanks

slate swan
#

are u coding on replit?

stray carbon
slate swan
#

not u

zinc phoenix
slate swan
zinc phoenix
# slate swan ohh

I have a question, how do I kinda like make the bot send a message in a specific channel, next time when I turn off the bot and run again, I dont want it to resend that message again, are there any ways to check if the message's already exist

heavy folio
#

database

slate swan
#

or you could iterate through the channel's history (find the specific message id) though i dont recommend it

zinc phoenix
#

Thanks

slate swan
#
    def timer(self):
        while True:
         with open("noob.json") as f:
          logs2 = json.load(f)
         for keys in logs2.keys():
            a = logs2[keys]
            if a[0] >= datetime.now():
                print("end")

fine?

#

nextcord and discord?

velvet haven
#

2 is better than 1

slate swan
#

what

velvet haven
#

πŸ™ƒ

granite parcel
#

role.members

#

returns with

slate swan
#

?

#

..

granite parcel
#

how i convert it to string

slate swan
#

what u want

#

name?

granite parcel
#

i want to mention the user with that role

slate swan
#

use member.mention

granite parcel
#

it isnt working

slate swan
#

show code

granite parcel
#
**Members with** {role.mention}: {role.members}```
heavy folio
#

e.g. [mem.mention for mem in role.members] or 'No members have this role'

granite parcel
#

for role in member.roles ?

slate swan
#

use list compre

granite parcel
#

ohk

heavy folio
slate swan
#

..

heavy folio
#

what the hell is that

slate swan
olive osprey
#

Hey,
I just saw someone used custom emojis in a dropdown, but their bot is coded in JavaScript, I tried to use custom emojis in a dropdown menu also, but it raised the error unknown emoji.

heavy folio
#
  1. i wouldnt use json as a db
  2. tias
olive osprey
#

I've tried to copy paste the emoji name & ID (like you normally use custom emojis with a bot) and defining it as a variable, both didn't work

slate swan
heavy folio
#

try it and see

granite parcel
#

how do i remove ['']

heavy folio
#

wait no

granite parcel
#

i got it

heavy folio
#

!d str.join

unkempt canyonBOT
#

str.join(iterable)```
Return a string which is the concatenation of the strings in *iterable*. A [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") will be raised if there are any non-string values in *iterable*, including [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "bytes") objects. The separator between elements is the string providing this method.
heavy folio
#

e.g. , .join(iterable)

olive osprey
# heavy folio code
    @commands.command()
    @commands.bot_has_permissions(embed_links=True)
    async def test(self, ctx):
      testemoji = "![2_LN_pepeStares](https://cdn.discordapp.com/emojis/901311580388589568.webp?size=128 "2_LN_pepeStares")"
      await ctx.reply("Test", components=[Select(
        placeholder="Select something",
        options=[
          SelectOption(label="Test", value="1", emoji=testemoji),
          SelectOption(label="Infos", value="2", emoji="![2_LN_pepeStares](https://cdn.discordapp.com/emojis/901311580388589568.webp?size=128 "2_LN_pepeStares")")],
          custom_id="m")])

Those are the both things i tried
This is the error:
https://i.imgur.com/Huey3id.png

heavy folio
#

ah

#

hmm

olive osprey
#

Welp, normal emojis do work that's the thing

heavy folio
#

does the bot have access to the emoji?

olive osprey
#

Yeah, it has admin perms

heavy folio
#

access to the server where the emoji belongs

olive osprey
#

It's the same server where I invoked the command

heavy folio
#

hmm

olive osprey
#

Is there a fetch_emoji function for guilds? Maybe that would work

#

!d discord.Guild.fetch_emoji

unkempt canyonBOT
#

await fetch_emoji(emoji_id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Retrieves a custom [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji") from the guild.

Note

This method is an API call. For general usage, consider iterating over [`emojis`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.emojis "discord.Guild.emojis") instead.

Changed in version 2.0: `emoji_id` parameter is now positional-only.
cold sonnet
#

why not get

olive osprey
#

It works with fetching it, let me try with get

thick basin
#

i fucked something up in my code and @commands.is_owner() doesn't seem to work in cogs
There is no response inside to my command

So this is my bot definition

class Bot(commands.AutoShardedBot):
  def __init__(self):
    allowed_mentions = discord.AllowedMentions(everyone=False,
    roles=False,
    users=True)
    super().__init__(command_prefix=_prefix_callable, # A function i wrote
    description="I am a robot",
    pm_help=None,
    help_command=PaginatedHelpCommand(),
    help_attrs=dict(hidden=True),
    chunk_guilds_at_startup=False,
    heartbeat_timeout=150.0,
    strip_after_prefix=False, 
    allowed_mentions=allowed_mentions,
    intents=discord.Intents.all(),
    enable_debug_events=True,
    case_insensitive=True,
    owner_id = 583174748478111745)

For example this isn't working

@commands.has_permissions(manage_messages=True)
@commands.command(hidden=True)
@commands.is_owner()
async def purge(self,ctx,limit:int):
    await ctx.message.delete()
    await ctx.channel.purge(limit=limit)
slate swan
#

give msg reactions docs pls

cold sonnet
#

should work too

#

if get works, use that instead

olive osprey
#

Hm

slate swan
#

!d disnake.Message.reactions

unkempt canyonBOT
slate swan
#

lmao

olive osprey
#

what

#

bruh

slate swan
#

i just type for test and it worked

olive osprey
cold sonnet
#

I feel an urge to print the bot's cache once

cold sonnet
#

random innit

#

I'd like to see it

#

like Mee6's cache

slate swan
cold sonnet
#

thousands of guilds and hundred thousands of member objects

slate swan
#

iirc carl has a higher number of users than Mee6

#

plus Mee6 isnt anything compared to carl

cold sonnet
#

hm

slate swan
#

I had more commands than carl

cold sonnet
#

My bot's cooler than Carl cuz it's mine

slate swan
brisk dune
#

Radio Silence