#discord-bots
1 messages ยท Page 1015 of 1
this guy way talking inappropriately about 2.0 the last time aswell
not the first time
installed a new one discord.py and here is such a mistake what to do ?
bot.load_extension(f'cogs.{filename[:-3]}')
RuntimeWarning: Enable tracemalloc to get the object allocation traceback```
I'm confused on how to use followups with interactions
with what exactly?
Can someone explain. Basically, I'm trying to have 2 different embeds send after a user clicks a button
alright
!d disnake.Interaction.send
await send(content=None, *, embed=..., embeds=..., file=..., files=..., allowed_mentions=..., view=..., components=..., tts=False, ephemeral=False, delete_after=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message using either [`response.send_message`](https://docs.disnake.dev/en/latest/api.html#disnake.InteractionResponse.send_message "disnake.InteractionResponse.send_message") or [`followup.send`](https://docs.disnake.dev/en/latest/api.html#disnake.Webhook.send "disnake.Webhook.send").
If the interaction hasnโt been responded to yet, this method will call [`response.send_message`](https://docs.disnake.dev/en/latest/api.html#disnake.InteractionResponse.send_message "disnake.InteractionResponse.send_message"). Otherwise, it will call [`followup.send`](https://docs.disnake.dev/en/latest/api.html#disnake.Webhook.send "disnake.Webhook.send").
Note
This method does not return a [`Message`](https://docs.disnake.dev/en/latest/api.html#disnake.Message "disnake.Message") object. If you need a message object, use [`original_message()`](https://docs.disnake.dev/en/latest/api.html#disnake.Interaction.original_message "disnake.Interaction.original_message") to fetch it, or use [`followup.send`](https://docs.disnake.dev/en/latest/api.html#disnake.Webhook.send "disnake.Webhook.send") directly instead of this method if youโre sending a followup message.
its the same thing as discordpy. just use the embeds kwarg
when I do followup.send it says unknown webhook
@brave forge It literally says you need to await the coroutine
the traceback would give you knowledge
can you send the tb?
Sure
it raised a NotFound exception i suppose?
Yeah
chill
thats weird because the method should start a webhook and im not sure how that would raise an error
Ignoring exception in view <AcceptChallenge timeout=180 children=1> for item <Button style=<ButtonStyle.success: 3> url=None disabled=False label='Accept?' emoji=None row=None>:
Traceback (most recent call last):
File "/Users/ellalbrys/PycharmProjects/EconomyDiscordBot/venv/lib/python3.10/site-packages/discord/ui/view.py", line 413, in _scheduled_task
await item.callback(interaction)
File "/Users/ellalbrys/Dropbox/Mac/Documents/GitHub/EconomyDiscordBot/Cogs/DebuggingCommands.py", line 59, in challenger_accept
await interaction.followup.send(embed=participants[key], view=RPSButtons(entitled_user=key))
File "/Users/ellalbrys/PycharmProjects/EconomyDiscordBot/venv/lib/python3.10/site-packages/discord/webhook/async_.py", line 1539, in send
data = await adapter.execute_webhook(
File "/Users/ellalbrys/PycharmProjects/EconomyDiscordBot/venv/lib/python3.10/site-packages/discord/webhook/async_.py", line 211, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10015): Unknown Webhook
it does raise an error yes but it doesnt show how
you too @slate swan, we are here to help people not critisize them
not sure when i did?
line is ```py
await interaction.followup.send(stuff...)
dont see how i critisize the person
because hes been in these channels being toxic to most regulars here and not reading basic tracebacks that say it all which i literally helped him even after he said i should shut up
Lol sorry to bug okimii, but could you take a look at the thing i sent above
Like I don't have to create a webhook to use a follow up
You have issues with migrating to 2.0 especially the cog loading part.
no no the method does create a webhook
Okay, that's what I thought
yeah
Taking time and the ambition to look at the page will help you a lot.
Of course if you don't read it or try anything, it won't help you.
Oh yeah I remember switching all my cogs to async
A little confusing since I'm still learning python lol
The migration page explains everything in details on how it works
More than this we can't do.
if you would just read the traceback๐
Maybe don't be so offensive in your messages?
if they're toxic call the moderators, simple
As OI previously said, more than this detailed description of the changes we cannot do.
then why dont you do it?
Read his name lol
It doesn't matter. Your way of talking is offensive and makes people not want to help you.
There is nothing wrong with the site. It actually shows you exactly how to switch your cogs over to async
So that you don't run into errors like the one you're getting
๐คทโโ๏ธ
The site gives more information, with examples, than anyone can give
it would be nice if you would handle the situation
Simply take the time to read it, and apply it to your code.
๐ฟ
So uhh, anyone know why I can't send a followup to my interaction
im not really sure how the webhook wouldnt be found as it was just created so sorry๐
No worries, just asking around
cheers ๐ป
As I've said multiple times more detailed than that it's not possible. They have examples, look at them.
If you really don't understand anything - you should start by learning more Python before doing a bot. Since as you can see it's not made for newcomers as it can be quite complex depending on your knowledge.
More than that we unfortunately can't do.
the only thing that was like this for me are paginators
Yerlikaya with the drip๐ณ
the dpy asyncgenerator method
why are you cussing in every message
"i know this language" bro the traceback has the solution for your problem ๐๏ธ๐๏ธ
await bot.load_extension(...)
should learn about asyncIO, d.py uses it
sifte and yerlikaya reading the traceback๐ณ
and btw it needs to be in a coroutine!
or else it would raise something like this await cannot be used outside of a coroutine
Hence the migration tutorial/guide with clear examples.
yep
which can be done when you subclass the bot class and just use setup_hook or just create a task
Anyways it's 1am, time to do some other stuff 
go to sleep
wdym by one team btw?
huh
oh
wdym = what do you mean
what teams?
yeah im a bit confused
show code
You need to enable the message content intent both in code and the developer portal.
oh right
Consider using slash commands though.
!d discord.Intents.message_content
Whether message content, attachments, embeds and components will be available in messages
which do not meet the following criteria:
โข The message was sent by the client
โข The message was sent in direct messages
โข The message mentions the client...
i forgot that change in 2.0
yeah you would need to use this^
^
Anyone have a guide on optional parameters for slash commands
yeah why use bitwise or
dpy
whats a XOR
XOR is ^
ah
| is a bitwise OR
yeah
~ is bitwise NOT
what
thats something i didnt know haha
!e
x = 10
print(~x)
@slate swan :white_check_mark: Your eval job has completed with return code 0.
-11
there should be examples here https://github.com/Rapptz/discord.py/blob/master/examples/app_commands/basic.py
That for me?
yeah
how does that work
and what does it do that it returns negative 11
!rule 4
4. Use English to the best of your ability. Be polite if someone speaks English imperfectly.
10 in binary is 1010
~1010 -> -(1010+1) -> -1011 -> -11 in decimal
๐
wow how do you know this?
<@&831776746206265384> The user has been toxic for the past hour(s) I've sent a report but now it's going too far.
like jeez thats allot of knowledge in that mind
Do lots of stuff in my free time about cyber security, hence I learn a lot.
mhm wow thats very cool
!mute 419481276765175808 12h Take a break. Please stop being rude.
:incoming_envelope: :ok_hand: applied mute to @brave forge until <t:1651404121:f> (11 hours and 59 minutes).
The ~ returns the complement of the number in case you're interested in the magic
thats cool
like what?
sure
!discord.history
!d discord.TextChannel.history
async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.10)") that enables receiving the destinationโs message history.
You must have [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.
Examples
Usage...
yh ty
Use your member object
Try it again
Why put ctx.author in a member variable
Also you use your object that you have
Not the default one
how would i see if an imae is present in a message?
!d discord.Message.attachments
A list of attachments given to a message.
to add to that
you can get the first attachment in the message with message.attachments[0]
How to display an error that the button is obsolete and no longer works?
then you can check the content_type attribute
which is a string with the media type (MIME) of the attachment
e.g 'image/jpeg'
How would I return a variable from an interaction
Like if a button is clicked, how would I set a variable to be true and then check for that variable

Does anyone know how to return a variable from a button callback?
Like if there are 3 buttons and each has a number, how would I update a variable to be equal to the number of the button
U should be able to read the label of the button from the callback, and set whatever the label is to a variable
so im trying to create a way to send a message depending on the number i send after my initial command
basically, if i send ".base ci+op" i want it to send a custom message, if i send ".base ext" i want it to send a dif message
but for the life of me i cannot think of how to do it, on_message just keeps popping into my head and its not really what im looking for
just use if, elif and else statements or just use commands which are better
yea i wanna use commands but i dont really know how to setup if i saw ci+op for it to send a completely dif thing
It doesn't seem like VoiceClient.is_paused is correctly reflecting whether the audio is paused or not, any ideas?
while audio is playing it is evident that it is hitting the NOT case for is_paused meaning it indicates that it is not paused
Your operating system failed to retry the network connection, causing it to time out. This problem can happen when there is a faulty network adapter, slow wired links, or weak signals.
Please be patient
shoudln't this send one of them instead of the whole list or did i do a stupid?
i used a diff way of making a bot before so i just kinda used that but changed to be the better way
does discord components require intents ?
be patient
someone'll figure it out, i can't help ya though, idk what it even is
you're fine
What are you trying to do Natixe?
Try it and see.. and this question is more suitable for #python-discussion
I was saying that you didn't do anything wrong, not if you you were doing good, sorry for the confusion
The "in" keyword does not work how you think it works
it also checks in strings lmao
just have to override __contains__, i think
I think it treats strings as a list if I'm not mistaken
I'd be more likely to try a string method like .contains() iirc
also if "http" in s: checks if it is a link, which contradicts the print statement
?
yep per docs using in keyword is a fine solution
and if you're trying to prevent http links as pydis says not in is the way
async def meme(ctx):
list = ['https://preview.redd.it/h3t4aac5vi981.jpg?width=640&crop=smart&auto=webp&s=f750bf1529363da544dc7cb7b6dfe008427fe7c5', 'https://preview.redd.it/x8h3nisq7j981.jpg?width=640&crop=smart&auto=webp&s=b347113c4726232525b7ea14c72182488640707c', 'https://cdn.discordapp.com/attachments/505507861724659714/928035898694701056/Screenshot_20220104-152253_Discord.jpg', 'https://cdn.discordapp.com/attachments/923407458095996928/927350325759864932/4ubzo6dmtc981.png', 'https://cdn.discordapp.com/attachments/923407458095996928/926202129260093440/video1.mp4', 'https://cdn.discordapp.com/attachments/505507861724659714/928037256894242876/f158fe3c2372a0d5b789f932d6eeb74831182e31b53c91ef85afe7f2d4caa563_1.png', 'https://cdn.discordapp.com/attachments/200710164934819840/928011190020485130/271086585_10221444521844836_6814480215424879651_n.png', 'https://cdn.discordapp.com/attachments/505507861724659714/928037675070550046/0858ec920e21e5777e6079558515a14f814ad672.png', 'https://cdn.discordapp.com/attachments/923407458095996928/926202081277276160/video0_1.mov', 'too bad,die']
await ctx.reply(random.choice(list))``` shouldn't that send just one instead of the whole list, it keeps sending the list instead and im not sure how to fix it
Replace "http" in link with "http" not in link
command so that my bot sends out one of the links in the list when you say "!meme"
you're overriding the built in list
s = "https://mdrr.tki.com"
if "http" not in s:
print("Message is clear !")
rename list to list_
yes, that @slate swan
list is a really bad name for a list, as pydis mentioned it overrides the list class in python
you should use descriptive names
more detail is better than less detail
it just has a couple commands as its just a bot for me and my friends
use names that if you had to pick yours out of a list of many different variables you'd know what it is and does at a glance
Both
thx
I know, it's still important to follow good coding practices, especially not overriding a basic datatype like list inadvertently
you'll save yourself a lot of trouble if you just always name things well even if it's just for you and friends
also, better to learn to be better, you might not know this but Software Engineers make $$$$ if you can do it well ๐ might as well start practicing now haha
Thx, i just ripped the code from my older bot and changed the LIST to list not realizing it would mess it up. I'll try to remember that next time
even LIST is not a great name, it doesn't really follow naming conventions for python
you could call it meme_list or something
even that is better
because at least you know what kind of list it is, or what the list is intended to contain
i almost never actually code anything, i've only ever wanted to just makes bots so i never go to far out of learning discord.py
walk?
well all the same, better to learn to do it well and reap the rewards ๐ Names are an easy change, just make it a habit that you name things descriptively
I will
Is it working now btw? Just to double check
oh
What does it do or say Natixe?
what's the output
If you mean me, yeah
Awesome ๐
That code works
I just tested it on my end Natixe, it does what you intended it to do lol
!e ```python
s = "https://mdrr.tki.com"
if "http" not in s:
print("Message is clear !")
else:
print('sadface hyperlink')
@ebon island :white_check_mark: Your eval job has completed with return code 0.
sadface hyperlink
!e ```python
s = "htt://mdrr.tki.com"
if "http" not in s:
print("Message is clear !")
else:
print('sadface hyperlink')
@ebon island :white_check_mark: Your eval job has completed with return code 0.
Message is clear !
thats not really a good practice.....?
!rule 7
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
I mean, if you jus write http the message is gonna be detected as a link holding message
We were just taking their code and demonstrating how to make it do what they intended
its better to
if any(word in message.content.lower() for word in ("https://", "http://")): ...
before I head to sleep, anyone have any idea why VoiceClient.is_paused is returning false even when the audio is paused?
You should make an issue https://github.com/Rapptz/discord.py/issues/ @ebon island
not you
wrong reply
ig you call bot.db before it's been set?
can i restart my bot w jishaku?
There is a default help command
the lib comes with a default help command. do bot.remove_command("help"). that should fix it
can i put it anywhere?
should use the kwarg
The help command implementation to use. This can be dynamically
set at runtime. To remove the help command pass None. For more
information on implementing a help command, see Help Commands.
just set it to None
help_command=None in ur bot constructor
for the kwargs option
Basically, when instantiating your bot, just do bot = discord.ext.commands.Bot(help_command=None, command_prefix="whatever", ...)
yeah
thanks, that fixed it
np
btw is that exception new?
hwat
because a while back i remember the commands would just overwrite each other
yes
no
ctx.add_reaction() not working on 2.0 is it changed?
Install git https://git-scm.com/
that's not a thing in discord.py
how do i add reactions then?
message.add_reaction(...)
how much time will this take ?
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 429 Too Many Requests (error code: 0): You are being blocked from accessing our API temporarily due to exceeding our rate limits frequently. Please read our docs at https://discord.com/developers/docs/topics/rate-limits to prevent this moving forward.
1~ hour for it to wear off
how's
use subprocess/sys/os
I'm quite confused, I keep getting discord.errors.ClientException: ffmpeg was not found. within my tmux session
Although I have pip installed it and imported it
getattr((bot:=getattr(__import__("importlib").import_module("discord.ext.commands"),'Bot')(command_prefix='^',intents=getattr(__import__('discord'),'Intents').all())), 'command')(name='quack')(lambda ctx:(await ctx.send('quack')for _ in '_').__anext__())
๐ฟ
it's not a python package
yes it is?
ffmpeg is something you need to install on a website
it's not
why'd it let me pip install it then
because someone made a package called ffmpeg
yeah and thats what i was using
cool, but that's not what you're supposed to install
this is what you're supposed to install https://ffmpeg.org/
and how would I install it that in a vps
sudo apt install ffmpeg
i dont have the exit codes rn but you can try searching
you can
idk i use sys.exit
Are there any dpy 2.0 tutorials?
and this is all I need?
yeah ig
I never use linux so I got no clue about the commands
does ctx.voice_client.stop() work?
How do I check if the channel im in is in a certain category when doing acommand
is this dpy 2.0?
i think it is
How can I stop bot voice?
How to assign a role on an interaction?
!d discord.VoiceClient.stop
stop()```
Stops playing audio.
!d discord.Guild.get_role
get_role(role_id, /)```
Returns a role with the given ID.
Changed in version 2.0: `role_id` parameter is now positional-only.
ty
can I use atrribute errors for an error handler
b = bot.get_channel(933866247760793611)
print(b.id)
if discord.CategoryChannel.name == b.name:
await ctx.send('work')
else:
print('not correct category')
why wont this work
!d await interaction.add_roles(role)
x
someone pls help
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.
Bruh why are u printing id
U already have that
Bro
That's wrong code
i get no error it just prints not correct category even tho its in the right one
why did u use discord.CategoryChannel.name
ok so how do i fix?
What do u want?
i want this scommand to only weork in certain categories
idk but that snhouldnt matter, it should work
Wait I'll send u the code
ok
Is that ID the ID for a channel, or for a category?
category why
Just wondering...
Ok
Because you could've been comparing a text-channel name to a category-channel name
yeah i tried id as well and it didnt work
b = bot.get_channel(933866247760793611)
print(b.id)
if ctx.channel.category.id == b.id:
await ctx.send('work')
else:
print('not correct category')โ
``` ig not sure
ok lemme try that
B is a channel right
B is a channel in that category
Any one
no b is the category
then use B.id
yes now it works
thanks bro
I edited
What's the problem
thanks very much @slate swan
๐
Sadge
I solved
Second too late to steal glory
..
Instead, your glory got sealed
๐
Inside my duck
Have you forgotten setting up the message content privileged intent
Bruh after wondering for like 10 minuets why I was getting a KeyError with a bridgecommand, I realized my command's name parameter was capitalized (no-no in slash commands)
Isn't that only for on_message and other events
Oh well technically commands do internally use on_message events
Enable it
!d discord.Intents.message_content
Whether message content, attachments, embeds and components will be available in messages
which do not meet the following criteria:
โข The message was sent by the client
โข The message was sent in direct messages
โข The message mentions the client...
This giant Traceback
when I ctrl-c to exit my bot
and I don't think it has KeyboardInterrupt in it...
ctrl c is KeyboardIntertupt
You didn't await something?
I know. I'm saying the traceback didn't acknowledge KeyboardInterrupt
Well...
Oh lol I read it wrong
@tasks.loop(seconds=30)
async def logs_dumper(self):
_parent_dir = os.path.abspath(os.getcwd())
async with aiofiles.open((_parent_dir + os.sep + "log.txt"), "at") as logs:
await logs.write(("\n".join(self._temp)))
if self._temp:
await logs.write("\n") # Newline to append next set of logs in `_temp`
self._temp = []
@logs_dumper.before_loop
async def before_logs_dumper(self):
await self.bot.wait_until_ready()
@logs_dumper.after_loop
async def on_logs_dumper_cancel(self):
if self.logs_dumper.is_being_cancelled() and len(self._temp) != 0:
await self.logs_dumper()
And the last few lines of traceback:
Traceback (most recent call last):
File "C:\Users\Me\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 116, in __del__
self.close()
File "C:\Users\Me\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\Users\Me\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 750, in call_soon
self._check_closed()
File "C:\Users\Me\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 515, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
sys:1: RuntimeWarning: coroutine 'Loop._loop' was never awaited
hi cocaine 
Ryuga found a way to do with by editing the source file of discord.py
@paper sluice show
Lol
Yes
Yes
You could always switch to disnake
@(bot:=getattr(__import__("importlib").import_module("discord.ext.commands"),'Bot')(command_prefix='^')).command(name="quack")
async def quack(ctx): await ctx.send('Quack');bot.run('token')
Best attempt
i said a command not a whole bot kek
It is a command
bot.run?
@(bot:=getattr(__import__("importlib").import_module("discord.ext.commands"),'Bot')(command_prefix='^')).command(name="quack")
async def quack(ctx): await ctx.send('Quack')
Why couldn't you ignore that
what happened?
mine better ๐ณ ```py
bot.add_command(
commands.Command(
asyncio.coroutine(
lambda ctx: ctx.send("๐"), "quack"
)
)
)
Invalid
not invalid
Ours are more esoteric so ours better
I mean, is your bot verified?
no
Yes
mine less bytes so it's better
Just enable the intent then ยฏ_(ใ)_/ยฏ
Esoteric doesn't care about performance or less bytes
then?!!!
๐
enable it within your code too
They did
ok?
then what would be the issue?
less bytes is still better
Commands not working
do you have an error handler and if you do, do you raise the error which isnt ever handled?
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
just telling you that this is the problem
Yeah
property display_avatar```
Returns the memberโs display avatar.
For regular members this is just their avatar, but
if they have a guild specific avatar then that
is returned instead.
New in version 2.0.
Doesn't show though
Nice
yeah cz url is a property for the avatar asset
?
is member author a thing?
getattr((bot:=getattr(__import__("importlib").import_module("discord.ext.commands"),'Bot')(command_prefix='^',intents=getattr(__import__('discord'),'Intents').all())), 'command')(name='quack')(__import__('asyncio').coroutine(lambda ctx:(await ctx.send('quack')for _ in '_').__anext__()))
we dont need to edit src with this one
member = interaction.author
role = await discord.Guild.get_role(id)
await member.add_role(role)```
interaction has no attribute author
what can I do?
its interaction.user
just make one :P
Means is there any free course?
huh? free course for what?
Botinfo?
do you know how to python?
No
Sift says his code is better cause less bytes
where is it?
ty
@paper sluice
um, he didn't define bot, no imports..
what's wrong with this?
(getattr((bot:=getattr(__import__("importlib").import_module("discord.ext.commands"),'Bot')(command_prefix='^',intents=getattr(__import__('discord'),'Intents').all())), 'command')(name='quack')(__import__('asyncio').coroutine(lambda ctx:(await ctx.send('quack')for _ in '_').__anext__())));bot.run(token)
ok now this is a full one liner with bot.run
Challenge was to only make a bot command with only 1 line of code
did already :p
Get rid of role_id=
It's a positional-only argument, meaning it only works if that's the argument you pass in at index [whatever] (in this case, it only works if you pass it in as the first argument)
this is one line it seems like 3 in discord
We should make a bot that fully runs only on 1 line
just paste that in ur IDE
Like a bot with multiple commands and events
id= or role_id=
we just have to repeate this thing (name='quack')(__import__('asyncio').coroutine(lambda ctx:(await ctx.send('quack')for _ in '_').__anext__()))
How about events
๐
we will edit the on_event deco instead of commands.command ....
Why are you using discord.Guild
Use your own guild object
how
Your own guild object
how do I do it
how do I create my own guild object
Either by the context
commands.context.Context.guild.get_role(1234567890)
message.guild.get_role(1234567890)
any examples?
commands.context.Context why?
ctx.guild.get_role(1234567890)
# or
message.guild.get_role(1234567890)
!d discord.ext.commands.context.Context
class discord.ext.commands.Context(*, message, bot, view, args=..., kwargs=..., prefix=None, command=None, invoked_with=None, invoked_parents=..., invoked_subcommand=None, ...)```
Represents the context in which a command is being invoked under.
This class contains a lot of meta data to help you understand more about
the invocation context. This class is not created manually and is instead
passed around to commands as the first parameter.
This class implements the [`Messageable`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable "discord.abc.Messageable") ABC.
in that case, "for educational purposes"
can I do
interaction.guild.get_role(124235236346)```
or
channel.guild.get_role(1234567890)
What library you using?
dpy 2.0
class discord.Interaction```
Represents a Discord interaction.
An interaction happens when a user does an action that needs to be notified. Current examples are slash commands and components.
New in version 2.0.
!d discord.Interaction.channel
The channel the interaction was sent from.
Note that due to a Discord limitation, DM channels are not resolved since there is no data to complete them. These are PartialMessageable instead.
!d discord.Interaction.guild
property guild```
The guild the interaction was sent from.
Why is there still this error
!d discord.Interaction.guild
property guild```
The guild the interaction was sent from.
ye it works
place role id there
(12412535)
inside the tuple
Why are you doing interaction.channel.guild?
Just do interaction.guild...
both works fine
It's just redundant
then #esoteric-python is best
dont make another () just place id inside get_role(2124125)
Bruh I'm not suggesting do lambda functions, I'm just saying...
that was a joke
ye it was a typo
ohk
Do I have to add id=
No
no
No
It's a positional-only argument, as it keeps telling you
Adding the id= or role_id= would make it a keyword argument, not a positional one
!intents do u have the required intents on?
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
.
ye
uh wait
Adding the id= or role_id= would make it a keyword argument, not a positional one
ic
so what should I do?
you can write positional arguments as keyword arguments too

If it says it's a positional-only argument, that means you cannot pass it in via a keyword like id or role_id. It only depends on the order you're passing your arguments in. Since it is accepting it first, literally just do interaction.guild.get_role(1234567890)
Not a positional-only argument tho...
I did
And did it run?
!e
def add(num1, num2):
return sum((num1, num2))
print(add(num1=3, num2=2))
@slate swan :white_check_mark: Your eval job has completed with return code 0.
5
its a positional argument
now add a / in the end
no

!e
def s(d):
print(d)
s(d=2)
well, you can , one should, but I was just trying to prove that it works
@slate swan :white_check_mark: Your eval job has completed with return code 0.
2
nvmd
!e
def spam(eggs: int, bacon: int, /):
print(f"Spam: {spam}")
print(f"Bacon: {bacon}")
spam(1, 2)
spam(bacon=2, spam=1)
@brisk dune :x: Your eval job has completed with return code 1.
001 | Spam: <function spam at 0x7f0b8fcdbd90>
002 | Bacon: 2
003 | Traceback (most recent call last):
004 | File "<string>", line 6, in <module>
005 | TypeError: spam() got some positional-only arguments passed as keyword arguments: 'bacon'
role is returning None as it could not be found in the bot's cache
you should rather make a getch
:< imagine using disnake
channel = bot.get_channel(id) or await bot.fetch_channel(id)
getch lowkey sounds better than fetch atm
yeah
disnake dont have getch :<
it does, for member/user
!d disnake.ext.commands.Bot.getch_user
await getch_user(user_id, *, strict=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Tries to get the user from the cache. If fails, it tries to
fetch the user from the API.
for msg?
lmao getch actually exists
wow
it doesnt, since fetch and get are both methods for different objects
cool
role instead of channel?
yes, sorry
see that yellow line
oop?
no
ik python
ye ik that's why I said it won't work
put ur bot instance
are u using class
role = self.client.get_role(id) or await self.client.fetch_role(id)
#replace client with bot if you have it defined as bot
commands.command() with a SELF is indicating that its a cog
uh ye
didnt saw that
..
embed on interactions looks good
yes?
yes
ok I will try
ye then add self
It doesn't have an attribute fetch_role or get_role
bot
Do I have to add guild.get_role?
@slate swan
yes
bot doesn't have an attribute guild
Do I have to write
interaction.Guild.get_role(id)```
interaction.guild.get_role
you cant await get_x methods, you have to await fetch_x methods
wdym?
I have this in ON_ready event
async with aiosqlite.connect('cogs.main.db') as db:
async with db.cursor() as cursor:
await cursor.execute('CREATE TABLE IF NOT EXISTS afk (user INTEGER, guild INTEGER, reason TEXT)')
bot it doesnt create table
File "C:\Users\Akai\AppData\Local\Programs\Python\Python38\lib\site-packages\aiosqlite\core.py", line 102, in run
result = function()
sqlite3.OperationalError: no such table: afk
Huh
role is None
it doesn't exist?
it doesnt exist
how should I get the role id
to assign to uesrs
it's simple sql database, but there's alot of ways to do this it's not really hard
elaborate
anybody help me?
https://stackoverflow.com/questions/72070513/discord-py-discord-slash-libary-cogs-error-handling
my problem.
no offence, but why are you still using an external library?
for keys in logs2.keys():
RuntimeError: dictionary changed size during iteration
<
im trying to dump when this is running in loop
or is that your own library?
probably your dictionary's values are being modified when you're iterating through it
how do i fix
ye i mentioned
you are updating the dictionary....?
@tasks.loop(seconds=1)
async def timer(self):
with open("giveawaytime.json") as f:
logs2 = json.load(f)
for keys in logs2.keys():
ye
hm, the issue is, the task is running every second and iterating through the file, so this means, whenever you run a command that updates the file, it will change the data within the json file hence modifying the length of the root dictionary within the file, hence, this will error at one point of time, and then work fine after that
ok how do i fix
dont use json files?
or handle the exception
ill go with 2 option
exception
Use a actual database
DUDE why are u opening file loop
just open it once before ur bot starts
update the dict
and write once just b4 bot stops
like
async with bot:
async with open(...) as file:
bot.file = file
await bot.start()
Using someone's lavalink is risky?
wait, you can open files using that?
I mean, dont you need to use something like aiofiles
ya u do
ur using dpy 2.0 right?
nope
oh.
i think u can do that with that too, it may not be async though
no, it doesnt work
uh im editing the file too?
Guys guys pls help me.
I need like when my bot joins a server i want it to give me the link of the server
do u have to update the file every second?
F
its a giv cmd
to store the time
im adding it when the bot is online
use the on_guild_join event and grab one of the channels of the server and create an invite link of it and dm it to yourself
No
Thats not what i meant
....?
um just make a global dict, and update the file like every five mins or something, file io is pretty expensive in terms of time taken
but thats what you wrote ๐
5 min late giveaway
Like
I want it to say
I joined guild name "this is name"
Guild members : 69420
Guild invite :
add 5 min + to the time?
I have the first two
so it balance?
thats what I said.....
5 mins is just a rough estimate, do it like every 30 seconds or something 1 second is too much
How do u make the bot Fetch a channel id
Creating an invite link without the owner's consent is a privacy breach and can get both your account and your bot terminated. Don't do it.
20 sec enough?
Oh ok sorry i didnt know
!d disnake.ext.commands.Bot.fetch_channel
await fetch_channel(channel_id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a [`abc.GuildChannel`](https://docs.disnake.dev/en/latest/api.html#disnake.abc.GuildChannel "disnake.abc.GuildChannel"), [`abc.PrivateChannel`](https://docs.disnake.dev/en/latest/api.html#disnake.abc.PrivateChannel "disnake.abc.PrivateChannel"), or [`Thread`](https://docs.disnake.dev/en/latest/api.html#disnake.Thread "disnake.Thread") with the specified ID...
i mean if u make ur dict global, u can just refer to that, then u can write to the file if u really need to store it even after the bot is shut down @slate swan
um ok ill try
why
?
get ๐๐ฟ
fetch ๐๐ฟ
do u know whats the difference between get and fetch
ofc
get() get from cache
sparky
yes
I don't think you have to explain it to me
..
no
my get doesnt work it return None
well, for performance you can just check if something is in the cache before fetching it

use or
get_channel will not return None with the correct id unless you manually disabled channels intents
no?
question me
my id is correct my intents are enabled then why it return none
when im using get()
it's not in the cache then
but works with fetch?
bru
Fetch it if it's not in the cache
@dusky pine
im noob in python
there was probably an update discord-side which your bot didn't update to the cache?
Nope, discord.py implements the cache, not discord
:( im not flexing , (i dont have anything to flex)
this doesn't correspond to what I said
discord.py also updates the cache on_guild_join()
in relation to guilds and channels of them
@heady sluice
hey im having a problem with importing discord for some reason it is saying that discord is not installed when it is, any clue how i can fix this? ive already tried unistalling and redownloading it to no success
I have a house, something's in it but it doesn't work
security it doesn't want to leak details about that person ๐ฟ
How did you install discord.py?
pip install discord.py?
there are plenty of things you could've messed up there and I'll never know
pip install -U discord.py
ya
Can it see the channel?
make sure your python interpreter is correct
should 3.9.5 work?
it gets the channel object from the cache based on id
ur url might not be correct the, do u get any error messages @slate swan
Oh yeah forgot about get gets from the cache
fetch also iirc puts the channel in the cache after it made an API call
still no success
pip install discord
in the terminal type py -m pip install -U discord.py
pip3.9 install discord
will work for u
you don't know which pip his path is on
should I uninstall all dependencies first?
No
JUst type that into the terminal
k
if you specifically tell to use the 3.9 pip it will work
cuz this is where he launches the code
ok
unless he doesn't have pip for 3.9
ok
which would be weird
well i did it and restarted VScode but no success

your pip is on 3.10
your python interpreter is 3.9
In your terminal do py main.py
either
pip3.9 install discord.py
or
change your python interpreter
it should work, if it doesn't then idk
pycord?
discord.ui.Button(style=discord.ButtonStyle.link, label="aaaaa", url="https://google.com")
hm nice
bruh
you add the buttons to the View
view = SelectView()
view.add_item(discord.ui.Button(style=discord.ButtonStyle.link, label="aaaaa", url="https://google.com"))
await ctx.respond(embed=embed, view=view)
!d discord.ui.View.add_item
add_item(item)```
Adds an item to the view.
This function returns the class instance to allow for fluent-style chaining.

add to the view ๐คฆ
running code is not bad advise ๐
bruh its a normal thing to do
even though i havent try it before
anyways im also here to ask question lol
i added events into my bot's code but it now can only react to events
the commands dont work
is it new?
cuz i didnt have that before the discord py update
the commands still works before that happened
its been there for some time now
^
im a linux user and i just saw the traceback in the terminal
it says no file or directory ask ./cogs
but i have every cogs in the folder
could you do ls and show the output?
maybe the directory really isn't there lmao
can u show the traceback too
Because you're not in the bot's directory
^
or whatever python you're using lmao
python2 ๐
did ShouldIgetDiscord get it tho
they already got discord though
no, the error
also i am curious on to what that theme is
replit theme and its pretty good lol
answer waht
"how do i make bot lol"
i just type that in terminal?
the message was deleted, the question stays
I think so
on the topic of themes i'll just share mine because i want fame
vs code already did this
@dusky pine DMs
anyone know how to disable a select menu on callback?
Nah
Edit it on callback
that doesnt work?
Not in that directory, no
that is what everyone has been telling me, but no one has told me how to edit it on callback
!d discord.Interaction.edit_original_message use this
await edit_original_message(*, content=..., embeds=..., embed=..., attachments=..., view=..., allowed_mentions=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the original interaction response message.
This is a lower level interface to [`InteractionMessage.edit()`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.InteractionMessage.edit "discord.InteractionMessage.edit") in case you do not want to fetch the message and save an HTTP request.
This method is also the only way to edit the original message if the message sent was ephemeral.
huh
can i change it in vs code
probably
hmm ok
biiig font
self.disabled = True
await interaction.edit_original_message(view=self)
:sadge:
i just did that in vs code and it showed my files and the cogs folder
Okay good, that means you're in your bot folder
I know what you're thinking and I don't like it
wut?
Now try doing python main.py
unix based system or windows?
selectview in a wheelchair
i don't understand, and i don't wanna
back to moneylaundering
๐คจ
it's a fave pastime
it can run but cant react to commands
can we not bring up that thing again
then that's your bot's problem i think
comma
,add item
!send @slate swan 69m
You typed a comma, not a dot
for child in self.children:
child.disabled = True
discord banned my bot for some reason :/
np lol check again before asking
Thanks lad
uh, what was your bot doing?
API spam
yep
then that
did they send you an email?
do i change events to listen?
type in the console โKill 1โ and restart
for mehs_child in self.children:
mehs_child.disabled = True
it's prolly ratelimited
i don't know what you mean by that
change @bot.event to @bot.listen
oh no no tthat
k lemme try
I'm 15...
why?
to the emaill i use for discord or the one i use for repl?
that's not how you listen for events
also, the name of the function matters
age doesnt have anything to do with actions
the one you used to create teh bot
back on topic
yeah and im 13 who asked
do you have children
dat worked, thanks
lmao
its not same?
someone here before told me to change it and it worked
Good
!ot
Off-topic channel: #ot2-never-nesterโs-nightmare
Please read our off-topic etiquette before participating in conversations.
i tried it twice before u told me, and then i tried it again and it worked lmao
well you can try that
Ok lmao
I hate y'all
i'm starting to get confused
I love you
um how do i add a check in my view
dont worry, I hate you too :)
I love you too <3
do i have to add () after listen?
BACK ON TOPIC
k thx
bro
hate you again
im not saying to you
Your an exception as itโs a self roast in your user
I love you
!ot
Off-topic channel: #ot2-never-nesterโs-nightmare
Please read our off-topic etiquette before participating in conversations.
This is a rollercoaster of emotions
ill cut the power
[a link](https://google.com)
We are tryna conversate
but I wanna get on topic ๐ญ
Then I would just stay at โI love youโ
""
guys please this is not discord bot talk anymore
await #discord-bots.get_on_topic()
ill rain missiles
.topic
:(
makes it a comment?
what counts as unique
It has a fucking ASCII dick generator fr
Ok ok calm down
@commands.has_permissions(kick_members = True)
youre doing it wrong, its supposed to be
@bot.slash_command()
@commands.has_permissions(kick_members=True)
wtf
@bot.slash_command()
@commands.has_permissions(kick_members=True)```
imagine letting everyone kick everyone
im suing you for copying me
im suing you for suing me
!d discord.ext.commands.has_guild_permissions would be better ig
@discord.ext.commands.has_guild_permissions(**perms)```
Similar to [`has_permissions()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.has_permissions "discord.ext.commands.has_permissions"), but operates on guild wide
permissions instead of the current channel permissions.
If this check is called in a DM context, it will raise an
exception, [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage").
New in version 1.3.
:reverse:
await interaction.edit_original_message(content=f"{self.values[0]} selected for {self.server} by {self.ign}", view=None, embed=None)
anyone know why this isnt working?
(happens on callback of a select menu)
it shows "unknown webhook" error
stop spamming that
I'm not spamming it
u are
yes you are
yes u r
u r
ok fine
that doesn't even make sense
yeah that's correct
.
hi is there anything to check in view or i need to add it
show the full traceback
i haven't seen that error before
so i downloaded the python 3.9.5 interpreter but after i change the interpreter from 3.10.4 and in the terminal run python it still says version 3.10.4
dont abuse
!d discord.Interaction.edit_original_message
await edit_original_message(*, content=..., embeds=..., embed=..., attachments=..., view=..., allowed_mentions=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the original interaction response message.
This is a lower level interface to [`InteractionMessage.edit()`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.InteractionMessage.edit "discord.InteractionMessage.edit") in case you do not want to fetch the message and save an HTTP request.
This method is also the only way to edit the original message if the message sent was ephemeral.
hmmm
hi is there anything to check in view or i need to add it
Traceback (most recent call last):
File "C:\Users\Harshit\AppData\Local\Programs\Python\Python39\lib\site-packages\nextcord\ui\view.py", line 359, in _scheduled_task
await item.callback(interaction)
File "c:\Users\Harshit\Desktop\ticket-bot-kareem\commands\menu.py", line 90, in callback
await interaction.edit_original_message(content=f"{self.values[0]} selected by {self.ign}", view=None, embed=None)
File "C:\Users\Harshit\AppData\Local\Programs\Python\Python39\lib\site-packages\nextcord\interactions.py", line 330, in edit_original_message
data = await adapter.edit_original_interaction_response(
File "C:\Users\Harshit\AppData\Local\Programs\Python\Python39\lib\site-packages\nextcord\webhook\async_.py", line 189, in request
raise NotFound(response, data)
nextcord.errors.NotFound: 404 Not Found (error code: 10015): Unknown Webhook
@quaint epoch
Unknown webhook
instead try await interaction.message and edit
im using nextcord
why?
uhh... its good?
i don't think it was able to find the message
is the meesage already deleted?
