#discord-bots
1 messages · Page 292 of 1
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>
see now you got full traceback
@slate swan i need to go offline are you able to help me with this tomorrow at 9 am GMT +2?
just ask your question here and somebody will answer you, im not the only one helping here
ok, bye i guess
@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?
but solution to your error is: invite bot with application.commands scope
Forbidden – The client does not have the applications.commands scope in the guild.
how you delete messages? using purge?
to delete message after x seconds pass delete_after kwarg when sending
!d discord.TextChannel.send
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**.
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.
@slate swan What is the difference between Using Cleint and Using Bot
Oh wait
sry i see
its explained below
Yeah
like that ?
if only this was correct syntax, yeah
what is the variable of the number of messages that I want to delete in my code?

len(messages)?
?
infact when I do: !del "x" on my server, it deletes "x" messages.
In my code which variable is "x" ?
and i also need a ay to insert embed into the webhook
!d discord.TextChannel
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.
@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?
!d discord.TextChannel.delete_messages
and set the embed into the webhook?
no i don't want to add a variable i want to know what variable i need
you need to call the listener decorator
lisener decorator... uhmm...
curious @slate swan
!d discord.TextChannel.purge
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...
?
like, listener decorator, maybe i need a doc for that
please help with the syntax
!d discord.ext.commands.Cog.listener you already have that in your code you just dont call it
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).
i see
syntax fail
You should clearly see why it does
thought i don't know where i had to call it
you know for a fact blud can't read that
if you dont see whats wrong with it you shouldnt be making a discord project already
Ik
I couldn't tell them to read it if I didn't send it in first place
it's to train me
So I need to send it
discord bot is not a good project to learn python, at least not to learn basics'
unless you're built different
I have 3 hours of codes under my belt and I'm proud of everything I've done in 3 hours, it's by trying that we learn
I did so
same
Ik just the very basics
send message, delete message, reaction its easy
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
I've ridden a bike before I have flew this plane
nah cuz I knew oop
more like the opposite
Dyslexic moment
he's saying java is harder
ok but finally can you help me for the syntax of this sentence please @slate swan
java is the plane
Ikik i wanted to say that
oh
I am the dyslexic
damn

You learn how to walk before you run
please
!res
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
I prefer to start swimming
Is there any way to download te file that a user send to the bot? Ex: A pdf file
Sobelos?
Autocorrector
!d discord.Attachment
A hands-on guide to Discord.py
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.
please just syntax of the sentence, i look after
What'swrongwiththissentence
which you get from message.attachments[i] @crude sparrow
you drown
that

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
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...
that's awful

you have to use send on a channel object
like ctx.channel
await ctx.channel.send(...)
and you don't need content=
how ok i know im stupide
hello i need help
is it possible to connect several bot in an index? to make a bot manager command
that's basically the whole line without the content of the message
at least add a + between the number of messages and the string
or learn about f-strings
!fstring
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.
thanks
,
!indent
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
do read those emperle
!d discord.Client.start innit
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).
i dont understand
maybe not
because i'm french and the french are noobs in english
you can't just
6 "string"
you have to make one string out of that
6 + " string"
or
f"{6} string"
where 6 can be a variable
ok but where ?
its my content
god
..
read this, then look at your content
I want the bot to write the number of deleted messages + this sentence in green when I delete the other messages
thats why i just send resources link.
listen, we dont really care what it will be saying now, we only are working out why it wont work cause it has syntax error
you cant just use a varriable and follow it with a string you need to merge them to one string
check this out
either adding them using + or using fstrings
ok
ok and how
cause thats just how it works
!e
print(6 "messages were deleted")
@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?
!e
print(f"{6} messages were deleted")
@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'
L
fuck
(how)
nah bro you need resources link now
sorry
look
woaw
!e
print(f"{6} messages were deleted")
@cold sonnet :white_check_mark: Your 3.11 eval job has completed with return code 0.
6 messages were deleted
!e ```py
super_cool_text = "hello"
print(super_cool_text "world") # throws error
@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
but replace 6 with your variable
!e ```py
super_cool_text = "hello"
print(super_cool_text + "world")
@slate swan :white_check_mark: Your 3.11 eval job has completed with return code 0.
helloworld
omg helloyou
simply adding a plus between, boom works
not in his case bru
if his varriable is a string it will
it's not
why not
I hope
how can I use discord's auto mod in discord.py?
hold on
it's int
no way you did it
respectfully, I think you need to re-read through the official tutorial docs for the python version you're using, and find an online list of programming exercises to work through. Project Euler is good for the maths aspect, but not sure about things like getting used to dealing with dictionaries and json, as well as web requests and whatnot.
sorry
tried already to enfore him to learn python basics, didnt work
I have hackerrank python basic certificate
I'm an official opp
explain what super does then
the parent class
guy is going to needlessly suffer, so many things that would be natural to others is going to take him minutes if not hours.
they didn't teach that on hackerrank tho
i know, his decision
what a shame
I learned that in a youtube video
💪
though there was much more to it than that
gotta watch it again
youtube tutorials be like 
can you just correct me (for 1 time only)
await ctx.channel.send(f"{number_of_message} viens d'être supprimer", delete_after=10seconds)
remove seconds
there is no such thing as 10seconds what type would that be
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
I watch videos but he, flatten was walking
what library/api is the guy using? interested in browsing through it myself now to see what's up
well don't
!d discord
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.
!pip discord.py
hi down
hi snipy
kinda racist
i want to build something
only greets the turtle
no im not working on my issue sorry
a castle from sand?
build gta 6
ok but ?
10seconds is not a thing bro
not a datatype
it's like the first thing you learn
so how do you say seconds in python
fuck you sir lancebot
pls
pass a float to it, it will understand you mean this many seconds
what you wanna build blud
a discord bot or a library
doesn't really depend on python it depends on dpy rn
im making like 7 discord bots already with everyone
ok but how build float
a library is great but noone will ever use it 😢
please learn at least basics of python
kekw
... a number
hikari wrapper
jk i aint touching hikari
with decimal points probably
int is fine too
!e
x = 1.2
print(x, type(x))
@glad cradle :white_check_mark: Your 3.11 eval job has completed with return code 0.
1.2 <class 'float'>
ok i will do that but first please i would like you to correct me this simple sentence
you said that you will learn python after message i send like half an hour ago bro please
and after I learn the basics of python I promise
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?
yes
how to cook rice using python
await Rice().cook()
have you tried changing 10seconds to just 10 or even 10.0?
busted
mh you should use some parenthesis to make it more readable
sorry disnake PRs hitted my head
my mum would tell you you don't need await cuz why would you need to do other stuff you dopamine addicted opp
its using pep 9001 code style sorry new style
await None
!indent
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
more than 2 errors
please don't put it in the for loop
what if None is awaitable, we would live in a completely different universe
and please use purge
https://docs.python.org/3/tutorial/interpreter.html start here, you will NOT understand everything, but try to pick up whatever info you can from the tutorial.
where did that come from
i am assuming you're using python 3.11 btw, but you can run python --version in the terminal to see what version you got installed
not python 2 for sure
naming the message user is crazy
I have just learned that during an error it was necessary to analyze and try by yourself to solve the problem
wasnt it always like that?
but its what ?
ok i actually don't understand what's causing the indentation error here, interested myself.
no
prolly inconsistent usage of spaces and tabs
ty
man
replace line 18 to 21 with just that
vsc
well gl i dip
dpy. hiraki has some very interesting standards that make it just annoying to work with, and all of the other forks are just useless since dpy has all of the features that the forks were meant to implement when dpy was on hiatus (but now isn't on hiatus and is very well maintained)
I will not touch hiraki with a ten foot pole
how do i add 2 buttons to 1 embed?
dont use discord slash its outdated
can someone help me guys
and i tried alraedy
" pip install discord-py-interactions "
what should i use ?
all knows libraries already have support for slash commands
what you mean sir ?
what library are you using?
python
and since when python is a package
what package, module, library are you using for discord bot
@slate swan after you are done with him do you know how i add 2 buttons to 1 embed?
you cant add buttons to embed, but you can to message
you mean this sir ?
this still doesnt answer my question what library it is
it can be discord.py can be nextcord and can be py-cord or many more
depends on preferences which you cannot have since you didnt use any
so for beginner i suggest discord.py
i linked you example how to use slash commands in discord.py
does this also work on a link button?
yes, why not
idk XD but it shows 2 at the same time right in that code?
you can run it yourself and see exactly how it works
you can later change somethings in code and see what changes in discord
mk
(thats literally how you learn)
ye ik hah i ment okay with my message
...
The solution is to not use discord_slash
Don't use discord_slash then...
what should i use then?
i alraey use it ?
Did you even look at the example i sent?
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
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 😢
Is discord importing properly?
i'm actually using py-cord
idk i only have py-cord rn
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
Cool
This doesn't change the question
Is there also an error when you import discord
nah
Have you reinstalled pycord
What method can be used to check is a member has a certain permission?
No documentation found for the requested symbol.
burh
!d discord.Member.guild_permissions
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.
I'd use permisions_for though
It's okay! I was tryin to get the actual list so I just did this
A list of tuples tbf but a list nonetheless lol
Why use that instead of permissions_for?
I needed a way to see the actual permissions (like the text), does it return a list of the members permissions?
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).
a question
for webhooks do it need the channel id?
or just discord.Message.channel?
I wouldn't take my word on it but I'm pretty sure you need a TextChannel object
You could get a TextChannel object from an ID though
!d discord.TextChannel.create_webhook
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.
!d discord.utils.get
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...
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
No
You need an interable
It gives you examples
and if i do this?
channel = await discord.utils.get(ctx.channel)
At least according to what i read
do you not know that dpy already has native slash command support?
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
In ChatGPTs defense, it's knowledge cutoff date was September 2021 and I don't believe discord.py had implemented slash commands at that time
true
Not sure how this is confusing. The docs provide examples for your use-case
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
The rest is true though
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
yep got nerfed iirc
it was always nerfed
!d discord.PCMVolumeTransformer
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`.
can someone help me please
how did you arrive to the conclusion of using that module?
dpy has slash commands natively intergrated
Didnt i already tell you to not use it?
down is angry
Nonetheless, please see this gist on how you can use slash commands within dpy: https://gist.github.com/AbstractUmbra/a9c188797ae194e592efe05fa129c57f
discord.py 2.0+ slash command info and examples. GitHub Gist: instantly share code, notes, and snippets.
no
yeah buddy i did not
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
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
I worked out the cause of this
Oh thanks
Its because you did not set application.commands scope when inviting the bot
You need to reinvite the bot and use this scope now
A hands-on guide to Discord.py
Here you have how to do that
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
Is MY_GUILD an int?
Its Object
I saw his code before and it was
Then is the bot in that guild
Maybe it's impossible to sync application commands with guilds which the bot isn't in
Pretty normal if it wouldnt be possibile
Yes and then the solution would be making sure the IDs match
Syncing to guild?
To sync a command tree with a guild
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?
No need to send the same error 3 times
Is the bot in the guild you try to sync it to?
that looks like a slash command but an error handler for a normal prefix command?
or are you using a hybrid command
Is there way we can reload the cogs on file change something like file watcher in discord.py?
!pypi cogwatch
Automatic hot-reloading for your discord.py (or other supported libaries) command files.
this maybe
disnake has reload arg in run for this, but it seems discord.py doesn't have something similar
I'm getting more and more interested in disnake
yeah that's great, Keep it up
xd
?
I dont undersatnd you?
I use slash command

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?
well its not a programming language
its a markup language
whats the diff bw markup and down

i have no idea what that is sorry
zeffo how come u never told us that u were a wc professor 😔
I am definitely nota professor of any kind though
lmao
how is that code?
im down
html is indeed a language
just not programming language
clearly you dont know anything about the WC .
Wouldn't jishaku work?
the toilet???
the world championship???
warcraft???
World Cup
It does have it?
I can see only manual reloading there
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'
How old is the yt video?
but i already installed pip install discord-py-interactions
Only filter on max 6 months, these libraries are old and unused.
!pypi discord-py-interactions
Where you see discord_slash here?
discord_slash was an old lib removed from pypi.
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
yo bruh how do i make slash cmds using bot.tree.command
they dont sync
lol
What's so funny
mb nothing
you're a turtle
🗿
but how do i make em sync
Send your code using !paste
!paste
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.
its not even large amounts
I like the formatting better.
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)```
But you can check out https://gist.github.com/AbstractUmbra/a9c188797ae194e592efe05fa129c57f
is it only for one guild
so like this async def setup_hook(self):
self.tree.copy_global_to()
await self.tree.sync()
just sync
and delete self.tree.copy_global_to()?
yes
okay
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}')
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()
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
remove
like you said
and you did put it above client definition
!e
print(x)
x = 3
@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
The same thing as you do
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}')
?
!code
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
bro omg idk how to do this
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}')
prefix is for Bot
client doesn't have prefix commands
oh
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
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
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
@bot.event
async def setup_hook():
await bot.tree.sync()
sorry abt this man im new
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("")
The first guy i have seen so far who is at least syncing in setup_hook
👍
is that good or bad
Good
But making a prefix command for sync is even better
As u don't need to sync everytime your bot starts
how do i do that
Wdym?
nvm
autosyncs 
Welp at least still better than in on_ready
But yeah this could be bad if he restarts the bot frequently
i only restart it on updates
Welp still it is better to just create a command
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"
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
I am hoping that they already do that.. but idk
🤣 that is not how you use setup hook
Who will stop me from doing that
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)```
Not with an event listener
Isn't that the same?
discord/client.py line 1988
setattr(self, coro.__name__, coro)```
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
Traceback (most recent call last):
File "C:\Users\mertc\OneDrive\Archiv\Desktop\DM BOT\dm.py", line 18, in <module>
@bot.slash_command(name="dm",
^^^^^^^^^^^^^^^^^
AttributeError: 'Bot' object has no attribute 'slash_command'. Did you mean: 'add_command'?
yea we see....
discord.py 2.0+ slash command info and examples. GitHub Gist: instantly share code, notes, and snippets.
Told you 3 times already to not use discord_slash
Example how to use slash commands in discord.py
Maybe this time you will actually open it
nah you never told me
brooo what did I do 😢
You spammed discord api
what ?
8 hours dam
(reffering to this)
guys can someone help me now ?
..
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?
You will have to splice the string so it's just the number part
i dont understand them
.
What's so hard with understanding them?
is that the only way?
BRO
listen
i did it already i get the same erros
Probably not
But it's the first one I can think of and the most straightforward
i have a counter, and i wanna display on the button label f'No: {counter}'
Alternatively you can also store the current number as an attribute instead of relying on the label
How can you get the same errors when None of the examples mention discord_slash module
of the class?
This is probably a better solution
Yeah
import discord
from discord.ext import commands
from discord_slash import SlashCommand, SlashContext
should i use this for st art
bro no one module supports slash
And the example is to see how to make slash commands with discordpy
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)
They can use it if they want to, let's not be condescending please
Actually every known ones do these days
Its outdated and doesnt work anymore
so i add approvs and denies as arguments to the init of the Counter class?
It was redesigned for interactions.py
I'm aware, you can tell them that but there's no need to force them to use something else
Then let them get the error by continuing to use it 👍
That is their call
Okay use it then 😃
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
You can add anything to the ctor but I'm not sure what the broader context here is
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)
!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.
Yeah show full traceback
Send message doesn't actually return the sent message, contrary to what you might believe
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'

Response
Ah, yeah
!d discord.Interaction.original_response
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.
@hasty coral use that ^
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
original_response is an async function, you need to call and await it
(or method, whatever)
message = await ctx.original_response() will give you what you want
right gotcha it works now, much appreciated 👋
i just wanna do that. A counter on the buttons and when it reaches 0 remove buttons
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
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
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.
It should be .command not .commands on line 22
oh that's why
@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?
That is correct
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.
Should be @commands.Cog.listener() on line 31
okey so i deff cant do
Note the inclusion of the parenthesis
@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
Yes, that's why you need to store it in the class state
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
!rule 9
Don't rely on the button label for the current count
Use internal state
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?
okay uhmm...
Sorry @sick birch
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'
Wasn't aware.
no worries
!paste
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.
what did i did wrong this time?
Your on_message cog listener should look like so:
@commands.Cog.listener()
async def on_message(self, message):
# code here
on_message doesn't take in ctx
the p´roblem is that i need ctx to get the database instance
Who has the greatest tutorial currently on making a discord.py bot?
how do i get the instance of my database?
How does ctx have any correlation with your database? You can use the bot object that you passed into your cog subclass and named it client for some odd reason
robin 😦
it's because my database is registered in my bot class
and i can't acess it without through the bot
and self.client is an instance of said bot class
I don't understand how you pass in an instance of your bot and just don't realize it
Please don't name a commands.Bot object client it's extremely misleading
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?
That's the message object
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.
click the blue title
I don't know what that means
like i want to my bot grab like
this message
and then store it into a variable
And what's the problem you're having?
i don't know how to grab the message i send in this apk
like, it grabs the message object
!d discord.TextChannel.fetch_message
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.
but i don't know which grabs the content
!d discord.Message.content 
The actual contents of the message. If Intents.message_content is not enabled this will always be an empty string unless the bot is mentioned or the message is a direct message.
i see
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
message.fetch_message 
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)
@severe sonnet :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | ['cB', ' Hello World']
002 | ['c:', ' Hello World']
how do i connect my discord bot to youtube to get notifications for certain youtube channels
.
You wanted to use instances[0] instead of message_disc[0] maybe
could someone answer me pls?
why are you using global variables in the first place
How do I fix this?
Import "discord_components" could not be resolved
you dont
dont use this library, its outdated
FYI discord.py already has native support for ui components
see examples in the repo
Can you re-ask your question with all context and code?
What one should I use?
Are you using discord.py?
Yes
Then you don't need anything else
Oh okay, thank you
examples of using components in discord.py ^
well, what i said before. I have variables at the beggining of the code, like APROVS. And i wanna make a button which displays a counter, starting on APROVS, and decreasing every time i press it
what i would suggest is to cache your value in an attr within the button view, and just increment or decrement depending on the button
but how can i cache it?
in an attr
of the class, right?
yes
thats what i am asking
if i should do that
or self.aprovs = APROVS
without the argument on the init
are you making a simple yes or not confirmation view?
im making this
so basically a upvote/downvote button
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```
self.aprovs is the important one
The former then
Though you should get rid of the global APROVS and DENIES, if you go with the former approach
why? like, if i change it in the future, i dont want magical numbers
huh, but having them near the bot prefix, for example, is much more accesible (?)
tbh, those 2 variables should be "constant"
It's a design choice and up to you
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
How can I prevent duplicates from the same user across different channels?
You still show some data that hopefully changes otherwise there's no point in setting a variable for that
????????
kekw
Add a guild id.
So, let's start from the beginning - what does DENIES hold
okey dude, im done with u xd
I mean, prevent people spamming the same message in multiple channels.
Use AutoMod 
or keep track of user id and his last msg (?)
@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.
Getting used to these people over time 
gratz. 🎖
Well it shouldn't be, it's a form of formality that people seems to be forgetting.

I wouldn't blame an entire generation.
Duplicates in what form?
If I were posting "I like cats" in all channels
Oh prevent spamming.
Mhm
thats literally what he said. Seems u cant read too
https://github.com/python-discord/bot/tree/main/bot/exts/filtering/_filters/antispam here are some of the filters this server uses including the duplicates.
Well I looked over that, we're people too. Communication is important and with that comes patience. If you're only here to provoke and annoy people please do that somewhere else.
@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.
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]```
looks good
I think this is a good solution, 10 might be a bit strict but other than that it's good.
although i wouldnt recommend using .event decorator unless you are not using prefixed commands
How should I install it on my path?
Isn't there a flaw in your system? 
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
return Session.settings_ready['guilds'][self.guildID]['member_count']
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
KeyError: 'guilds'
can someone help me plz
Not if it has been popped before
thats a feature to actually check last 9 messages
Well with a max stored message value of 10, wouldn't you expect it to actually check for the stored messages 
i guess easiest refactor would be to switch the ifs?
Or >= to >
Depends the behavior they want
hey, would you help me plz ?
Error says it all, you don't have the key "guilds"
how can i solve this ?
By adding the key
yeah
!e
myDict = {
"users": "blah"
}
print(myDict["users"])
print(myDict["guilds"])
@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'
Session.settings_ready print to console this and see what it has and why there is no guild key you expect to be there
would you matter if i could send u my code in dm and u tell me what is the error because still poping like it's an error
Yes it would matter
u don't want ?
Why is it installed on another PATH?
not related use #1035199133436354600 instead
K Got it
Mind showing a bit more of your code
never seen discium
There we go, we don't provide support for self-bots
ok
5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.
yes busted
Why do you think it is too strict? Can you give me a scenario example?
Thanks 
Well maybe something could occur again later a similar message. But thinking about it, it seems fine.
You could also look into fuzzy matching for those trying to dodge the filter.
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
I suppose you could also just make it invisible and allow them to send messages in there. Since hidden channels are still sent trough the API
what you mean by invisible channel? am i unaware of some discord feature
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.
if you cant see it how can you send a message in it
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.
That's the point, only self botters or client modders can see those channels.
yeah but will they see it
Well if the code only checks send perms rather than visibility then it's ok
Yeah the API will just send all channels.
Regardless of them being hidden, it's weird i know.
so thats how the better discord extension to show private channels was working 🧐
i remember using better discord like 3 years ago 
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
yeah this scary
Not implying I will, but if I would I'd do it right.
guys, how do i properly ping someone in embeds?
in this webhook
it's suppose to ping myself
not showing my id
you cant ping anybody in the embed title
oh i see
then i need to set in authot
*author
thought that is not the title
it's the author
whatever that is, you cant put mentions in here
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)
oh so maybe in footer?
!d discord.Embed.set_author
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.
i doubt it you can
you can for sure in the description or in fields
You can't ping anyone in embeds for that matter. You can only mention users in descriptions or field values



