#discord-bots

1 messages · Page 550 of 1

valid niche
#

sounds like the discord API is disconnecting you and the bot is automatically reconnecting

slate swan
#

How can I check if a argument is a mention or not?
for example !info @slate swan

valid niche
slate swan
fallow mauve
#

im trying to make it so my bot will DM me when someone DMs the bot, telling me what they said and who said it. I've tried this but all this does is spam "Hi (:" in the person's DM with the bot, how do i fix this?

valid niche
#

that way it raises badargument when it couldn't convert the given argument

unreal ingot
#

Hello, is it somehow possible to log commands that got ran my users? i have made this a long time ago Log(ctx.message.author, 'paymenthistory') but seems like the Log function not exist anymore and i cant get it back....

slate swan
valid niche
#
@bot.command()
async def foo(ctx, user: discord.User):
  # user is a discord.User here, and it automatically checks if it's valid
fallow mauve
#

whats that?

valid niche
slate swan
valid niche
slate swan
#

what?

#

that's too complicated?

valid niche
#
async def foo(ctx, user: typing.Optional[discord.User]=None):
  if not user:
    user = ctx.author
valid niche
#

it's triggering itself

#

you are sending a message, and this triggers on_message again

valid niche
#

use INSERT INTO to make a new row

valid niche
#

it's a stdlib

valid niche
#

also i reccomend you to follow PEP 8 naming conventions

valid niche
#

you named your bot Bot with capital B, which is not conventional and can cause errors or confusion

valid niche
valid niche
#

well you said you wanted to add a new warning row right? so INSERT INTO will add a new row for a new warning

fallow mauve
valid niche
#

if message.author.bot is the easiest. This returns true if the author is a bot, this does make it ignore ANY bot, not only itself

valid niche
#

otherwise it's if message.author == bot.user

#

that will make it only work on the bot itself, and all other bots are still allowed

fallow mauve
valid niche
#

oh in that way, i would personally say that isn't a good system, but if it is what you wish, look up arrays and concatenation of arrays for your database, since each database has their own way

slate swan
#

@valid nicheHey I tried this:

    async def info(self, ctx, arg: typing.Optional[discord.User] = None):
        if arg:
            print(arg.id)
        if not arg:
            print(ctx.author.id)
        if arg == "server":
            print(ctx.guild.id)

But it wont work when I do "-info server"

fallow mauve
# valid niche `if message.author.bot` is the easiest. This returns true if the author is a bot...

i tried that and i got this error:

Ignoring exception in on_message
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 28, in on_message
    if not message.author.Bot:
AttributeError: 'User' object has no attribute 'Bot'
/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py:350: RuntimeWarning: coroutine 'Client.fetch_user' was never awaited
  pass
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
valid niche
valid niche
#

also it's author.bot with lowercase b

#

it is probably easier too

fallow mauve
valid niche
#

and it's more organised, since you'll be utilizing the relational part of databases/SQL more

slate swan
#

yes, I can send you the logs (although they are extremly long)

valid niche
slate swan
#

ok

fallow mauve
valid niche
#

if you can find those lines, it means that discord is just disconnecting you, or your internet connection to discord isn't stable

slate swan
#

time to do some [CTRL]+[F]

#

@valid nicheScrew this it wont work, how can I get information on something by ID?

valid niche
# slate swan time to do some [CTRL]+[F]

you will need to look for INFO level and you will either find
_log.info('Timed out receiving packet. Attempting a reconnect.')
or
_log.info('Websocket closed with %s, attempting a reconnect.', code)

slate swan
#

-info 234649992357347328

valid niche
#

the typehint will automatically parse IDs too

slate swan
#

and it will return your name, your pfp, when ur account was created etc

#

but it wont work for the server

valid niche
#

so discord.User typehint accepts IDs too

slate swan
#

Mine is at debug level

#

when i do -info server it wont work

valid niche
#

that way "server" will work

#

as long as there is no member named server that is

slate swan
#

this is so complicated compared to nodejs

#

then switch

valid niche
#

Did you set user_id as a primary key or UNIQUE constraint?

#

or guild_id

slate swan
#

there u just do 1 line of a if statement to check if the user has mentioned someone

#

can't you do that in python?

valid niche
#

regex

slate swan
#

regex?

valid niche
# slate swan regex?

regular expression, pattern matching in strings, works in almost every programming language out there

slate swan
#

so how would i use regex in this case?

valid niche
#

for a mention it would be match = re.search(r"<@!?\d+>", arg) assuming arg is a string

#

that should be the regex for a discord mention, but keep in mind that this does not check if this is a VALID mention

#

so if i type @slow dawn it's an invalid mention, the user doesn't exist, but this regex will match it

#

primary key means it automatically is UNIQUE, which means it can only exist ONCE in the database table

#

primary key is a thing in databases to indicate an always unique value, often an ID, which can be used to address this particular row and you know for certain there won't be conflict

#

yes, this means you can only have each user once and each guild once in your database

#

for instance this is my warnings table for my bot

#

as you can see, i have an auto-increasing warn id that is the primary key

#

a lot of databases can do without a primary key

#

it's recommended to always have one, so you can find the row later on

#

for instance when i do any communication with my database about a warning, i always talk using the primary key, the warnid

#

this means i never have to dig through data and always get what i want

#

which makes writing it in code also a lot easier, if i want to review a case later on i can just call a command with the ID, and the bot looks it up in the database right away, and i always get the warn i want

#

postgres datatypes

#

it's how large the value can be

cursive barn
# slate swan so how would i use regex in this case?

why not just use something like ```py
async def info(self, ctx, *, arg: str):
try:
user = await commands.MemberConverter().convert(ctx, arg)
except commands.BadArgument:
if arg.lower() == 'server':
# do server info stuff
return
else:
#output error message
return

do user info stuff

return

#

you could manually attempt to invoke the converter

valid niche
#

postgres has 3 integer types. Smallint, a signed 2 byte integer, integer, a signed 4 byte integer, and bigint, a signed 8 byte integer

cursive barn
#

and if you wanted to condense it you could do so even further @slate swan

#
async def info(self, ctx, *, arg: str):
  if arg.lower() == 'server':
    query = ctx.guild
  else:
    try:
      query = await commands.MemberConverter().convert(ctx, arg)
    except commands.BadArgument:
      query = False
  # do something with query object, or if false, output error message
#

@slate swan both of which are acceptable ways to handle your issue ^

valid niche
#

you passed all situations already so you know the argument isn't correct

cursive barn
placid escarp
#
    author1 = ctx.author
    guild = client.get_guild(888136367937294356)

    role = guild.get_role(888716964141367326)
    await author1.add_roles(role)
    sleep(.5)
    role1 = guild.get_role(899739409707044875)
    await ctx.author.remove_roles(role1)
#

how can i get guild id in messages?

slim whale
#
@commands.command()
async def serverinfo(self, ctx):
  embed = discord.Embed(title="Guild Information")
  embed.add_field(name="Guild Owner", value=f"{ctx.Guild.owner}")
  await ctx.send(embed)```
#

Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "serverinfo" is not found

slim whale
#

oh yes

#

im so dumb jijijija

placid escarp
placid escarp
slim whale
#

Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Context' object has no attribute 'Guild'

#
@bot.command()
async def serverinfo(ctx):
  embed = discord.Embed(title="Guild Information")
  embed.add_field(name="Guild Owner", value=f"{ctx.Guild.owner}")
  await ctx.send(embed)```
lament mesa
#

lowercase "g"

placid escarp
#

try that

slim whale
#

okk

#

@placid escarp it works but the bot sends this <discord.embeds.Embed object at 0x7f2f51465040>

placid escarp
placid escarp
slim whale
#

or where

placid escarp
# slim whale in embed add file?
@bot.command()
async def serverinfo(ctx):
  guild = ctx.guild
  embed = discord.Embed(title="Guild Information", description=f"{guild.owner}")
  await ctx.send(embed=embed)

(watch how to get started)

marble pilot
#
 @commands.command()
    @commands.has_role("Admin")
    async def add(self, ctx, member:None, role:discord.role):
        if role not in discord.guild.roles:
            pass
        else:
            if member is None:
                task_embed = discord.Embed(title=":white_check_mark: Success!", description=f"Successfully added {role.name} to {ctx.author}", timestamp=ctx.message.created_at)
                await ctx.author.add_roles(role)
                await ctx.send(embed=task_embed)
                document = {"name": f"{ctx.author}", "role":f"{role.name}"}
                data = collection.insert_one(document)
                print(collection.find_one(data.inserted_id))
            else:
                task_embed = discord.Embed(title=":white_check_mark: Success!", description=f"Successfully added {role.name} to {member}", timestamp=ctx.message.created_at)
                await member.add_roles(role)
                await ctx.send(embed=task_embed)
                document = {"name": f"{ctx.author}", "role": f"{role.name}"}
                data = collection.insert_one(document)
                print(collection.find_one(data.inserted_id))

Any help?
raise BadArgument('Converting to "{}" failed for parameter "{}".'.format(name, param.name)) from exc
discord.ext.commands.errors.BadArgument: Converting to "NoneType" failed for parameter "member".
plz anyone?

barren isle
#

so I'm trying to make a bump bot and for some reason this bit is broken:

@bot.command()
@commands.has_permissions(manage_guild=True)
async def setinvite(ctx,*,desc):
  file = open("data/invites.txt","r")
  current = ast.literal_eval(file.read())
  file.close()
  try:
    await ctx.send(f"Getting information for {desc} .")
    invite = await bot.get_invite(desc)
  except:
    await ctx.send("The invite is invalid.")
  try:
    if invite.guild == ctx.guild:
      current[str(ctx.guild.id)] = desc
      await ctx.send("Invite Set!")
      file = open("data/invites.txt","w")
      file.write(str(current))
      file.close()
    else:
      await ctx.send("The listed invite is not for your server.")
  except:
    await ctx.send("The invite is invalid.")```
any help would be good
barren isle
#

It just returns all the invite is valid massages

proud glade
#

well then remove the try excepts to see the actual error, then fix it

toxic wharf
#

Why this doesnt work?

primal fox
#

uuid?

pliant gulch
#

Just use the message ID as the warn id

#

That's what I did

kindred epoch
#

or message link, warn_message_link

muted pier
#

I’m a skid

#

Pls don’t hack me or ddos attack me

kindred epoch
#

print data with indexed and just data

#

ur fetching one

#

wait

#

how do you store the warnings

#

do you make a new column? or just update the original

slate swan
#

Maybe don't use .fetchone()

#

Read their documentation

kindred epoch
#

ye

slate swan
#

About how to fetch multiple rows

kindred epoch
#

thats why, but why do you make a new column

slate swan
#

Searching on your own is also something you might want to consider sometimes

kindred epoch
#

just update the original column

#

so it saves space to

slate swan
#

Just make fixed columns and add rows, you shouldn't edit columns

#

Don't create new columns

#

Create new rows with your existing columns

slate swan
#

Google is your friend

kindred epoch
#
("INSERT INTO something(numbers) (?),1")
slim whale
#

icon_url=f"{guild.icon} is this correct?

slate swan
#

_url

slim whale
#

okkk

hasty iron
#

and no need for fstring

reef shell
#

.url

slate swan
#

Whatever

slim whale
#

tnx

#

a no

hasty iron
#

!d discord.Guild.icon

unkempt canyonBOT
#

property icon: Optional[discord.asset.Asset]```
Returns the guild’s icon asset, if available.
hasty iron
#

it changed in 2.0

slate swan
#

Yeay that's 2.0

slim whale
slate swan
#

I don't get it why this bot uses 2.0 documentation when it's in beta and not officially recommended to be used 🤡

slim whale
#

but in the version i have how it would be?

slate swan
#

icon_url

pliant gulch
slim whale
#

embed.set_author(name="Guild info!", icon_url=f"{guild.icon}")

reef shell
hasty iron
#

it’s stable enough to be used

pliant gulch
slim whale
slate swan
#

guild.icon_url

slim whale
#

oh

#

true, i try it and i tell u

reef shell
#

that will work for you if you are using dpy from pypi

slim whale
#

it works but it doesnt send any photo

reef shell
#

Cuz u are using string

slim whale
slim whale
reef shell
slim whale
#
@bot.command()
async def serverinfo(ctx):
  guild = ctx.guild
  embed = discord.Embed(title="Guild Information", colour=0x87CEEB)
  embed.set_author(name="Guild info!", icon_url = guild.icon_url)
  embed.add_field(name="Server Owner", value=f"{guild.owner}", inline=True)
  embed.add_field(name="Server ID", value=f"{guild.id}", inline=True)
  await ctx.send(embed=embed)
```this is the whole code
reef shell
#

Show code

pliant gulch
#

Because icon_url isn't a string lol

#

It's an asset object

#

You need to cast str

hasty iron
#

it gets casted to a str

slate swan
#

No

#

Like that it's good

pliant gulch
slim whale
hasty iron
#

and dpy casts everything to a str for convenience

pliant gulch
pliant gulch
#

You need to manually cast or use the f string

reef shell
pliant gulch
reef shell
#

i mean worked

pliant gulch
slate swan
reef shell
#

When i used dpy 1.7

slim whale
#
@bot.command()
async def serverinfo(ctx):
  guild = ctx.guild
  embed = discord.Embed(title="Guild Information", colour=0x87CEEB)
  embed.set_author(name="Guild info!", icon_url = guild.icon_url)
  embed.add_field(name="Server Owner", value=f"{guild.owner}", inline=True)
  embed.add_field(name="Server ID", value=f"{guild.id}", inline=True)
  await ctx.send(embed=embed)
slate swan
#

hele i wanted to ask something about a error

slim whale
#

so how it would be?

hasty iron
slate swan
#

I used it on a bot I've made today without casting it to a string and works perfectly fine

#

how do i fix module 'collections' has no attribute 'MutableMapping'

pliant gulch
hasty iron
#

        self._author = {
            'name': str(name),
        }

        if url is not EmptyEmbed:
            self._author['url'] = str(url)

        if icon_url is not EmptyEmbed:
            self._author['icon_url'] = str(icon_url)

        return self
pliant gulch
#

Ok ok I see that now

#

Dk why dpy docs says icon_url is passed a str

hasty iron
unkempt canyonBOT
#

class collections.abc.Mapping``````py

class collections.abc.MutableMapping```
ABCs for read-only and mutable [mappings](https://docs.python.org/3/glossary.html#term-mapping).
hasty iron
#

is that what you want?

pliant gulch
#

It might be diff for master

slim whale
# hasty iron ```py self._author = { 'name': str(name), } ...
@bot.command()
async def serverinfo(ctx):
  guild = ctx.guild
  embed = discord.Embed(title="Guild Information", colour=0x87CEEB)
  embed.set_author(name="Guild info!", icon_url = guild.icon_url)
  embed.add_field(name="Server Owner", value=f"{guild.owner}", inline=True)
  embed.add_field(name="Server ID", value=f"{guild.id}", inline=True)
  await ctx.send(embed=embed)```
hasty iron
#

it should be the same

slim whale
hasty iron
#

yep its the same in v1.5.x branch

slim whale
hasty iron
#

not talking to you

slim whale
#

ohç

pliant gulch
reef shell
#

I guess not

slim whale
#

same

hasty iron
#

could it be your discord client is not rendering it?

pliant gulch
#

Can you print out guild.icon_url

slim whale
#

maybe, i try it in another server

#

now it does

pliant gulch
#

Does the guild you are running it in even have an icon?

reef shell
#

kek

slim whale
#

sorry guys hjklSHJLdajkahjkajhkahjkhjkas

#

tnx for helping me <3

reef shell
#

in 2.0 it raises an error if a guild doesn’t have icon

hasty iron
#

it doesn’t, it just returns None in Guild.icon

reef shell
#

i guess it does, cuz i had to remove that when rewriting my bot to 2.0, let me check tho

slate swan
#

how to create a command that when you do this command the bot could dm the members with this certain role (I attempted to make it but it doens't work)

reef shell
#

and your attempt is.....

slate swan
reef shell
#

On mobilethrinking

slate swan
reef shell
#

Don't mind me

reef shell
#

!d discord.Role.members

unkempt canyonBOT
slate swan
#

!d discord.Role.members

unkempt canyonBOT
slate swan
steady flume
#

guys, i made music system, but bot showed this mistake

Exception ignored in: <function AudioSource.__del__ at 0x0000022E6EEFCA60>
Traceback (most recent call last):
  File "C:\Users\Pakhoms\PycharmProjects\project\venv\lib\site-packages\discord\player.py", line 115, in __del__
    self.cleanup()
  File "C:\Users\Pakhoms\PycharmProjects\project\venv\lib\site-packages\discord\player.py", line 211, in cleanup
    self._kill_process()
  File "C:\Users\Pakhoms\PycharmProjects\project\venv\lib\site-packages\discord\player.py", line 176, in _kill_process
    proc = self._process
AttributeError: 'FFmpegPCMAudio' object has no attribute '_process'
reef shell
slate swan
#

all of this coding thingy makes me confused lemon_angrysad

reef shell
unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

slate swan
#

Good place to start to learn Python

reef shell
#

Btw, can anyone explain me a weird behaviour of my bot?

slate swan
#

Maybe

reef shell
#

So my bot was kicked from this guild on Oct 20, but after that i got 3 more guild leaving log with the same id

#

The last log is just a few min ago

#

was the server deleted or something

#

Assuming It was deleted, why would it still trigger the on_guild_leave eventpithink

oblique adder
slate swan
#

anyone know how to make an afk command?

reef shell
#

I asked why would it still trigger after getting kicked before/ the server got deleted

reef shell
reef shell
slate swan
#

than you

hollow agate
#
async def mute(ctx, user : discord.Member, duration = 0,*,unit = None):``` How can I make this work like .mute @hollow agate 10s?
toxic wharf
#

What should I place instead of return?
After if, i cant do anything with "Interaction failed."

toxic wharf
fallow mauve
#

im getting really pissed at my bot. i have this code:

@Bot.event
async def on_message(message):
    my_user_id = 853991571702939668
    user = await Bot.fetch_user(my_user_id)
    if type(message.channel) == discord.channel.DMChannel:
      if not message.author.bot:
        await message.channel.send("Hi :)")
        await user.send(f"{message.author.name}#{message.author.discriminator} messaged your bot: `{message.content}`")
    return

@Bot.command()
async def setup(ctx):
  embed=discord.Embed(color=0x44f3ff)
  embed.set_author(name='Rules:', icon_url="https://media.discordapp.net/attachments/900734911718252588/900791372238450689/GDSecretCoin.png")
  embed.add_field(name="**Rule #1**", value="No NSFW, spam, text walls, trolling, etc.", inline=False)
  embed.add_field(name="**Rule #2**", value="Respect all of our members and listen to our staff.", inline=False)
  embed.add_field(name="**Rule #3**", value="Use each channel according to it's intended purpose.", inline=False)
  embed.add_field(name="** **", value="** **", inline=False)
  embed.set_footer(text="Questions? DM me for more info.")
  await ctx.send(embed=embed)

and the modmail thing works just fine but as long as its in the code the setup command doesnt work. if i take it out, it works fine, how do i fix this?

placid skiff
#

Guys i need to check if a string contains comma and spaces after every words, how i can do it?

Example of correct input:
ab, cd, ef g, hi jk

fallow mauve
#

is this for me?

neon spear
#

Trying to remove the strings in the list from display names. When I'm running the code the bot removes it and add it back constantly (bug?)

@bot.event
async def on_member_update(before, after):

    roleArray = ["(om)", "(s)", "(h)"]

    for role in roleArray:
        nick = after.display_name.replace(role, "")
        await after.edit(nick=nick)
placid skiff
fallow mauve
#

ok

placid skiff
#

Database query returns a list of tuple, you have to iterate through them

hasty iron
#

iterate through the list using a for loop

peak salmon
#

anyone know how to add buttons in cog?

hollow agate
#
@client.command()
async def mute(ctx, member: discord.Member,time):
    muted = discord.utils.get(ctx.guild.roles, name="Muted")
    if member is None:
        a = await ctx.reply("You can't mute air!")
        await a.delete()
        await ctx.message.delete()
    if time is None:
        await ctx.reply('Muted')
    else:
        try:
            time_list = re.split('(\d+)',time)
            if time_list[2] == "s":
                time_in_s = int(time_list[1])
            if time_list[2] == "m":
                time_in_s = int(time_list[1]) * 60
            if time_list[2] == "h":
                time_in_s = int(time_list[1]) * 60 * 60
            if time_list[2] == "d":
                time_in_s = int(time_list[1]) * 60 * 60 * 60
            timestamp = DT.datetime.now().timestamp()
            await ctx.reply(f'Timestamp Now: {timestamp} \n \nMuted for {time_in_s} seconds!')
        except:
            time_in_s = 0
            await ctx.reply(f'{time_in_s} seconds!')``` Is my current code... how can I change the `time_in_s` to a timestamp so I can add it together and store when the member gets unmuted?
slate swan
#

How can i set my bot's about page?

hollow agate
slate swan
#

I noticed some bots can do this recently, i never knew it was possible

slate swan
#

I see now, thank you. This never used to be here before so that's cool to know.

#

I thought u meant like the documentation lmao

hollow agate
#

xD

#

So, I have seconds. How could I add those seconds to a time so that I can store when a mute expires in a database?

slate swan
#

#bot-commands ||ignore||

unkempt canyonBOT
#

Source code: Lib/datetime.py

The datetime module supplies classes for manipulating dates and times.

While date and time arithmetic is supported, the focus of the implementation is on efficient attribute extraction for output formatting and manipulation.

gleaming torrent
#

hmmm

#

!d discord

slate swan
#
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.giveaway' raised an error: NameError: name 'self' is not defined```
#

how do I define self?

cursive barn
# slate swan how do I define self?

That error is because somewhere in one of your methods (maybe static or classmethod) or possibly outside of your class, you referenced self where it would not be defined

#

it could also mean one of your functions is missing the self argument parameter

#

without seeing your code it is incredibly difficult to assist you

slate swan
#

ok, and is there a specific way to define self if that is the problem?

cursive barn
#

i have no idea because i do not know where the error occurs

#

if you show me your code i can further assist you

#

specifically i would need to reference the giveaway extension 🙂

slate swan
#

@client.command()
@commands.guild_only()
async def serverinfo(ctx):
    embed = discord.Embed(
        color = ctx.guild.owner.top_role.color
    )
    text_channels = len(ctx.guild.text_channels)
    voice_channels = len(ctx.guild.voice_channels)
    categories = len(ctx.guild.categories)
    channels = text_channels + voice_channels
    embed.set_thumbnail(url = str(ctx.guild.icon_url))
    embed.add_field(name = f"**{ctx.guild.name}**: ", value = f"![scribbleheart](https://cdn.discordapp.com/emojis/898400112173281291.webp?size=128 "scribbleheart") ID: **{ctx.guild.id}** \n![scribbleheart](https://cdn.discordapp.com/emojis/898400112173281291.webp?size=128 "scribbleheart")  Owner: **{ctx.guild.owner}** \n![scribbleheart](https://cdn.discordapp.com/emojis/898400112173281291.webp?size=128 "scribbleheart")  Location: **{ctx.guild.region}** \n![scribbleheart](https://cdn.discordapp.com/emojis/898400112173281291.webp?size=128 "scribbleheart")  Creation: **{ctx.guild.created_at.strftime(format)}** \n![scribbleheart](https://cdn.discordapp.com/emojis/898400112173281291.webp?size=128 "scribbleheart")  Members: **{ctx.guild.member_count}** \n![scribbleheart](https://cdn.discordapp.com/emojis/898400112173281291.webp?size=128 "scribbleheart")  Channels: **{channels}** Channels; **{text_channels}** Text, **{voice_channels}** Voice, **{categories}** Categories \n![scribbleheart](https://cdn.discordapp.com/emojis/898400112173281291.webp?size=128 "scribbleheart") Verification: **{str(ctx.guild.verification_level).upper()}**

    await ctx.send(embed=embed)```

getting this error
lavish grove
#

do you guys integration test your bots?

#

if so, how?

slate swan
#

How can I verify if peepol only spoke to the bot ONLY in dms?

kindred epoch
#

If its DMchannel then it's in dms

slate swan
#

What

#

Is there a link for the documentation of this dm channel?

#

Or a vid perhaps

#

Or just tell me how it works

#

anyone have any suggestions for a fork that supports slash commands, rn i'm using disnake and the docs aren't clear enough for me

quiet coral
#

Hello, I have this but it's giving me an error

import disnake
from gtts import gTTS
import playsound
import os

client=disnake.Client(intents=disnake.Intents.all())
voice_client=disnake.VoiceClient(client=client,channel=client.get_channel(889583102194765827))

@client.event 
async def on_ready():
    print('Hey, I am ready')
@client.event
async def on_voice_state_update(member, before, after):
    
    if not before.channel:
        channel_joining_string=f"{member.name} joined {after.channel.name}"
        tts=gTTS(text=channel_joining_string, lang='en')
        filename='voice.mp3'
        tts.save(filename)
        await voice_client.play(filename)
        ```
here is the error:```    raise ClientException('Not connected to voice.')
disnake.errors.ClientException: Not connected to voice.```
slate swan
#

Cause I haven't found anythin yet

kindred epoch
#

If it is discord.channel.DMchannel, then they spoke in dms

rugged marsh
kindred epoch
kindred epoch
primal fox
kindred epoch
#

Lol

#

It's the same as disnake

slate swan
#

Yeah literally is

#

It’s just they are so vauge and use different prefixes

kindred epoch
#

Sir

#

Wtf

slate swan
#

I’m pretty sure all the forks are the same anyways

#

kinda true

#

just a few different changes

kindred epoch
#

Ye

slate swan
#

Disable is very easy to migrate

#

I use nextcord because py-cord's dev version was so hard to migrate to

#

Disnake*

slate swan
#

i've got no clue what i'm doing, trying to add a role to a user by ids. Documentation is helping very little as I am extremely blind.

slate swan
slate swan
#
async def verify(ctx, uid: discord.Member, key):
#

do that first

#

aah. thanks. lemme test that...

#

then change await client.add_roles to await uid.add_roles(id)

#

i mighta done something extremely stupid... it did the same as before...

#

current code

#

no errors, no roles were added.

median hazel
#

I am doing an 8ball command and I have the random responses and everything but I am trying to make it so that if somebody asks a specific question, it only replies with one answer. How can I do that?

kindred epoch
slate swan
#

yep. as i thought. something extremely dumb of me.

#

thanks!

#

did nothing. do i have the wrong id? (string was the role id...)

kindred epoch
#

And you should not use json to store things

kindred epoch
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

primal fox
#

usually it's something like

role = ctx.guild.get_role(810264985258164255)
await user.add_roles(role)
kindred epoch
#

Ye

slate swan
kindred epoch
#

Idk what he's doing

slate swan
#

idk what im doing either tbh.

primal fox
#

I mean, I just pasted something you could try

slate swan
#

might see what it does ig.

primal fox
#

anywhere I've ever added roles I use the actual role object

kindred epoch
#

Why do you have a random bot.command

slate swan
#

idk. lemme check.

#

how can i make it so a command removes a role of the person who used it?

kindred epoch
#

?

slate swan
#

oh that one.

#

thats a part of other code that i know works.

kindred epoch
#

Wtf

primal fox
#

!d discord.Member.remove_roles

unkempt canyonBOT
#

await remove_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Removes [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s from this member.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the removed [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
kindred epoch
#

There

#

Use that @slate swan

slate swan
#

i cant get it to work

primal fox
#

how do you expect anyone to help you?

#

show what you've tried

slate swan
#
@commands.has_role('eligible')
async def name(ctx):
    await remove_roles('eligible', reason = None, atomic = True)```
#

this code?

#

whats wrong?

primal fox
#

ctx.author.remove_roles for one thing

visual island
#

you need to call it through a member instance

#

and provide a Role to remove, not a string

slate swan
#

how do i provide a role?

primal fox
#

ah yeah author, my bad

visual island
#

!d discord.Guild.get_role

unkempt canyonBOT
slate swan
#
@commands.has_role('eligible')
async def name(ctx):
    await ctx.author.remove_roles(get_role(900771730233098240, /), reason = None, atomic = True)```
#

?

primal fox
#

ctx.guild.get_role

slate swan
#

invalid syntax

#
@commands.has_role('eligible')
async def name(ctx):
    await ctx.author.remove_roles(ctx.guild.get_role(900771730233098240, /), reason = None, atomic = True)```
primal fox
#

for cleanliness I would just do role = ctx.guild.get_role(...) on the line above

#

you have parentheses messed up

slate swan
#
@commands.has_role('eligible')
async def name(ctx):
  role = ctx.guild.get_role(900771730233098240)
    await ctx.author.remove_roles((role, /), reason = None, atomic = True)
#

like this?

#

i still have invalid syntax cuz of the slash

visual island
#

remove it

primal fox
#

await ctx.author.remove_roles(role)

#

the other stuff is already default

slate swan
#

it worked

#

thank you very much

#

!d discord.on_member_ban

unkempt canyonBOT
#

discord.on_member_ban(guild, user)```
Called when user gets banned from a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").

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

OHHHH

#

how can i do something like this?

#

How do you remove a reaction by a user

#

!d discord.Button

unkempt canyonBOT
#

class discord.Button```
Represents a button from the Discord Bot UI Kit.

This inherits from [`Component`](https://discordpy.readthedocs.io/en/master/api.html#discord.Component "discord.Component").

Note

The user constructible and usable type to create a button is [`discord.ui.Button`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.Button "discord.ui.Button") not this one.

New in version 2.0.
slate swan
#

2.0..

#

wth did i mess up...

primal fox
slate swan
#

as in if the value of role is none?

primal fox
#

or your read() isn't == to the key youre providing

slate swan
#

pretty sure you do bot.get

#

hm.

primal fox
#

no, get_role is a guild function

slate swan
#

did not know that

primal fox
#

!d discord.Guild.get_role

unkempt canyonBOT
slate swan
#

it wont even return anything

#

like he said check if the role is None

primal fox
#

no print would mean its not ==

slate swan
#

How do you remove a user's reaction

#

hm. might need to throw the print elsewhere...

primal fox
#

I'm giving you advice and you're ignoring it lol

slate swan
#

i had the print in the if and it didnt do nothing.

primal fox
#

so what would that mean?

slate swan
#

if role is None:
lol

#

Would it be with open

#

I'd assume it would return something if it found the id...

primal fox
#

will it always print?

slate swan
#

it should print unless the value is null/empty or something.

primal fox
#

let me fix something that might help you

#

can you paste your current code

slate swan
#

somehow this must return nothing, yet the role exists.

primal fox
#

...paste

slate swan
#

How do I make sure peepol say someword but in dms?

#

should i use dpy 2.0?

slate swan
primal fox
# slate swan

I can't edit your code if you give me a screenshot

slate swan
#

^^

#

Like in the DMS if u say hi it says hi back to you but in the servers it can't say hello back to you

slate swan
#

i believe

#

Oh ok

slate swan
#

If you want

primal fox
#

@slate swan

async def verify(ctx, uid: discord.Member, key):
    KeyCheck = open('staffkey.txt', 'rt')
    file_contents = KeyCheck.read()

    if key == file_contents:
        print("Key matches file!")
        role = ctx.guild.get_role(900587905519599636)
        print(role)
        await uid.add_roles(role)
    else:
        print("Key does not match file")
        print("Key: ", key)
        print("File contents: ", file_contents)

    KeyCheck.close()```
slate swan
#

gonna try that rq...

#

Wait

#

Change the user.add_roles to uid

primal fox
#

what?

slate swan
#

User is never defined there

primal fox
#

oh you mean uid.add_roles

slate swan
#

Uid is

#

Yeah

primal fox
#

youre giving the role to the person who calls the command

#

right?

slate swan
#

It looks like it's whoever he pings

primal fox
#

ok, I edited above

slate swan
#

discord.Member I thought that was ping

primal fox
#
async def verify(ctx, uid: discord.Member, key):
    KeyCheck = open('staffkey.txt', 'rt')
    file_contents = KeyCheck.read()

    if key == file_contents:
        print("Key matches file!")
        role = ctx.guild.get_role(900587905519599636)
        print(role)
        await uid.add_roles(role)
    else:
        print("Key does not match file")
        print("Key: ", key)
        print("File contents: ", file_contents)

    KeyCheck.close()
#

good catch @slate swan

slate swan
#

Thanks

#

its not printing anything...

#

odd...

#

i need a way to use buttons

primal fox
slate swan
#

ive tried previously working code. the entire bot is broken.

primal fox
#

command_prefix='/n '?

thick hamlet
#

Hey guys! can someone set me in the right direction?

How would I go on about making "Instances" of a discord game

like when someone uses ;play and a text game pops up. Only who sent that ;play can control the instance of the ;play, and other people can still make more instances with ;play while someone is playing.

slate swan
slate swan
primal fox
slate swan
#

\n is newline

#

bots worked before...

#

Or sorry

#

Effprime correctness if I'm wrong but can your use a /prefix if it's not slash commands

primal fox
slate swan
#

changed it, it just refuses to work.

thick hamlet
primal fox
kindred epoch
#

Ok nvm then

thick hamlet
slate swan
#

changed prefix to bot name.

#

will try with no space

kindred epoch
#

@slate swan how are you using the command

slate swan
#

used to manually verify a user if the staff trust them.

kindred epoch
#

?

slate swan
#

within a server for a game community

kindred epoch
#

I said how, how do you type it in discord

slate swan
#

oooh.

#

necron!verify <user's id> <key>

kindred epoch
#

@primal fox

#

I think u notice the mistake?

primal fox
#

why do you need me to point it out? lol

supple thorn
#

Jesus

slate swan
kindred epoch
kindred epoch
slate swan
#

i changed it last time...

primal fox
#

right, he said will try with no space

slate swan
#

King does the command work or not

primal fox
#

seems he understands how prefixes work so I'm not sure

slate swan
#

it finally gave an error...

#

Ctrl c + ctrl v

#

long error

primal fox
#

you didnt check my edited code

#
async def verify(ctx, uid: discord.Member, key):
    KeyCheck = open('staffkey.txt', 'rt')
    file_contents = KeyCheck.read()

    if key == file_contents:
        print("Key matches file!")
        role = ctx.guild.get_role(900587905519599636)
        print(role)
        await uid.add_roles(role)
    else:
        print("Key does not match file")
        print("Key: ", key)
        print("File contents: ", file_contents)

    KeyCheck.close()```
slate swan
#

wait. was i blind?

primal fox
#

uid: discord.Member

slate swan
#

Yeah

#

Perfection!

#

it finally works...

primal fox
#

nice

slate swan
#

thanks man!

#

sorry for wastin y'alls time on stuff because im blind

primal fox
#

btw you don't have to provide the ID with how youre doing it

#

you can also tag the user or put Username#1234

kindred epoch
#

Wdym same id

slate swan
#

neat. I use ids mostly tho.

#

Ok now time for my question

primal fox
#

just wanted to point out the power of converters 😉

slate swan
#

How do you remove a user's reaction

kindred epoch
#

It's cuz u indexed it as 0

slate swan
#

hm. time to be completely brainded and have to look at documentation again.

kindred epoch
#

Ok

slate swan
#

See

primal fox
#

!d discord.Message.remove_reaction

unkempt canyonBOT
#

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

Remove a reaction by the member from the message.

The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji").

If the reaction is not your own (i.e. `member` parameter is not you) then the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission is needed.

The `member` parameter must represent a member and meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.
kindred epoch
#

There

slate swan
#

Ok thanks

#

oh.

#

faster than me.

#

Yeah I still don't understand hoe to use that

#

How

primal fox
slate swan
#

Ok thanks

supple thorn
#
re = data['mutetime'] - 1
if data["mutetime"] != 0:
          await collection.update_many({"same": "pog"},{'$set':{'mutetime': re}} 
#

Ok so this is in a tasks that loops for 1 second it subtracts 1 from a int

#

It works with the same person only

#

Only problem is when a different person gets in the database and has a different mute time

#

It pretty much puts the mute time of the first person

#

To the other dude and i dont really know how to individually subtract 1 from each of their mute time simultanously

kindred epoch
#

Wtf

#

That's not a good idea

#

Running a task loop every 1 second

slate swan
#

got this error. dunno what to do, gonna paste ss of some stuff in a few secs.

#

output is the log of a moderation action.

#

tried await log.send

kindred epoch
#

Show the line under log

kindred epoch
#

In fact send the whole code

slate swan
#

gave similar error... kinda odd.

median hazel
#

I don't want to code my Discord bot to do this but my bot is in a server that I am not Admin on. How do I remove it from that server?

supple thorn
slate swan
primal fox
#

I dont think theres another way besides asking an admin to kick it @median hazel

kindred epoch
supple thorn
slate swan
#

think you might be able to set a time with datetime

#

then wait until that time and set things to run.

#

idk how all that works tho

kindred epoch
primal fox
#

I would make a single loop that checks all muted users and sees if their expire time is up

kindred epoch
supple thorn
#

no

#

I dont want to use asyncio.sleep

kindred epoch
#

Why

supple thorn
#

Because the bot forgets to unmute the muted person if the bot restarts or crashes

#

That is my problem that im trying to solve

primal fox
#

store the muted user data in a DB or something

#

open it every time the bot starts

supple thorn
#

Thats the whole point of why im using a database and a task loop

primal fox
#

tasks and aysncio.sleep are the same thing

#

it's up to you how "low level" you wanna be

kindred epoch
#

Are u sure

#

tasks and sleep is not similar

primal fox
#

yes they are

kindred epoch
#

What

primal fox
#

tasks do something every set amount of time

kindred epoch
#

Ye and then repeat it

primal fox
#

putting sleep in a loop is the same thing

kindred epoch
#

:|

#

Putting it in a loop is the same thing

supple thorn
#

I just need to fix the problem of how to subtract 1 from all of the mute time

slate swan
#
@client.slash_command(name="gban", guild_ids=[794596546830008330])
async def gbanslash(ctx, user: disnake.User):
    if ctx.author.id in authors:
        for guild in client.guilds:
          if guild.id in guilds:
              try:
                await guild.ban(user)
                await ctx.response.send_message(content='Sucessfully banned **' + str(user) + '** from the server called **' + guild.name + '**')
              except (disnake.Forbidden, disnake.HTTPException):
                await ctx.response.send_message(content='There was an error banning **' + str(user) + '** from the server called **' + guild.name + '**')
        await ctx.response.send_message(content='Successfully banned **' + str(user) + '** from all SL2 servers!',mention_author=True)
    else:
        await ctx.response.send_message(content='Only SL2 High Command can run this command, please contact **SaintBrighten#3919** for more information!', delete_after=5)
        await ctx.message.delete(delay=5)

Hey, does anyone have any suggestions on how I could make it so the bot let's the user know which servers the ban actually worked and which it didn't? Maybe the edit_message with disnake, but I don't know how to implement this.

patent lark
primal fox
slate swan
kindred epoch
#

Wait a minute

#

You can just subtract all the rows at once

#

No difference

supple thorn
#

Technically the command is a temp mute command just made to be a different command

primal fox
#

again you could just use timestamps

#

but I guess you wanna make it complicated ;P

supple thorn
#

The mute time is in seconds

#

1-120 seconds

#

Randomly picks between those numbers

supple thorn
#

Ill try it

#

Ill go back here when it doesnt work and i got no more ideas

primal fox
#
5_minutes_in_the_future = datetime.datetime.now() + datetime.timedelta(minutes=5)
#
if datetime.datetime.now() > 5_minutes_in_the_future:
   print("5 minutes has passed")
supple thorn
#

Im guessing i can just change minutes to seconds

primal fox
#

yes

supple thorn
#

Poggers then

#

Im gonna go eat pancakes

slate swan
#

line 14 , await ctx ?

patent lark
#

you cant just await ctx

slate swan
#

says line 16...

slate swan
patent lark
#

yeah that your issue

slate swan
#

Thanks!

#

sorry for being dumb.

patent lark
#

kinda literally says "in verify await ctx"

#

sometimes all it takes is reading your error.

slate swan
#

yeah, it was the error complainin line 16. its fixed now tho.

cerulean osprey
#

Question, I need to make the bot respond to a message if 2 keywords are present, but I only know how to do it for one. How would I go about doing something like that?

slate swan
#

2 specific ones?

cerulean osprey
#

Yeah

slate swan
#

need an order to em?

cerulean osprey
#

Preferably, but not required

slate swan
#

i think a simple and gate should work...

#

oh. okey then...

cerulean osprey
#

Alright ty

devout iris
#

How can i set a status command?

cerulean osprey
#

How would I make it not case-sensitive?

rain olive
cerulean osprey
#

So

if message.content.lower() == "".lower() and "".lower():```
?
rain olive
#

yes

cerulean osprey
#

Alr ty

devout iris
#

!e

for i in range(10):

if i%2==0:
    print(i)
slate swan
#

what's the significance of and "".lower() there?

cerulean osprey
#

2 keywords

slate swan
#

that's not how and statement works , you would have to mention the condition after and too

#
if 2 > 1 and 0: #wrong ```

```py
if 2>1 and 2>0 : #correct```
devout iris
#

!e

print(1)
print(2)
print(3)
print(4)

slate swan
#

#bot-commands

devout quest
#
if message.content.startswith("$bl"):
    bl = randint(1,10)
    if bl == 1:
    
      ryv = [
        "https://www.youtube.com/watch?v=3_wbWSlxG4A",
        "https://www.youtube.com/watch?v=oyCYrCG0_MA",
        "https://www.youtube.com/watch?v=ZU7Q2yvmwfc"
      ]
      await message.channel.send(random.choice(ryv))```
what do i wrong
devout iris
#

Alr sorry

devout quest
#

bl doesnt work

slate swan
devout quest
#

yeh

#

i import it

slate swan
#

also , dont use on_message events to construct commands , use commands.Bot

cerulean osprey
slate swan
devout quest
#

no

#

just not work

#

join my server

slate swan
rain olive
#

you could use this idea

devout quest
#

lmao

cerulean osprey
#

If 1, I dont want it to respond

devout quest
#

can someone help me

#

with the bot

#

lmao

#

$bl doesnt work

slate swan
#

!e ```py
var = [ 'a' , 'b']

if 'z' and 'b' in var :
print('.')```

unkempt canyonBOT
#

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

.
rain olive
#

oh

slate swan
#

even if 'z' s not in var ,it prints it if no condition is mentioned

slate swan
supple thorn
slate swan
#

(ignore my typos im on phone rn)

cerulean osprey
slate swan
#

what error?

#

remove the ()

cerulean osprey
#

TypeError: 'in <string>' requires string as left operand, not builtin_function_or_method

bitter depot
cerulean osprey
slate swan
cerulean osprey
brave vessel
#

Ah

cerulean osprey
#

Yes

#

It comes before the if statement lol

devout quest
cerulean osprey
#

Bruh KEKW

bitter depot
slate swan
devout quest
#
if message.content.startswith("$bl"):
    bl = randint(1,10)
    if bl == 1:
    
      ryv = [
        "https://www.youtube.com/watch?v=3_wbWSlxG4A",
        "https://www.youtube.com/watch?v=oyCYrCG0_MA",
        "https://www.youtube.com/watch?v=ZU7Q2yvmwfc"
      ]
``` what do i wrong
cerulean osprey
#

Bruh KEKW didnt you get an answer?

devout quest
#

uh

#

i dont understand

#

im new to bot tho

cerulean osprey
slate swan
#

are you aware what do you have in the code?

slate swan
cerulean osprey
#

Oh I have that defined as another variable lol, so if I want to use 2 keywords Id need to define one with 1 word and another with another?

primal fox
slate swan
#

!e py if 'p' in 'python': print('yeah')

unkempt canyonBOT
#

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

yeah
cerulean osprey
#

So

msg = message.content

if '' in msg and '' in msg:

?

slate swan
#

sure

#

ill assume you have something inside that ' ' s

cerulean osprey
#

But with ''.lower", and yeah the keywords inside the ' '

slate swan
#

its preferable if you do message.content.lower() too

cerulean osprey
#

Alr, so if I do msgl = message.content.lower() I could use msgl instead?

slate swan
#

your wish , variable naming doesnt really matter till it follows the pep rules

cerulean osprey
#

Gotcha, ty

#

It came back with the same error Sadge

slate swan
#

show the exact code you have

cerulean osprey
#
if 'where'.lower() in msgl and 'skin'.lower in msgl:
cerulean osprey
slate swan
#

also lower isnt required since it is already lowered

cerulean osprey
#

Yeah but I want the keywords to work without having to worry abt caps

#

So like where and skin work, but also Where and Skin

slate swan
#

m , you miss the brackets tho

cerulean osprey
#

Yeah ik lol, I do that a lot, I deleted some things I had in it since I no longer needed em so let me try it rq

#

Ah perfect! It works, thank you!

slate swan
#

Hello is it possible to see the most used cmd?

#

he's been typing for a long time

proven salmon
proven salmon
#

I stop then started again

slate swan
#

manage_server isn't a valid permission?

#

!d discord.Permissions

unkempt canyonBOT
#

class discord.Permissions(permissions=0, **kwargs)```
Wraps up the Discord permission value.

The properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools. This allows you to edit permissions.

Changed in version 1.3: You can now use keyword arguments to initialize [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions") similar to [`update()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.update "discord.Permissions.update").
slate swan
#

it's guild

gloomy quest
#

yes discord doesnt work

#

i tried yesterday but it broke

slate swan
#

i can some one help me i had to remake my code now i need help to
build the code is dm people

gloomy quest
#

what?

#

all of it?????

slate swan
#

ok

gloomy quest
#

yeh

#

Im too lazy to try nextcord but you can

#

but it also probably wont work

#

lol

slate swan
#

first let me make the error code

final iron
#

Do dpy buttons not work anymore?

gloomy quest
#

you have to install nextcord then uninstall poetry and discord and install potry and billions of things

#

yes but they didnt say anything

#

I think they should have a developer newsletter

#

WHAT

#

ok

#

they had to make it complicated

#

and even the avatar cmd doesnt work

#

member.avatar_url???

#

oh

#

sad

#

nope

#

from its description I would rather code everything in one file

#

and make it 209393 lines and flex it to everyone LOL

boreal ravine
#

Why didn't it work? Any errors?

boreal ravine
#

you'll know why it doesn't work

unkempt canyonBOT
#

property avatar```
Equivalent to [`User.avatar`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.avatar "discord.User.avatar")
boreal ravine
#

Which version are you using?

#

@slate swan hello?

gloomy quest
#

oooo thx

#

oh its ok

boreal ravine
#

if you feel like you wanna give up thats just you lacking python knowledge to make a bot ¯_(ツ)_/¯

#

we're gonna act like you didn't see my messages thats ok

fair rose
#

how do i make a discord bot create a webhook

boreal ravine
unkempt canyonBOT
#

await create_webhook(*, name, avatar=None, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Creates a webhook for this channel.

Requires [`manage_webhooks`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_webhooks "discord.Permissions.manage_webhooks") permissions.

Changed in version 1.1: Added the `reason` keyword-only parameter.
fair rose
#

i love u

gloomy quest
#

;-;

devout quest
#

How to edit message

#

I want to make a genshin gacha

#

How to edit message

stable delta
#

then await message.edit()

devout quest
#

How

#

How to get

stable delta
#

!d discord.abc.Messageable.fetch_message

unkempt canyonBOT
#

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

Retrieves a single [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") from the destination.
slate swan
#
async def on_member_join(member):
   await bot.get_channel(891878891889766414).send(f"welcome **{member.name}!**")```
how do i change it from just sending a message like

"welcome **john**"
to mentioning someones USERID?
devout quest
#

Uh

stable delta
unkempt canyonBOT
#

await edit(content=..., embed=..., embeds=..., attachments=..., suppress=..., delete_after=None, allowed_mentions=..., view=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the message.

The content must be able to be transformed into a string via `str(content)`.

Changed in version 1.3: The `suppress` keyword-only parameter was added.
slate swan
#

like this

@stable delta

#

to where i can click to view their profile etc.

stable delta
#

member.mention

slate swan
#

!d discord.Member.mention

#
async def avatar(ctx, member: discord.Member=None):
    icon_url = member.avatar_url 
 
    avatarEmbed = discord.Embed(title = f"{member.name}\'s Avatar", color = 0xFFA500, timestamp=ctx.message.created_at)
 
    avatarEmbed.set_image(url = f"{icon_url}")

    await ctx.send(embed = avatarEmbed)```

any idea on how to make it so i dont have to mention a user to use this command?

(sorry if im getting buggy im getting back into coding and trying to fix up my old bot)
#

recode it

#

trust me it's worth

devout quest
#
 async def on_message(https://images-ext-2.discordapp.net/external/r_HR-WHA2AzKT3y9NwUWCCiWCpKH440-5B_0_sxrcm4/https/i.imgur.com/w5vm9l8.mp4):
      if 'https://images-ext-2.discordapp.net/external/r_HR-WHA2AzKT3y9NwUWCCiWCpKH440-5B_0_sxrcm4/https/i.imgur.com/w5vm9l8.mp4' in message.content:
        await edit(https://images-ext-2.discordapp.net/external/r_HR-WHA2AzKT3y9NwUWCCiWCpKH440-5B_0_sxrcm4/https/i.imgur.com/w5vm9l8.mp4, "https://images-ext-2.discordapp.net/external/mpGFFgi1XQhjX_3U2Alopp4JS-4onQa55B7L__53xiQ/https/i.imgur.com/qJyjIIN.mp4")
``` pls help me
slate swan
#

edit , what?

#

message.edit

devout quest
#

help debug

slate swan
#

!d discord.Message.edit

unkempt canyonBOT
#

await edit(content=..., embed=..., embeds=..., attachments=..., suppress=..., delete_after=None, allowed_mentions=..., view=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the message.

The content must be able to be transformed into a string via `str(content)`.

Changed in version 1.3: The `suppress` keyword-only parameter was added.
devout quest
#

???

#

how

#

help me

slate swan
#

set the message you want to edit as a variable

devout quest
#

uh

maiden fable
devout quest
#

Ok

maiden fable
#

I suggest u learn more about Python and specifically functions please

devout quest
#

What to fix

maiden fable
#

!resources are a great way to get started

unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

devout quest
#

I have read all of that

slate swan
#

the color is so goo

maiden fable
slate swan
unkempt canyonBOT
#
Nope.

No documentation found for the requested symbol.

slate swan
#

!d discord.on_message

unkempt canyonBOT
#

discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") is created and sent.

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

Warning

Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
devout quest
#

Can u help me

slate swan
#

the color of the embed

maiden fable
devout quest
#

Idk

slate swan
devout quest
#

What

slate swan
#

click tap to see attachment

#

i just provided literally everything

#

OMG GUYS MY BOT GOt VERIFYED!!

#

niceeee

undone wyvern
#

Nice

slate swan
#

my anti-nuke is almost done i just need to finish some moderation cmds

#

weirdo alert

#

i worked 4 years and it finally become verifyed

#

4 years..

devout quest
#

What do i wrong

slate swan
#

the code isn't even in the correct function..

slate swan
slate swan
# devout quest

i'm also guessing you have little to no experience with python

#

use !recourses

#

!recourses

#

!resources

unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

steel trench
devout quest
#

I learn py by coding bots

slate swan
#

..

#

not a good idea

#

i sent him everything he needs for it

#

!d discord

unkempt canyonBOT
#

In order to work with the library and the Discord API in general, we must first create a Discord Bot account.

Creating a Bot account is a pretty straightforward process.

slate swan
#

click on "discord"

#

!d discord.on_message

unkempt canyonBOT
#

discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") is created and sent.

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

Warning

Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
slate swan
#

@devout quest does your code have that anywhere?

#

this python bot prolly took the longest time to make

devout quest
#

Ok

slate swan
#

ik

devout quest
#
if message.content.startswith("g!wish"):
    
    await message.channel.send("https://images-ext-2.discordapp.net/external/r_HR-WHA2AzKT3y9NwUWCCiWCpKH440-5B_0_sxrcm4/https/i.imgur.com/w5vm9l8.mp4")
    time.sleep(5)
    async def on_message(message):
      if 'https://images-ext-2.discordapp.net/external/r_HR-WHA2AzKT3y9NwUWCCiWCpKH440-5B_0_sxrcm4/https/i.imgur.com/w5vm9l8.mp4' in message.content:
        await message.edit(message,"https://imgur.com/qJyjIIN")
slate swan
#

that's it..

slate swan
#

!resources pls

unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

stable delta
slate swan
#

i beg

stable delta
#

before coding discord bots

slate swan
devout quest
#

Pls dont

slate swan
#

he's missing a lot

devout quest
#

I have learned all 2 times

slate swan
#

like a lot

devout quest
#

Lmao, pls help

slate swan
devout quest
#

Dont wanna learn again

slate swan
#

not functions

stable delta
#

dictionaries, loops, classes, objects, def, functions, indexing, etc?

#

I missed a few

#

but you get the point

devout quest
#

Uh but help me with the code

#

what do i wrong in that code

rugged marsh
#

Hu Tao lol

slate swan
devout quest
#

here

#

Ok

lusty swallow
slate swan
#

!resources

unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

devout quest
#

What next, read what

slate swan
#

tap on Resources page loo

lusty swallow
#

!d discord

unkempt canyonBOT
#

In order to work with the library and the Discord API in general, we must first create a Discord Bot account.

Creating a Bot account is a pretty straightforward process.

lusty swallow
#

here's the docs

slate swan
#

he doesn't understand basic python, he won't understand

devout quest
#

Wtf, how to invite your bot

lusty swallow
#

!d discord.ext.commands.Bot start here

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.

This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with this bot.

This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
rugged marsh
devout quest
#

It just says that

#

I come from liyue

rugged marsh
#

lol, curious

cunning lion
#

i think mars

devout quest
#

Im from liyue

rugged marsh
#

-.-

cunning lion
#

🧢

devout quest
#

but what to fix

rugged marsh
#

your spotify profile

devout quest
#

Here

#

Uh, ok

rugged marsh
devout quest
#

Fck no

rugged marsh
#

hmm

#

vn?

inner geyser
#

but my bot is like a open for everyone na, not for a particular servr

devout quest
#

No

#

Fck

rugged marsh
#

umm, us?

slate swan
#

Learn at least basicbpython

devout quest
#

Ok

lusty swallow
#

rather than tell people to learn python, tell him what he wants

inner geyser
#

sorry, actually after that I went to sleep, was night at that time here

lusty swallow
#

he wants to know what's wrong

devout quest
#

Im from liyue

rugged marsh
#

by learning python

devout quest
#

What

rugged marsh
#

Max Minh Duc

devout quest
#

Wtf

slate swan
#

i told him that he needs to put it inside a function from the docs specifically !d discord.on_message

lusty swallow
#

tell us what you intend to do with your code, and maybe i can help you improve it...

devout quest
rugged marsh
#

then

slate swan
#

!d discord.on_message

#

is what i meant

#

!d discord.on_message_delete

#

you can't edit someone else's message no

inner geyser
#

!d discord.ext.commands.check

unkempt canyonBOT
#

@discord.ext.commands.check(predicate)```
A decorator that adds a check to the [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") or its subclasses. These checks could be accessed via [`Command.checks`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command.checks "discord.ext.commands.Command.checks").

These checks should be predicates that take in a single parameter taking a [`Context`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context"). If the check returns a `False`-like value then during invocation a [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure") exception is raised and sent to the [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") event.

If an exception should be thrown in the predicate then it should be a subclass of [`CommandError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError"). Any exception not subclassed from it will be propagated while those subclassed will be sent to [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error").
rugged marsh
#

Your playlist tells everything lol

lusty swallow
#

maybe a teen 14-16

rugged marsh
#

and contain vietnamese words becuase i'm vietnamese :l

boreal ravine
#

people stalking people's spotify now?

#

😂

lusty swallow
rugged marsh
#

yes =))