#discord-bots

1 messages · Page 292 of 1

terse hawk
#

BRUH

#

2023-08-25 21:39:38 INFO discord.client logging in using static token
Traceback (most recent call last):
File "c:\Users\Phil\Desktop\discordbot.py", line 116, in <module>
client.run('TOKEN')
File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 860, in run
asyncio.run(runner())
File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 849, in runner
await self.start(token, reconnect=reconnect)
File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 777, in start
await self.login(token)
File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 621, in login
await self.setup_hook()
File "c:\Users\Phil\Desktop\discordbot.py", line 28, in setup_hook
await self.tree.sync(guild=MY_GUILD)
File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands\tree.py", line 1069, in sync
data = await self._http.bulk_upsert_guild_commands(self.client.application_id, guild.id, payload=payload)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#

File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\http.py", line 738, in request
raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
PS C:\Users\Phil>

slate swan
#

see now you got full traceback

terse hawk
#

@slate swan i need to go offline are you able to help me with this tomorrow at 9 am GMT +2?

slate swan
slow hollow
#

@slate swan what command should i do to get the bot to tell me how many messages did it delete.
and that this message automatically disappears after 10 seconds?

slate swan
#

Forbidden – The client does not have the applications.commands scope in the guild.

slate swan
#

to delete message after x seconds pass delete_after kwarg when sending

#

!d discord.TextChannel.send

unkempt canyonBOT
#
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the destination with the content given.

The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/latest/api.html#discord.File) object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list) of [`File`](https://discordpy.readthedocs.io/en/latest/api.html#discord.File) objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed) object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list) of [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed) objects. **Specifying both parameters will lead to an exception**.
slate swan
#

delete_after (float) – If provided, the number of seconds to wait in the background before deleting the message we just sent. If the deletion fails, then it is silently ignored.

gloomy fox
#

@slate swan What is the difference between Using Cleint and Using Bot

#

Oh wait

#

sry i see

gloomy fox
#

Yeah

slow hollow
#

like that ?

slate swan
#

if only this was correct syntax, yeah

slow hollow
#

what is the variable of the number of messages that I want to delete in my code?

slow hollow
slow hollow
severe sonnet
#

okay guys

#

how do i update a webhook?

slow hollow
severe sonnet
#

and i also need a ay to insert embed into the webhook

unkempt canyonBOT
#

class discord.TextChannel```
Represents a Discord guild text channel.

x == y Checks if two channels are equal.

x != y Checks if two channels are not equal.

hash(x) Returns the channel’s hash.

str(x) Returns the channel’s name.
severe sonnet
#
@commands.Cog.listener
    async def on_message(self, ctx, message):
        if message.author == self.client.user:
            return
        
        buffer = await ctx.bot.database.buffer()

        message_instance = self.message_instances(message, buffer)

        if message_instance is not None:
            for i in message_instance:
                if i[0] in buffer:
                    for j in buffer:
                        if i[0] in j:
                            webhook = await discord.TextChannel.webhooks()[0] if await discord.TextChannel.webhooks() else await discord.TextChannel.create_webhook(j["name"], avatar=j["image_url"])

                            author = f"<@{ctx.author.id}>" if not ctx.bot.database.anonimity_check() else "Anonymous"

                            embed = discord.Embed(
                                description=i[1]
                            )
                            embed.set_author(name=f"character of {author}")
#

i have the webhook creator and the webhook grabber

#

but how do i update a webhook?

thin raft
#

!d discord.TextChannel.delete_messages

severe sonnet
#

and set the embed into the webhook?

slow hollow
# unkempt canyon

no i don't want to add a variable i want to know what variable i need

slate swan
slow hollow
severe sonnet
#

lisener decorator... uhmm...

slow hollow
severe sonnet
thin raft
unkempt canyonBOT
#

await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=None, bulk=True, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.

You must have [`manage_messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_messages) to delete messages even if they are your own. Having [`read_message_history`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.read_message_history) is also needed to retrieve message history.

Changed in version 2.0: The `reason` keyword-only parameter was added.

Examples

Deleting bot’s messages...
slate swan
severe sonnet
#

like, listener decorator, maybe i need a doc for that

slow hollow
slate swan
unkempt canyonBOT
#

classmethod listener(name=...)```
A decorator that marks a function as a listener.

This is the cog equivalent of [`Bot.listen()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.listen).
slow hollow
thin raft
severe sonnet
#

thought i don't know where i had to call it

cold sonnet
slate swan
thin raft
#

I couldn't tell them to read it if I didn't send it in first place

thin raft
#

So I need to send it

slate swan
cold sonnet
#

unless you're built different

slow hollow
thin raft
cold sonnet
#

same

thin raft
#

Ik just the very basics

slow hollow
slate swan
#

start from something small then when you got to the point you know what OOP, decorators and functional programming is come back to it and you will see it will be a lot easier

cold sonnet
#

I have done java before doing dpy

#

which was lucky

thin raft
cold sonnet
#

nah cuz I knew oop

slate swan
thin raft
cold sonnet
#

he's saying java is harder

slow hollow
cold sonnet
#

java is the plane

thin raft
cold sonnet
#

oh

thin raft
#

I am the dyslexic

cold sonnet
#

damn

thin raft
slate swan
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.

slow hollow
crude sparrow
#

Is there any way to download te file that a user send to the bot? Ex: A pdf file

thin raft
#

Sobelos?

crude sparrow
#

Autocorrector

thin raft
#

!d discord.Attachment

unkempt canyonBOT
#

class discord.Attachment```
Represents an attachment from Discord.

str(x) Returns the URL of the attachment.

x == y Checks if the attachment is equal to another attachment.

x != y Checks if the attachment is not equal to another attachment.

hash(x) Returns the hash of the attachment.

Changed in version 1.7: Attachment can now be casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str) and is hashable.
slow hollow
thin raft
cold sonnet
cold sonnet
slow hollow
slow hollow
cold sonnet
#

you already have ctx.channel

#

which is a channel object

#

then you use its purge method

#

it's also a coroutine which means you gotta await

#

it's just
await ctx.channel.purge(limit=number)

#

!d discord.TextChannel.purge

unkempt canyonBOT
#

await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=None, bulk=True, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.

You must have [`manage_messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_messages) to delete messages even if they are your own. Having [`read_message_history`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.read_message_history) is also needed to retrieve message history.

Changed in version 2.0: The `reason` keyword-only parameter was added.

Examples

Deleting bot’s messages...
slow hollow
#
await purge(delete_after=10seconds)```
#

like that ?

cold sonnet
#

that's awful

slow hollow
cold sonnet
#

you have to use send on a channel object

#

like ctx.channel

#

await ctx.channel.send(...)

#

and you don't need content=

slow hollow
eager mural
#

hello i need help
is it possible to connect several bot in an index? to make a bot manager command

slow hollow
cold sonnet
#

at least add a + between the number of messages and the string

#

or learn about f-strings

slate swan
#

!fstring

unkempt canyonBOT
#
Format-strings

Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.

>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."

Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.

cold sonnet
#

thanks

slate swan
#

!indent

unkempt canyonBOT
#
Indentation

Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.

Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.

Example

def foo():
    bar = 'baz'  # indented one level
    if bar == 'baz':
        print('ham')  # indented two levels
    return bar  # indented one level

The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.

Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines

More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

cold sonnet
#

do read those emperle

unkempt canyonBOT
#

await start(token, *, reconnect=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

A shorthand coroutine for [`login()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.login) + [`connect()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.connect).
slow hollow
#

i dont understand

cold sonnet
slow hollow
cold sonnet
#

where 6 can be a variable

slate swan
slow hollow
cold sonnet
#

god

slate swan
#

..

slate swan
slow hollow
# slate swan

I want the bot to write the number of deleted messages + this sentence in green when I delete the other messages

cold sonnet
#

I don't

#

I don't know anymore

slate swan
#

thats why i just send resources link.

slate swan
#

you cant just use a varriable and follow it with a string you need to merge them to one string

cold sonnet
#

check this out

slate swan
#

either adding them using + or using fstrings

slate swan
cold sonnet
#

!e

print(6 "messages were deleted") 
unkempt canyonBOT
#

@cold sonnet :x: Your 3.11 eval job has completed with return code 1.

001 |   File "/home/main.py", line 1
002 |     print(6 "messages were deleted")
003 |           ^^^^^^^^^^^^^^^^^^^^^^^^^
004 | SyntaxError: invalid syntax. Perhaps you forgot a comma?
cold sonnet
#

!e

print(f"{6} messages were deleted") 
unkempt canyonBOT
#

@cold sonnet :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 1, in <module>
003 |     print(6 + "messages were deleted")
004 |           ~~^~~~~~~~~~~~~~~~~~~~~~~~~
005 | TypeError: unsupported operand type(s) for +: 'int' and 'str'
cold sonnet
#

fuck

slow hollow
slate swan
slow hollow
#

sorry

slate swan
#

look

cold sonnet
#

!e

print(f"{6} messages were deleted") 
unkempt canyonBOT
#

@cold sonnet :white_check_mark: Your 3.11 eval job has completed with return code 0.

6 messages were deleted
slate swan
#

!e ```py
super_cool_text = "hello"

print(super_cool_text "world") # throws error

unkempt canyonBOT
#

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

001 |   File "/home/main.py", line 3
002 |     print(super_cool_text "world") # throws error
003 |                           ^^^^^^^
004 | SyntaxError: invalid syntax
cold sonnet
#

but replace 6 with your variable

slate swan
#

!e ```py
super_cool_text = "hello"

print(super_cool_text + "world")

unkempt canyonBOT
#

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

helloworld
cold sonnet
#

omg helloyou

slate swan
#

simply adding a plus between, boom works

cold sonnet
#

not in his case bru

slate swan
#

if his varriable is a string it will

cold sonnet
#

it's not

slate swan
#

why not

cold sonnet
#

I hope

formal basin
cold sonnet
#

hold on

cold sonnet
#

it's int

slow hollow
slate swan
slate swan
slow hollow
slate swan
cold sonnet
#

I'm an official opp

slate swan
#

explain what super does then

cold sonnet
#

the parent class

slate swan
cold sonnet
#

they didn't teach that on hackerrank tho

cold sonnet
#

what a shame

#

I learned that in a youtube video

#

💪

#

though there was much more to it than that

#

gotta watch it again

slate swan
#

youtube tutorials be like 2Head

cold sonnet
#

it was great

#

I remember that dude was smart

slow hollow
#

can you just correct me (for 1 time only)

await ctx.channel.send(f"{number_of_message} viens d'être supprimer", delete_after=10seconds)

cold sonnet
#

remove seconds

slate swan
#

delete_after (float) – If provided, the number of seconds to wait in the background before deleting the message we just sent. If the deletion fails, then it is silently ignored.

#

as the docs says its of type float

slow hollow
slate swan
#

what library/api is the guy using? interested in browsing through it myself now to see what's up

cold sonnet
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
unkempt canyonBOT
glad cradle
#

hi down

slate swan
cold sonnet
#

kinda racist

glad cradle
#

i want to build something

cold sonnet
#

only greets the turtle

slate swan
#

no im not working on my issue sorry

slate swan
cold sonnet
#

build gta 6

cold sonnet
#

not a datatype

#

it's like the first thing you learn

slate swan
#

.rp datatypes

#

:/

slow hollow
#

so how do you say seconds in python

cold sonnet
#

fuck you sir lancebot

glad cradle
slate swan
slate swan
glad cradle
#

a discord bot or a library

cold sonnet
slate swan
slow hollow
glad cradle
slate swan
cold sonnet
slate swan
#

jk i aint touching hikari

cold sonnet
slate swan
glad cradle
unkempt canyonBOT
#

@glad cradle :white_check_mark: Your 3.11 eval job has completed with return code 0.

1.2 <class 'float'>
slow hollow
slate swan
slow hollow
slate swan
#

no need to promise me

#

what was the code you needed help with now again?

#

await ctx.channel.send(f"{number_of_message} viens d'être supprimer", delete_after=10seconds)this?

glad cradle
#

how to cook rice using python

cold sonnet
#

looks kinda goated it has brackets and dots now and an f

#

looks cool

slate swan
slate swan
slate swan
glad cradle
#

sorry disnake PRs hitted my head

cold sonnet
slate swan
slow hollow
#

ok ty

glad cradle
slate swan
unkempt canyonBOT
#
Indentation

Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.

Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.

Example

def foo():
    bar = 'baz'  # indented one level
    if bar == 'baz':
        print('ham')  # indented two levels
    return bar  # indented one level

The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.

Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines

More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

slow hollow
cold sonnet
#

please don't put it in the for loop

glad cradle
#

what if None is awaitable, we would live in a completely different universe

cold sonnet
#

and please use purge

slate swan
cold sonnet
#

where did that come from

slate swan
#

not python 2 for sure

slow hollow
#

lets go finish

slate swan
#

naming the message user is crazy

slow hollow
#

I have just learned that during an error it was necessary to analyze and try by yourself to solve the problem

slow hollow
slate swan
# slow hollow

ok i actually don't understand what's causing the indentation error here, interested myself.

slow hollow
slate swan
slow hollow
#

ty

cold sonnet
#

replace line 18 to 21 with just that

slate swan
#

Man that's such an annoying problem to get caught by.

cold sonnet
#

vsc

slate swan
#

well gl i dip

cold sonnet
#

he dips

#

chest and triceps

quick brook
#

I will not touch hiraki with a ten foot pole

zealous lance
#

how do i add 2 buttons to 1 embed?

eager ridge
slate swan
eager ridge
#

can someone help me guys

and i tried alraedy

" pip install discord-py-interactions "

eager ridge
slate swan
#

all knows libraries already have support for slash commands

eager ridge
#

what you mean sir ?

slate swan
#

what library are you using?

eager ridge
#

python

slate swan
#

and since when python is a package

eager ridge
#

like

#

i dont understand ur question

slate swan
#

what package, module, library are you using for discord bot

zealous lance
#

@slate swan after you are done with him do you know how i add 2 buttons to 1 embed?

slate swan
eager ridge
#

you mean this sir ?

slate swan
#

it can be discord.py can be nextcord and can be py-cord or many more

eager ridge
slate swan
slate swan
eager ridge
#

wich libary you would prefer me sir ?

slate swan
#

you cant really use two libraries at once

eager ridge
#

i can change my libariers

#

wich is the best for slash cmds ?

slate swan
#

depends on preferences which you cannot have since you didnt use any

eager ridge
#

alright but

#

how can i fix my error sir

slate swan
zealous lance
slate swan
zealous lance
slate swan
#

you can later change somethings in code and see what changes in discord

zealous lance
#

mk

slate swan
#

(thats literally how you learn)

zealous lance
eager ridge
#

...

final iron
eager ridge
#

how to fix it bro

#

since 3hr

#

i cant anymore i want to die

final iron
#

Don't use discord_slash then...

eager ridge
#

what should i use then?

final iron
eager ridge
#

i alraey use it ?

slate swan
buoyant quail
shrewd ledge
#

How to make a setting command
Like I have on_member_join event and it's sending welcome in a channel so how I can make a command to set this channel ID

#

I think it's by store the information like the id in a JSON file but I don't know how to get them and edit them

tall temple
#

i'm actually using pycord and i get the following error (appearing in the ss)

here is all the script imports :

from discord.ext import commands
import discord
from discord import default_permissions
from colorama import Fore, Back, Style, init
import json
import os
import pathlib```
#

i was asking for 2 days and didn't solved the problem 😢

final iron
tall temple
final iron
#

Doesn't change the question

tall temple
#

idk i only have py-cord rn

final iron
#

Okay?

#

That doesn't change the code

tall temple
#
C:\Users\Medra>py -m pip list
Package            Version
------------------ ---------
aiohttp            3.8.5
aiosignal          1.3.1
anyio              3.7.1
async-timeout      4.0.3
attrs              23.1.0
certifi            2023.7.22
charset-normalizer 3.2.0
colorama           0.4.6
exceptiongroup     1.1.3
fernet             1.0.1
ffmpeg-python      0.2.0
frozenlist         1.4.0
future             0.18.3
h11                0.14.0
httpcore           0.17.3
httpx              0.24.1
idna               3.4
imageio-ffmpeg     0.4.8
multidict          6.0.4
numpy              1.25.2
pip                23.2.1
protobuf           4.24.1
py-cord            2.4.1
pyaes              1.6.1
requests           2.31.0
setuptools         57.4.0
sniffio            1.3.0
typing_extensions  4.7.1
urllib3            2.0.4
yarl               1.9.2
final iron
#

Cool

#

This doesn't change the question

#

Is there also an error when you import discord

tall temple
#

nah

final iron
#

Have you reinstalled pycord

tall temple
#

it just worked thanks

lethal drift
#

What method can be used to check is a member has a certain permission?

unkempt canyonBOT
#
NEGATORY.

No documentation found for the requested symbol.

final iron
#

burh

final iron
unkempt canyonBOT
#

property guild_permissions```
Returns the member’s guild permissions.

This only takes into consideration the guild permissions and not most of the implied permissions or any of the channel permission overwrites. For 100% accurate permission calculation, please use [`abc.GuildChannel.permissions_for()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.GuildChannel.permissions_for).

This does take into consideration guild ownership, the administrator implication, and whether the member is timed out.

Changed in version 2.0: Member timeouts are taken into consideration.
final iron
#

I'd use permisions_for though

lethal drift
#

A list of tuples tbf but a list nonetheless lol

final iron
lethal drift
final iron
#

It returns

#

!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/latest/api.html#discord.Permissions) similar to [`update()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.update).
severe sonnet
#

a question

#

for webhooks do it need the channel id?

#

or just discord.Message.channel?

final iron
#

You could get a TextChannel object from an ID though

#

!d discord.TextChannel.create_webhook

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.

You must have [`manage_webhooks`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_webhooks) to do this.

Changed in version 1.1: Added the `reason` keyword-only parameter.
severe sonnet
#

i see

#

howo do i get it from channel id?

final iron
#

!d discord.utils.get

unkempt canyonBOT
#

discord.utils.get(iterable, /, **attrs)```
A helper that returns the first element in the iterable that meets all the traits passed in `attrs`. This is an alternative for [`find()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.utils.find).

When multiple attributes are specified, they are checked using logical AND, not logical OR. Meaning they have to meet every attribute passed in and not one of them.

To have a nested attribute search (i.e. search by `x.y`) then pass in `x__y` as the keyword argument.

If nothing is found that matches the attributes passed, then `None` is returned.

Changed in version 2.0: The `iterable` parameter is now positional-only.

Changed in version 2.0: The `iterable` parameter supports [asynchronous iterable](https://docs.python.org/3/glossary.html#term-asynchronous-iterable)s...
severe sonnet
#

i see

#

attrs is the channel id?

#

okay so, will this work?

channel = await discord.utils.get(ctx.channel.id)
#

i'm curious about what it will return

final iron
#

You need an interable

#

It gives you examples

severe sonnet
#

and if i do this?

channel = await discord.utils.get(ctx.channel)

At least according to what i read

quick brook
#

the module for discord_slash leads back to interactions.py. ChatGPT (which is shit for dpy anyways as it constantly get things incorrect) suggests using the discord_slash namespace (interactions.py never had this to begin with???) for some odd reason

#

.... there is something called app_commands in dpy

final iron
final iron
#

You need your interable, and an attr to search for

#

i.e

#
discord.utils.get(ctx.guild.members, id=669343267589980160)
#

This would return a discord.Member object of me

final iron
#

I feel like ChatGPT got nerfed recently or something

#

Today I was using it for baking, and it thought that there were 10 tablespoons in 1/2 a cup, and I couldn't convince it otherwise

quick brook
#

yep got nerfed iirc

fading linden
#

it was always nerfed

granite raft
#

!d discord.PCMVolumeTransformer

unkempt canyonBOT
#

class discord.PCMVolumeTransformer(original, volume=1.0)```
Transforms a previous [`AudioSource`](https://discordpy.readthedocs.io/en/latest/api.html#discord.AudioSource) to have volume controls.

This does not work on audio sources that have [`AudioSource.is_opus()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.AudioSource.is_opus) set to `True`.
eager ridge
#

can someone help me please

quick brook
#

dpy has slash commands natively intergrated

slate swan
glad cradle
#

down is angry

quick brook
eager ridge
slate swan
#

I linked you example how to use slash in discord py

#

Did you bother to check it?

#

Or you waiting for someone to give you code to copy paste and make it work

#

Cause if so we dont do that here bud

terse hawk
#

Hello down

#

Mind Helping me Again

#
Traceback (most recent call last):
  File "c:\Users\Phil\Desktop\discordbot.py", line 116, in <module>
    client.run('TOKEN')
  File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 860, in run
    asyncio.run(runner())
  File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 849, in runner
    await self.start(token, reconnect=reconnect)
  File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 777, in start
    await self.login(token)
  File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 621, in login
    await self.setup_hook()
  File "c:\Users\Phil\Desktop\discordbot.py", line 28, in setup_hook
    await self.tree.sync(guild=MY_GUILD)
  File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands\tree.py", line 1069, in sync
    data = await self._http.bulk_upsert_guild_commands(self.client.application_id, guild.id, payload=payload)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\http.py", line 738, in request
    raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
slate swan
terse hawk
#

Oh thanks

slate swan
#

Its because you did not set application.commands scope when inviting the bot

#

You need to reinvite the bot and use this scope now

#

Here you have how to do that

terse hawk
#

its still an error

#
Traceback (most recent call last):
  File "c:\Users\Phil\Desktop\discordbot.py", line 116, in <module>
    client.run('TOKEN')
  File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 860, in run
    asyncio.run(runner())
  File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 849, in runner
    await self.start(token, reconnect=reconnect)
  File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 777, in start
    await self.login(token)
  File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 621, in login
    await self.setup_hook()
  File "c:\Users\Phil\Desktop\discordbot.py", line 28, in setup_hook
    await self.tree.sync(guild=MY_GUILD)
  File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands\tree.py", line 1069, in sync
    data = await self._http.bulk_upsert_guild_commands(self.client.application_id, guild.id, payload=payload)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\http.py", line 738, in request
    raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
brazen raft
#

Is MY_GUILD an int?

slate swan
#

Its Object

brazen raft
#

It should be

#

But is it

slate swan
#

I saw his code before and it was

brazen raft
#

Then is the bot in that guild

#

Maybe it's impossible to sync application commands with guilds which the bot isn't in

slate swan
#

Pretty normal if it wouldnt be possibile

brazen raft
#

Yes and then the solution would be making sure the IDs match

brazen raft
#

To sync a command tree with a guild

terse hawk
#
Traceback (most recent call last):
  File "c:\Users\Phil\Desktop\discordbot.py", line 116, in <module>
    client.run('TOKEN')
  File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 860, in run
    asyncio.run(runner())
  File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 849, in runner
    await self.start(token, reconnect=reconnect)
  File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 777, in start
    await self.login(token)
  File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 621, in login
    await self.setup_hook()
  File "c:\Users\Phil\Desktop\discordbot.py", line 28, in setup_hook
    await self.tree.sync(guild=MY_GUILD)
  File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands\tree.py", line 1069, in sync
    data = await self._http.bulk_upsert_guild_commands(self.client.application_id, guild.id, payload=payload)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Phil\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\http.py", line 738, in request
    raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access

What do i do?

slate swan
#

No need to send the same error 3 times

#

Is the bot in the guild you try to sync it to?

terse hawk
#

oh...

#

wait

#

NO WAY IT WORKED LETS GOO

#

THANKS

ember mango
#

Hello?

#

What is this?

vocal snow
#

that looks like a slash command but an error handler for a normal prefix command?

#

or are you using a hybrid command

robust fulcrum
#

Is there way we can reload the cogs on file change something like file watcher in discord.py?

buoyant quail
#

!pypi cogwatch

unkempt canyonBOT
buoyant quail
#

this maybe

#

disnake has reload arg in run for this, but it seems discord.py doesn't have something similar

glad cradle
#

yeah so switch to disnake

slate swan
glad cradle
buoyant quail
#

xd

ember mango
#

I dont undersatnd you?

#

I use slash command

slate swan
#

give more context on the code

#

what cups is in this code?

shrewd apex
vocal snow
#

Html is not a language, but I know it.
HTML is a language. the L in HTML stands for Language

#

can you send your code?

shrewd apex
#

its a markup language

vocal snow
#

never said it was 🤷‍♂️

#

a what

shrewd apex
#

whats the diff bw markup and down

buoyant quail
vocal snow
#

i have no idea what that is sorry

shrewd apex
#

zeffo how come u never told us that u were a wc professor 😔

vocal snow
#

I am definitely nota professor of any kind though

shrewd apex
#

lmao

slate swan
#

how is that code?

slate swan
#

html is indeed a language

#

just not programming language

vocal snow
cold sonnet
#

the world championship???

#

warcraft???

turbid condor
#

World Cup

cold sonnet
#

chess world cup

#

magnus carlsen

buoyant quail
#

I can see only manual reloading there

turbid condor
#

Oh it only has commands

#

Not auto reloading

eager ridge
#

can someone help mee please

#

Traceback (most recent call last):
File "dm.py", line 3, in <module>
from discord_slash import SlashCommand
ModuleNotFoundError: No module named 'discord_slash'

cloud dawn
#

How old is the yt video?

eager ridge
#

but i already installed pip install discord-py-interactions

cloud dawn
#

Only filter on max 6 months, these libraries are old and unused.

buoyant quail
unkempt canyonBOT
buoyant quail
#

Where you see discord_slash here?

cloud dawn
#

discord_slash was an old lib removed from pypi.

hushed galleon
#

nah that was discord_components that got removed, discord_slash still lives in an older version of discord-py-slash-command before they released v4 and then migrated to discord-py-interactions/interactions.py

#

their older docs also mentions merging discord_components into their lib

main holly
#

yo bruh how do i make slash cmds using bot.tree.command

slate swan
main holly
#

they dont sync

slate swan
main holly
glad cradle
slate swan
main holly
#

but how do i make em sync

odd pumice
main holly
#

!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 Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

main holly
#

its not even large amounts

odd pumice
#

I like the formatting better.

unkempt canyonBOT
#

examples/app_commands/basic.py lines 25 to 28

async def setup_hook(self):
    # This copies the global commands over to your guild.
    self.tree.copy_global_to(guild=MY_GUILD)
    await self.tree.sync(guild=MY_GUILD)```
buoyant quail
buoyant quail
#

Just remove the guild arg and copy_global_to then

#
await self.tree.sync()
main holly
buoyant quail
#

just sync

main holly
#

and delete self.tree.copy_global_to()?

buoyant quail
#

yes

main holly
#

okay

main holly
# buoyant quail yes

is this correct

import discord
from discord import app_commands

async def setup_hook(self):
await self.tree.sync()

intents = discord.Intents.all()
client = commands.Client(command_prefix='.', intents=intents)

@client.event
async def on_ready():
print(f'Logged in as {client.user} (ID: {client.user.id})')
print('------')

@client.tree.command()
async def hello(interaction: discord.Interaction):
"""Says hello!"""
await interaction.response.send_message(f'Hi, {interaction.user.mention}')

buoyant quail
#

setup_hook is not a random function

#

you need to set it as bot attribute

#

by subclassing or doing

@client.event
async def setup_hook(self):
    await self.tree.sync()
main holly
#

how

#

oh

buoyant quail
#

and without self

#

if it's not inside the class

main holly
#

so this import discord
from discord import app_commands

@client.event
async def setup_hook(self):
await tree.sync()

intents = discord.Intents.all()
client = commands.Client(command_prefix='.', intents=intents)

@client.event
async def on_ready():
print(f'Logged in as {client.user} (ID: {client.user.id})')
print('------')

@client.tree.command()
async def hello(interaction: discord.Interaction):
"""Says hello!"""
await interaction.response.send_message(f'Hi, {interaction.user.mention}')

#

or remove the self

buoyant quail
#

remove

main holly
#

like you said

buoyant quail
#

and you did put it above client definition

main holly
#

am i not supposed o

#

to

buoyant quail
#

!e

print(x)

x = 3
unkempt canyonBOT
#

@buoyant quail :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 1, in <module>
003 |     print(x)
004 |           ^
005 | NameError: name 'x' is not defined
buoyant quail
#

The same thing as you do

main holly
#

ohhh

#

import discord
from discord import app_commands

intents = discord.Intents.all()
client = commands.Client(command_prefix='.', intents=intents)

@client.event
async def on_ready():
print(f'Logged in as {client.user} (ID: {client.user.id})')
print('------')

@client.event
async def setup_hook(self):
await self.tree.sync()

@client.tree.command()
async def hello(interaction: discord.Interaction):
"""Says hello!"""
await interaction.response.send_message(f'Hi, {interaction.user.mention}')

#

?

naive briar
#

!code

unkempt canyonBOT
#
Formatting code on discord

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.

For long code samples, you can use our pastebin.

buoyant quail
#

You don't have commands variable but you do use it (5 line)

#

and Client is located not inside the commands

#

there are discord.Client and commands.Bot

main holly
#

bro omg idk how to do this

main holly
# buoyant quail and Client is located not inside the `commands`

like this?

import discord
from discord import app_commands

intents = discord.Intents.all()
client = discord.Client(command_prefix='.', intents=intents)

@client.event
async def on_ready():
print(f'Logged in as {client.user} (ID: {client.user.id})')
print('------')

@client.event
async def setup_hook(self):
await self.tree.sync()

@client.tree.command()
async def hello(interaction: discord.Interaction):
"""Says hello!"""
await interaction.response.send_message(f'Hi, {interaction.user.mention}')

buoyant quail
#

prefix is for Bot
client doesn't have prefix commands

main holly
#

oh

buoyant quail
#

and tree is also for bot

#

so i guess you want the Bot

#
from discord.ext import commands

client = commands.Bot(...)
#

and i'd name it bot not client

main holly
#

so import discord
from discord.ext import commands
from discord import app_commands

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

@bot.event
async def on_ready():
print(f'Logged in as {client.user} (ID: {client.user.id})')
print('------')

@bot.event
async def setup_hook(self):
await self.tree.sync()

@bot.tree.command()
async def hello(interaction: discord.Interaction):
"""Says hello!"""
await interaction.response.send_message(f'Hi, {interaction.user.mention}')

bot.run

#

oops

main holly
# buoyant quail and `tree` is also for bot

import discord
from discord.ext import commands
from discord import app_commands

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

@bot.event
async def on_ready():
print(f'Logged in as {bot.user} (ID: {bot.user.id})')
print('------')

@bot.event
async def setup_hook(self):
await self.tree.sync()

@bot.tree.command()
async def hello(interaction: discord.Interaction):
"""Says hello!"""
await interaction.response.send_message(f'Hi, {interaction.user.mention}')

bot.run

buoyant quail
#
@bot.event
async def setup_hook():
    await bot.tree.sync()
main holly
main holly
# buoyant quail ```py @bot.event async def setup_hook(): await bot.tree.sync() ```

from discord.ext import commands
from discord import app_commands

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

@bot.event
async def on_ready():
print(f'Logged in as {bot.user} (ID: {bot.user.id})')
print('------')

@bot.event
async def setup_hook():
await bot.tree.sync()

@bot.tree.command()
async def hello(interaction: discord.Interaction):
"""Says hello!"""
await interaction.response.send_message(f'Hi, {interaction.user.mention}')

bot.run("")

buoyant quail
#

commands.Bot

#

and i guess that's all

main holly
#

thank you

#

🙏

turbid condor
#

👍

main holly
turbid condor
#

Good

#

But making a prefix command for sync is even better

#

As u don't need to sync everytime your bot starts

main holly
turbid condor
main holly
#

nvm

turbid condor
#

But yeah this could be bad if he restarts the bot frequently

main holly
turbid condor
#

Welp still it is better to just create a command

main holly
#

i dont like prefix cmds

#

alot of people told me to switch to / cmds

#

so thats what im doin

#

and can someone tell me what im doing wrong

@bot.tree.command()
async def unban(interaction: discord.Interaction, user: discord.User):
"""Unban a previously banned user."""
if interaction.user.guild_permissions.ban_members:
banned_users = await interaction.guild.bans()
banned_user_ids = [entry.user.id for entry in banned_users]
if user.id in banned_user_ids:
await interaction.guild.unban(user)
await interaction.response.send_message(f'{user.mention} has been unbanned.')
else:
await interaction.response.send_message(f'{user.mention} is not currently banned.')
else:
await interaction.response.send_message('You do not have permission to use this command.')

#

it doesnt work and says "this application did not respond"

naive briar
#

Can't you just save slash command information on sync and compare it to the new stuff after restarting, then figure out whether to autosync or not?

#

That seems easy enough

buoyant quail
#

I am hoping that they already do that.. but idk

quick brook
buoyant quail
#

Who will stop me from doing that

unkempt canyonBOT
#

examples/app_commands/basic.py lines 25 to 28

async def setup_hook(self):
    # This copies the global commands over to your guild.
    self.tree.copy_global_to(guild=MY_GUILD)
    await self.tree.sync(guild=MY_GUILD)```
slate swan
#

Isn't that the same?

unkempt canyonBOT
#

discord/client.py line 1988

setattr(self, coro.__name__, coro)```
eager ridge
#

can someone help i try to fix it since 3 hr

#

Traceback (most recent call last):
File "C:\Users\mertc\OneDrive\Archiv\Desktop\DM BOT\dm.py", line 15, in <module>
slash = SlashCommand(bot, sync_commands=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\mertc\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord_slash\client.py", line 59, in init
self._discord.loop.create_task(self.sync_all_commands(delete_from_unused_guilds))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\mertc\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 140, in getattr
raise AttributeError(msg)
AttributeError: loop attribute cannot be accessed in non-async contexts. Consider using either an asynchronous main function and passing it to asyncio.run or using asynchronous initialisation hooks such as Client.setup_hook

naive briar
#

discord_slash is outdated ducky_sphere

#

discord.py already support slash commands, by the way

eager ridge
#

ok how should i change my code

#

then

eager ridge
#

yea we see....

slate swan
#

Example how to use slash commands in discord.py

Maybe this time you will actually open it

eager ridge
lost cliff
#

brooo what did I do 😢

slate swan
#

You spammed discord api

lost cliff
#

lmao ik now this was a couple months ago

#

its just funny as hell

eager ridge
#

what ?

slate swan
#

8 hours dam

eager ridge
#

we dont have same bots

#

and api

lost cliff
lost cliff
eager ridge
#

guys can someone help me now ?

slate swan
#

I have a question with discord py and buttons

#
    @discord.ui.button(label=str(f'No: {DENIES}'), style=discord.ButtonStyle.danger)
    async def button_no(self, interaction: discord.Interaction, button: discord.ui.Button):
        c = int(button.label) or DENIES
        if c - 1 <= 0:
            message = interaction.message
            embed = message.embeds[0]
            embed.description = f'NO \U0000274C'
            embed.clear_fields()
            await interaction.response.edit_message(embed=embed, view=None, attachments=[])
            no(self.pokemon, self.image)
        else:
            button.label = str(f'No: {c - 1}')
            await interaction.response.edit_message(view=self)```
#

So this code fails cuz c tries to int the label, which is not an int

#

Basically i wanna have buttons like No: 3

#

And every time u click, the counter is reduced and it reaches 0

#

How can i do it?

slate swan
#

3 peoples helped you

eager ridge
#

bro just tell me what i shgoulkd do

#

omfg

slate swan
#

that's not how it works bud

#

no. ppl here dont write code for u

eager ridge
#

BRO where i told write a code for me

#

just help me out from the error

slate swan
#

You have got 2 examples how to linked

#

Just open one of them

sick birch
eager ridge
slate swan
slate swan
eager ridge
#

listen

#

i did it already i get the same erros

sick birch
#

But it's the first one I can think of and the most straightforward

slate swan
#

i have a counter, and i wanna display on the button label f'No: {counter}'

sick birch
#

Alternatively you can also store the current number as an attribute instead of relying on the label

slate swan
sick birch
#

This is probably a better solution

sick birch
eager ridge
#

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

should i use this for st art

slate swan
#

no

#

Told you already to not use discord_slash module

eager ridge
slate swan
#

And the example is to see how to make slash commands with discordpy

hasty coral
#

Every time this command is run i get the same error: discord.app_commands.errors.CommandInvokeError: Command 'poll' raised an exception: AttributeError: 'NoneType' object has no attribute 'add_reaction'

Does anyone know how to fix this issue? I've checked the docs but there's no direct solution or example

polls = {}
@bot.tree.command(name='poll', description='Create a Poll')
@app_commands.describe(option1 = 'option1')
@app_commands.describe(option2 = 'option2')
@app_commands.describe(duration = 'duration')
async def poll(ctx:discord.Interaction, option1: str, option2: str, duration: int):
    embed = discord.Embed(title="Poll Time!", description="React to vote.", color=discord.Color.brand_green())
    embed.add_field(name="Option 1", value=option1, inline=False)
    embed.add_field(name="Option 2", value=option2, inline=False)
    message = await ctx.response.send_message(embed=embed)
    await message.add_reaction("1️⃣")  # Reaction for option 1
    await message.add_reaction("2️⃣")  # Reaction for option 2

    polls[message.id] = {
        "option1": option1,
        "option2": option2,
        "votes": {"1️⃣": 0, "2️⃣": 0}
    }

    await asyncio.sleep(duration*60)  # Wait for the chosen duration

    results = polls.pop(message.id)
    result_embed = discord.Embed(title="Poll Results", color=discord.Color.brand_green())
    result_embed.add_field(name=results["option1"], value=f"Votes: {results['votes']['1️⃣']}", inline=False)
    result_embed.add_field(name=results["option2"], value=f"Votes: {results['votes']['2️⃣']}", inline=False)
    await ctx.channel.send(embed=result_embed)
sick birch
slate swan
slate swan
slate swan
# sick birch Yeah

so i add approvs and denies as arguments to the init of the Counter class?

sick birch
naive briar
sick birch
#

That is their call

slate swan
#

Okay use it then 😃

sick birch
#

I think a "hey this library is outdated and not recommended, I also don't have experience with it so I can't help, sorry" is good enough without being rude/condescending

slate swan
#

I already said that

#

When he asked that first time

#

Cause this is Like 3rd i belive

sick birch
hasty coral
#

can i have an input on my code please?

#

Every time this command is run i get the same error: discord.app_commands.errors.CommandInvokeError: Command 'poll' raised an exception: AttributeError: 'NoneType' object has no attribute 'add_reaction'

Does anyone know how to fix this issue? I've checked the docs but there's no direct solution or example

polls = {}
@bot.tree.command(name='poll', description='Create a Poll')
@app_commands.describe(option1 = 'option1')
@app_commands.describe(option2 = 'option2')
@app_commands.describe(duration = 'duration')
async def poll(ctx:discord.Interaction, option1: str, option2: str, duration: int):
    embed = discord.Embed(title="Poll Time!", description="React to vote.", color=discord.Color.brand_green())
    embed.add_field(name="Option 1", value=option1, inline=False)
    embed.add_field(name="Option 2", value=option2, inline=False)
    message = await ctx.response.send_message(embed=embed)
    await message.add_reaction("1️⃣")  # Reaction for option 1
    await message.add_reaction("2️⃣")  # Reaction for option 2

    polls[message.id] = {
        "option1": option1,
        "option2": option2,
        "votes": {"1️⃣": 0, "2️⃣": 0}
    }

    await asyncio.sleep(duration*60)  # Wait for the chosen duration

    results = polls.pop(message.id)
    result_embed = discord.Embed(title="Poll Results", color=discord.Color.brand_green())
    result_embed.add_field(name=results["option1"], value=f"Votes: {results['votes']['1️⃣']}", inline=False)
    result_embed.add_field(name=results["option2"], value=f"Votes: {results['votes']['2️⃣']}", inline=False)
    await ctx.channel.send(embed=result_embed)
unkempt canyonBOT
#
Traceback

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
#

Yeah show full traceback

sick birch
hasty coral
#
Traceback (most recent call last):
  File "C:\Users\jackf\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\tree.py", line 1248, in _call
    await command._invoke_with_namespace(interaction, namespace)
  File "C:\Users\jackf\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 853, in _invoke_with_namespace
    return await self._do_call(interaction, transformed_values)
  File "C:\Users\jackf\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 846, in _do_call
    raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'poll' raised an exception: AttributeError: 'NoneType' object has no attribute 'add_reaction'
sick birch
naive briar
#

Response

sick birch
#

Ah, yeah

naive briar
#

!d discord.Interaction.original_response

unkempt canyonBOT
#

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

Fetches the original interaction response message associated with the interaction.

If the interaction response was a newly created message (i.e. through [`InteractionResponse.send_message()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionResponse.send_message) or [`InteractionResponse.defer()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionResponse.defer), where `thinking` is `True`) then this returns the message that was sent using that response. Otherwise, this returns the message that triggered the interaction (i.e. through a component).

Repeated calls to this will return a cached value.
sick birch
#

@hasty coral use that ^

hasty coral
#

just changed it to this, however the add_reaction part is still whited out

#
await ctx.response.send_message(embed=embed)
message = ctx.original_response
await message.add_reaction("1️⃣")  # Reaction for option 1
await message.add_reaction("2️⃣")  # Reaction for option 2
naive briar
#

original_response is an async function, you need to call and await it

#

(or method, whatever)

sick birch
#

message = await ctx.original_response() will give you what you want

hasty coral
#

right gotcha it works now, much appreciated 👋

slate swan
sick birch
# slate swan i just wanna do that. A counter on the buttons and when it reaches 0 remove butt...

I would just do something like so

class MyView(discord.ui.View):
  def __init__(self):
    self.count = 10 # start at 10
    super().__init__()

  @discord.ui.button(label="Count: 10")
  async def callback(self, interaction: discord.Interaction, button: discord.ui.Button):
    self.count -= 1 # decrement count
    if self.count == 0:
      self.clear_items()
      await interaction.response.edit_original_response(view=None)
    else:
      button.label = f"Count: {self.count}"
      await interaction.response.edit_original_response(view=self)

Not actually sure if this works but feel free to fiddle with it to your liking

severe sonnet
#

okay guys, what did i did wrong?

#
Database connected!
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\commands\bot.py", line 935, in _load_from_module_spec
    spec.loader.exec_module(lib)  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "c:\Users\User\Documents\GitHub\RP-Utilities\cogs\ActionCog.py", line 6, in <module>
    class ActionCog(commands.Cog):
  File "c:\Users\User\Documents\GitHub\RP-Utilities\cogs\ActionCog.py", line 22, in ActionCog
    @_annonymous_mode.commands(name="switch",)
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'set' object is not callable
#

!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 Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

severe sonnet
sick birch
severe sonnet
#

oh that's why

slate swan
#

@sick birch

#
@discord.ui.button(label=str(f'Yes: {APROVS}'), style=discord.ButtonStyle.green)
    async def button_yes(self, interaction: discord.Interaction, button: discord.ui.Button):```
#

This function is called everytime i press the button

#

right?

sick birch
#

That is correct

severe sonnet
#

okay so, guess i made the cog listener be in wrong way:

Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\commands\bot.py", line 935, in _load_from_module_spec
    spec.loader.exec_module(lib)  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "c:\Users\User\Documents\GitHub\RP-Utilities\cogs\ActionCog.py", line 6, in <module>
    class ActionCog(commands.Cog):
  File "c:\Users\User\Documents\GitHub\RP-Utilities\cogs\ActionCog.py", line 31, in ActionCog
    @commands.Cog.listener
     ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\commands\cog.py", line 495, in listener
    raise TypeError(f'Cog.listener expected str but received {name.__class__.__name__} instead.')
TypeError: Cog.listener expected str but received function instead.
sick birch
slate swan
#

okey so i deff cant do

sick birch
#

Note the inclusion of the parenthesis

slate swan
#
    @discord.ui.button(label=str(f'No: {DENIES}'), style=discord.ButtonStyle.danger)
    async def button_no(self, interaction: discord.Interaction, button: discord.ui.Button):
        c = DENIES```
#

Cuz everytime i press it, c gets reseted

sick birch
slate swan
#

yeah

#

before the button labels hasnt text

#

so i was doing button.label = str(c-1)

#

and i was grabbing the label already reduced again

#

but if i have text i cant do this

sick birch
#

!rule 9

unkempt canyonBOT
#

9. Do not offer or ask for paid work of any kind.

sick birch
#

Use internal state

slate swan
#

yeah ^^'

#

so a good practice would be

#
class Counter(discord.ui.View):
    def __init__(self, name=None, image=None, aprovs=APROVS, denies=DENIES):
        super().__init__()
        self.name = name
        self.image = image
        self.aprovs = aprovs
        self.denies = denies
#

like this?

#

or no need to pass as arguments since APROVS and DENIES are global variables?

severe sonnet
#

okay uhmm...

surreal cliff
severe sonnet
#
ERROR    discord.client Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 441, in _run_event
    await coro(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^
TypeError: ActionCog.on_message() missing 1 required positional argument: 'message'
surreal cliff
#

Wasn't aware.

sick birch
severe sonnet
#

!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 Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

sick birch
dusk dagger
severe sonnet
#

the p´roblem is that i need ctx to get the database instance

hollow zinc
#

Who has the greatest tutorial currently on making a discord.py bot?

severe sonnet
#

how do i get the instance of my database?

dusk dagger
severe sonnet
#

and i can't acess it without through the bot

vocal snow
#

and self.client is an instance of said bot class

dusk dagger
#

I don't understand how you pass in an instance of your bot and just don't realize itintjfall

#

Please don't name a commands.Bot object client it's extremely misleading

severe sonnet
#

okay so, since i can't use ctx i changed my algo a bit

#

first i commmented my algo

#

and then made a print of message

#

i got this output:

<Message id=1145078294425915413 channel=<TextChannel id=1135999360656748618 name='rpu-test' position=3 nsfw=False news=False category_id=1141434256980189276> type=<MessageType.default: 0> author=<Member id=1130268405333753857 name='hirukaroguetemplar2.0' global_name='Rogue Templar' bot=False nick=None guild=<Guild id=1135999359985647706 name='RP Utilities server' shard_id=0 chunked=False member_count=2>> flags=<MessageFlags value=0>>
#

how do i get the message i typed?

naive briar
#

That's the message object

severe sonnet
#

yep, and how i make it grab the message i typed

#

in my chase:
cB: Hello world?

vocal snow
#

check the docs for Message/

#

!d discord.Message

unkempt canyonBOT
#

class discord.Message```
Represents a message from Discord.

x == y Checks if two messages are equal.

x != y Checks if two messages are not equal.

hash(x) Returns the message’s hash.
vocal snow
#

click the blue title

naive briar
severe sonnet
#

this message

#

and then store it into a variable

naive briar
#

And what's the problem you're having?

severe sonnet
#

i don't know how to grab the message i send in this apk

#

like, it grabs the message object

naive briar
#

!d discord.TextChannel.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/latest/api.html#discord.Message) from the destination.
severe sonnet
#

but i don't know which grabs the content

naive briar
unkempt canyonBOT
severe sonnet
#

in my case i don't know if message_content will work in a cog listener

#
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 441, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\User\Documents\GitHub\RP-Utilities\cogs\ActionCog.py", line 36, in on_message
    print(message.fetch_message)
          ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Message' object has no attribute 'fetch_message'
#

same with message_content

#

okay soo, enabling that...

#

maybe i will need to enable it in message from listener

#

yep, it need intents

#

otherwise it's an eternity of leading

slate swan
#

message.fetch_message gophermindblown

severe sonnet
#

okay why do my code overlay "B" with ":"?

#
cB: Hello World
['cB', ' Hello World']
['c:', ' Hello World']
C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\pymongo\collection.py:1661: UserWarning: use an explicit session with no_cursor_timeout=True otherwise the cursor may still timeout after 30 minutes, for more info see https://mongodb.com/docs/v4.4/reference/method/cursor.noCursorTimeout/#session-idle-timeout-overrides-nocursortimeout
  return Cursor(self, *args, **kwargs)
None
#

!e

message_disc = "cB: Hello World"

instances = message_disc.split(':', 1)
print(instances)
prefix = message_disc[0]
prefix = prefix+':'
instances[0] = prefix

print(instances)

unkempt canyonBOT
#

@severe sonnet :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | ['cB', ' Hello World']
002 | ['c:', ' Hello World']
severe sonnet
#

what the?

#

i didn't knew that python do that when you try concat string

final isle
#

how do i connect my discord bot to youtube to get notifications for certain youtube channels

buoyant quail
#

.

buoyant quail
eager ridge
#

FINMALYY

#

I MAKE IT; ITS WORK

#

Thank you very much ❤️ @slate swan & @vocal snow

slate swan
quick brook
pliant jay
#

How do I fix this?

Import "discord_components" could not be resolved

slate swan
quick brook
#

FYI discord.py already has native support for ui components

#

see examples in the repo

slate swan
#

every of most known libraries have support for components

#

already

sick birch
pliant jay
sick birch
pliant jay
sick birch
slate swan
pliant jay
slate swan
slate swan
quick brook
quick brook
slate swan
#

of the class, right?

quick brook
slate swan
#

if i should do that

#

or self.aprovs = APROVS

#

without the argument on the init

quick brook
#

are you making a simple yes or not confirmation view?

quick brook
slate swan
#
class Counter(discord.ui.View):
    def __init__(self, name=None, image=None, aprovs=APROVS, denies=DENIES):
        super().__init__()
        self.name = name
        self.image = image
        self.aprovs = aprovs
        self.denies = denies```
or
```py
class Counter(discord.ui.View):
    def __init__(self, name=None, image=None):
        super().__init__()
        self.name = name
        self.image = image
        self.aprovs = APROVS
        self.denies = DENIES```
sick birch
#

It really doesn't matter

#

APROVS is simply the starting number

slate swan
#

i know it is the same

#

just a better practice

sick birch
#

self.aprovs is the important one

sick birch
quick brook
#

both are actually pretty much the same

#

second

sick birch
#

Though you should get rid of the global APROVS and DENIES, if you go with the former approach

slate swan
#

why? like, if i change it in the future, i dont want magical numbers

sick birch
#

You would change it at the call site

#

Rather than in some global variable

slate swan
#

huh, but having them near the bot prefix, for example, is much more accesible (?)

#

tbh, those 2 variables should be "constant"

sick birch
#

It's a design choice and up to you

slate swan
#

Once you restart your bot they won't hold the value anymore, just remember that

#

thats why they should be constant

#

i have a dummy variable

#

Won't change anything

#
    @discord.ui.button(label=str(f'No: {DENIES}'), style=discord.ButtonStyle.danger)
    async def button_no(self, interaction: discord.Interaction, button: discord.ui.Button):
        c = DENIES```
#

Restarting a program will reset it, constant or not - that's not how it works

#

c is the dummy

#

i dont change APROVS nor DENIES

#

Again, it doesn't matter. Restarting your bot will reset everything

#

u mad?

#

APROVS never changes on runtime

#

You don't get it, do you?

#

i think u dont

#

You don't

#

you dont

#

If you change any variable at runtime, ANY

#

It will get reset once you restart your bot

#

Doesn't matter if it's a constant or not, it will get reset

slate swan
young dagger
#

How can I prevent duplicates from the same user across different channels?

slate swan
#

You still show some data that hopefully changes otherwise there's no point in setting a variable for that

#

????????

#

kekw

slate swan
#

So, let's start from the beginning - what does DENIES hold

#

okey dude, im done with u xd

young dagger
#

I mean, prevent people spamming the same message in multiple channels.

slate swan
#

Use AutoMod krShrug

slate swan
cloud dawn
#

@slate swan I'm sorry but "u mad?" and "do u even read?" doesn't really comply with the code of conduct of this server. It's not even nice at all.

slate swan
#

Getting used to these people over time KEK

cloud dawn
sick birch
slate swan
#

Welcome to the generation of these years I suppose

#

:kek:

cloud dawn
#

I wouldn't blame an entire generation.

young dagger
cloud dawn
young dagger
slate swan
cloud dawn
cloud dawn
visual yarrow
#

@slate swan, please be considerate in your interactions with people here. As Pandabweer said, comments like "u mad?" and "do u even read?" are inflammatory, and not the sort of conduct we want in this server. Please review our #code-of-conduct.

young dagger
# cloud dawn <https://github.com/python-discord/bot/tree/main/bot/exts/filtering/_filters/ant...

Thanks. What do you think about this?

MAX_STORED_MESSAGES = 10

recent_messages = {}

@client.event
async def on_message(message):
    user_id = message.author.id
    channel_id = message.channel.id
    user_message = message.content

    if user_id not in recent_messages:
        recent_messages[user_id] = {}

    if channel_id in recent_messages[user_id]:
        messages = recent_messages[user_id][channel_id]
        if len(messages) >= MAX_STORED_MESSAGES:
            messages.pop(0)  # Remove oldest message
        if user_message in messages:
            await message.delete()
            await message.channel.send(f"{message.author.mention}, please avoid posting duplicate messages.")
            return
        messages.append(user_message)
    else:
        recent_messages[user_id][channel_id] = [user_message]```
slate swan
#

looks good

cloud dawn
slate swan
#

although i wouldnt recommend using .event decorator unless you are not using prefixed commands

hollow zinc
#

How should I install it on my path?

slate swan
#

You're always popping if it's >=10 but not necessarily adding the newly sent message

#

Feels a bit weird

#

there is two ifs so both will be executed

#

Yeah but if the second gets executed it won't get added

#

cause its already there

quick hound
#

return Session.settings_ready['guilds'][self.guildID]['member_count']
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
KeyError: 'guilds'

#

can someone help me plz

slate swan
#

Not if it has been popped before

slate swan
#

Well with a max stored message value of 10, wouldn't you expect it to actually check for the stored messages PepeHmm

#

i guess easiest refactor would be to switch the ifs?

#

Or >= to >

#

Depends the behavior they want

quick hound
slate swan
#

Error says it all, you don't have the key "guilds"

quick hound
slate swan
#

By adding the key

slate swan
#

!e

myDict = {
  "users": "blah"
}
print(myDict["users"])
print(myDict["guilds"])
unkempt canyonBOT
#

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

001 | blah
002 | Traceback (most recent call last):
003 |   File "/home/main.py", line 5, in <module>
004 |     print(myDict["guilds"])
005 |           ~~~~~~^^^^^^^^^^
006 | KeyError: 'guilds'
slate swan
#

Session.settings_ready print to console this and see what it has and why there is no guild key you expect to be there

quick hound
slate swan
#

Yes it would matter

quick hound
slate swan
#

Correct

#

This is a helping channel, use it accordingly krShrug

hollow zinc
#

Why is it installed on another PATH?

slate swan
hollow zinc
#

K Got it

slate swan
#

never seen discium

#

There we go, we don't provide support for self-bots

quick hound
#

ok

slate swan
#

Just wanted to confirm that, thanks CS_ThumbsUp

#

😳

#

busted

unkempt canyonBOT
#

5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.

quick hound
#

yes busted

young dagger
young dagger
cloud dawn
#

You could also look into fuzzy matching for those trying to dodge the filter.

slate swan
#

if you are trying to defend from bots spamming each channel same message i once saw cool solution
it was a channel visible by everyone and everyone could send messages in here

the trick was it was named DO NOT MESSAGE or something simmilar and there was a warning message too in the channel itself, basically you sent message here you were banned insta

cloud dawn
slate swan
cloud dawn
#

Well you can set a channel up that cannot be seen by anyone unless you have admin perms but you can allow everyone to send messages.

slate swan
#

if you cant see it how can you send a message in it

cloud dawn
#

If self bot use the API and filter on send perms rather than visibility perms you could make the channel hidden to avoid accidental bans.

cloud dawn
slate swan
#

yeah but will they see it

cloud dawn
#

Well if the code only checks send perms rather than visibility then it's ok

cloud dawn
#

Regardless of them being hidden, it's weird i know.

slate swan
#

so thats how the better discord extension to show private channels was working 🧐

#

i remember using better discord like 3 years ago skull

cloud dawn
#

Yeah it's just the API still sending the channel tbh big flaw imo

#

But in this case you could try it.

#

But any smart coder would just check for recent messages less than a couple of minutes old and not sent by a bot.

#

Damn we could really create one heck of a raid bot lmao

slate swan
#

yeah this scary

cloud dawn
#

Not implying I will, but if I would I'd do it right.

severe sonnet
#

guys, how do i properly ping someone in embeds?

#

in this webhook

#

it's suppose to ping myself

#

not showing my id

slate swan
#

you cant ping anybody in the embed title

severe sonnet
#

oh i see

#

then i need to set in authot

#

*author

#

thought that is not the title

#

it's the author

slate swan
#

whatever that is, you cant put mentions in here

severe sonnet
#

as you can see:

for i in message_instance:
                in_db = True
                for j in buffer:
                    if i[0] in j["prompt_prefix"]:
                        embed = discord.Embed(
                            description=i[1]
                        )
                        embed.set_author(name=f"character of {author}")

                        await webhook.send(username=j["name"], avatar_url=j["image_url"], embed=embed)
                        in_db = False
                        break
                
                if in_db:
                    prompt_instance = await self.client.database.quick_search_default_character(user_id=message.author.id, prompt_prefix=i[0])
                    prompt_instance = prompt_instance[0]

                    if webhook is list:
                        webhook = webhook[0]
                    
                    embed = discord.Embed(
                            description=i[1]
                        )
                    embed.set_author(name=f"character of {author}")

                    await webhook.send(username=prompt_instance["name"], avatar_url=prompt_instance["image_url"], embed=embed)
severe sonnet
slate swan
#

!d discord.Embed.set_author

unkempt canyonBOT
#

set_author(*, name, url=None, icon_url=None)```
Sets the author for the embed content.

This function returns the class instance to allow for fluent-style chaining.
slate swan
#

you can for sure in the description or in fields

fading marlin
#

You can't ping anyone in embeds for that matter. You can only mention users in descriptions or field values

severe sonnet
#

i see

#

guess i will ping in the content of my webhook