#discord-bots
1 messages · Page 78 of 1
no, its a reaction object, you can get the message using reaction.message
so in my check id want
if msg.author == bot.user
and how do i check for the emoji author
to make sure its not the bot
no, because assuming you did msg = await ctx.send(...) is going to be always true its kinda useless
you can check reaction.author
and to make sure its not a bot, you can do reaction.author.bot, it returns True if it is, else False
code?
def del_check():
if reaction.author == bot.user
im prob overlooking somethin so simple
you didn't take reaction and use in the function parameter
what do you mean by valid term?
its just a normal variable
well currently its deleting the msg when the bot reacts
i wonder if im oversimplifying a step
ok i got this
async def del_check(reaction):
if not reaction.author == bot.user:
await msg.delete()
await bot.wait_for('on_reaction_add', check=del_check)
what am i overlooking
Uh
well, thats what you told it to do...
:l
Hey, I'm working on a bot in py-cord and have some code in the following format:
class MyView(View):
def __init__(self, user):
self.user = user
@MySelect(a)
async def callback(self, select, interaction):
...
class MySelect(Select):
def __init__(self, page_count):
super().__init__(options=[...])
The issue is on line 5, @MySelect(a). a is a variable which I can get from the user attribute that I assigned earlier, but I need self for that and can't get self outside a function.
How can get the data from user and use it in the decorator?
TL;DR: Need to access an instance attribute in a decorator inside the same class.
this doesnt delete anything tho
It'll be weird if it did
try reaction.message.delete()
you can try something simple like
def check(reaction, user):
return not user.bot
reaction, user await bot.wait_for("reaction_add", check=check)
await msg.delete()
you probably added the reaction before the wait for
you can't do it with decorators, although you can do this
self.user = user
self.callback = MySelect(user.a)(self.callback)
i added the bots reaction first yeah
so its not going to work...
what
why are you deleting the message when the bot reacts
im not, im tryin to delete it when anyone else reacts
just somehow i managed to make it so the bot deleted it b4
isnt anymore
well, you are not, you are doing reaction.author == bot.user
== checks if left and right are the same
u can just do != then delete
i got
def del_check(reaction):
if reaction.author is not bot.user and reaction == '⚔️':
msg.delete()
await bot.wait_for('on_reaction_add', check=del_check)
don't use is not
it think it was reaction_add
on works as well
and you need to await delete()
fixed
wdym?
wait_for looks for bot dispatched event for reaction its reaction_add
on_reaction_add should work also
so u mean i need to put reaction_add as a para instead of just reaction ?
hang on i got somethin mixed up there
its fine u can run it no change needed
ok so where is this wrong
async def del_check(reaction):
if not reaction.author == bot.user and reaction == '⚔️':
await msg.delete()
await bot.wait_for('on_reaction_add', check=del_check)
thats the same as doing not (reaction.author == bot.user and reaction == ':crossed_swords:')
just use != and remove the not
still missing something
Use len to count the guild members
@bot.event
async def on_guild_join(guild):
if len(guild.members) < 20:
await guild.leave()
rip
Also, you don't have to use bot.get_guild
if i put a print under the check, shouldnt it print something if its called?
coz its not
i wonder if the issue is in the wait_for part of it
well, look at the code above it and apply some logic
at this point, you are just asking us to write it for you
im doing plenty of my own fiddling
You can compare IDs if that does anything
Checks can't be async
And event is "reaction_add" not on_reaction_add
i changed that prior to having to go do something else; now it just crashes instead of simply not working lol
at least it’s something smh
where do i put the delete part then
You can use asyncio.create_task or have wait_for in a loop and break on a favorable condition
Where are you using this wait_for, in a command?
to delete a message when u add a specific reaction to it
ive sent a msg, added an emoji, now i want to delete said message when someone reacts to it with that same emoji
Specific reaction on a specific message or any message?
this
That isn't checking on a specific message so i was curious
If it's not for a specific message you could just use an event
i also want a timeout feature that clears x msg after say 5 mins if someone doesn’t close it before that
sec
msg = await ctx.send(f"...")
await msg.add_reaction('⚔️')
async def del_check(reaction):
if reaction.author != bot.user and reaction == '⚔️':
await msg.delete()
thats what i got rn
You'll also need to check if the message being reacted to is the same as the one you reacted to
But yeah checks can't be async, easy solution would be to use asyncio.create_task
idek how that one works
asyncio.create_task(coro, *, name=None)```
Wrap the *coro* [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine) into a [`Task`](https://docs.python.org/3/library/asyncio-task.html#asyncio.Task "asyncio.Task") and schedule its execution. Return the Task object.
If *name* is not `None`, it is set as the name of the task using [`Task.set_name()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.Task.set_name "asyncio.Task.set_name").
The task is executed in the loop returned by [`get_running_loop()`](https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_running_loop "asyncio.get_running_loop"), [`RuntimeError`](https://docs.python.org/3/library/exceptions.html#RuntimeError "RuntimeError") is raised if there is no running loop in current thread.
so where would this fit into what i got rn..?
Or if this is too alien, you could just call wait_for in a loop and break when you get the condition you want
You use it to execute message.delete() in the check
im not sure why its printing this in the callback
TypeError: del_check() takes 1 positional argument but 2 were given
what arguments does on_reaction_add give
dam
!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.
There's a search bar on the site
reaction and user
I see, so your check needs to have both those parameters
well now my traceback is
AttributeError: 'Reaction' object has no attribute 'author'
!d discord.Reaction.message
Message this reaction is for.
You'll want to use this, and then .author
Or if you want the person who reacted
Then you use the user argument
it doesnt like that
Wdym
AttributeError: 'member_descriptor' object has no attribute 'author'
I'm guessing you literally did discord.Reaction.message.author
Anyways, you can learn oop later
You need to check that user.bot is False, str(reaction.emoji) == "..." and reaction.message.id == msg.id
user.bot means any bot ?
Yes
dang
3 hrs of troubleshooting, googling and conversing, came down to 3 lines
im at 27hrs so far, and the bot isnt doing its job haha
i know that feeling...
yesterday i have read my code for like 16 times and im still on it, someone helped me to change my main from over 230 line to like 24 lines, and the bot isnt working
sheesh, thats some workover
the issue too that im not that good coding discord bot, it was my literal 27 hrs lol
i just started of a youtube tutorial
but like, i had a python class last Sem
where was the link i can copy the code to?
Sheesh, help. Can't quite make this to work:
@bot.listen
async def on_ready():
Message = await bot.fetch_guild(943462265317912576).get_channel(960392445135290408)
Shuma = await bot.get_or_fetch_user(user_id="786978127816818698")
await Shuma.send("Bot Online!")
await Message.send("Bot Online!")
I'm trying to make the bot send a DM to me or Send a MSG to a channel after it becomes Online but it just doesn't work. No errors in the terminal though. All my cmds also work fine.
Why are you using bot.listen?
It's listening for the bot to become online?
Use bot.event instead
Don't they work the same?
@listen(name=None)```
A decorator that registers another function as an external event listener. Basically this allows you to listen to multiple events from different places e.g. such as [`on_ready()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_ready "discord.on_ready")
The functions being listened to must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.10)").
Example...
bot.listen()
I mean, the problem I'm facing here is that the bot won't send me a DM, nor does it send the Msg in the guild's specified channel
Also you're awaiting get_channel not fetch _guild
And why does your get or fetch take a str 
Put your ID as int in user_id
Actually, I didn't implement the channel thing yet lol. For now, I'm just trying to make the bot DM me. My code's like this
@bot.listen()
async def on_ready():
Shuma = bot.get_or_fetch_user(user_id="786978127816818698")
await Shuma.send("Bot Online!")
Oh, wait. lemme try
Nah, still doesn't work.
How is get_or_fetch_user defined
Try using bot.get_user
@bot.listen()
async def on_ready():
Shuma = bot.get_user(786978127816818698)
await Shuma.send("Bot Online!")
Works now. Thanks! I just awaited the variable
local error handlers yes.
Uhhhh
Need to edit the message with the new view
Hmm but i don't think command error handlers will matter, only on_error
points file: https://paste.pythondiscord.com/cewupuceli
main file: https://paste.pythondiscord.com/juqefekore
Uhhhhhhhh
Why do you have 2 setup functions?
I think it didn't show any errors on my code because I commented it out Kek
I was working on getting the bot to DM first before the channel
What cmd should I start with if I want to get started with learning databases and storing data? Or is it not recommended if I don't fully understand around 40% of Python Basics yet?
Gotchu, so I guess, for now, OOP & Async + familiarizing basics. Alright, will probably read about them later. Thanks for the feedback! ✔️
Do u think Danny uploaded a mirror package, named discord so that none can upload a malicious with that name?
async def interaction_check(self, interaction) -> bool:
if interaction.user.id != interaction.author.id:
await intraction.response.send_message("You cant use dis kid", ephemeral=True)
return
else:
return
any help? I dont want my buttons working for anyone other than the one who started the command
@naive briar
Nice
Dude, stop pinging randoms
@maiden fable
This should be working. What's not working?
Just add something in the else block
interaction.author
I need the author@of the embed
What embed
Tbh, @vocal snow is more experienced and will be more than happy to help you (:

interaction.author is not a thing. it's interaction.user
why would i compare interaction.user to interaction.user though
exactly the point, why would you compare the user who invoked the interaction with its author, its literally the same thing
No
u not getting it@Lol
Uh
yes sure. imagine not understanding the diffence between command author and an interaction'a author.
basically i want to get the id of the person who clicked on the button.. Then the one who started the command & compare them
if they not the same return
You have to store the ID of the user in the view
since u can’t understand Lol
why do you think the command author's data will be stored in the interaction?
R u using pychord
you need to set that up yourself
pass the interaction or ctx depending on the command to the view which u subclassed
I think u shld use pychord
^
I wanted to add a giveaway command for my bot
but I've got an error
AttributeError: 'async_generator' object has no attribute 'flatten'
I searched this error on API reference, but I couldn't fix this error
I use this code
users = await new_msg.reactions[0].users().flatten() this is the error section
!d discord.Reaction.users
async for ... in users(*, limit=None, after=None)```
Returns an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.10)") representing the users that have reacted to the message.
The `after` parameter must represent a member and meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.
Changed in version 2.0: `limit` and `after` parameters are now keyword-only.
Examples
Usage...
There are examples there
I wouldnt really call it an "async iterator object" as it may cause confusion as an "async iterator object" doesnt exactly exist, over something like a genexpr that would return an object named generator, but async iterator is a bit more clearer, i would say, as you would be referring to an object that implements __aiter__() and __anext__() that would return an awaitable object. I'm not saying you're wrong but you're not exactly correct either.
bro did u type all that just to say my explanation wasn't complicated enough 💀
Lmao
okimi moment
https://docs.python.org/3/glossary.html#term-asynchronous-iterator doc calls it an async iterator object tho
its clearer and more understandable to explain it as async iterator
is there a way for me to make a thread with discord.py ?
or i must use the threading lib
what for?
i mean, what do you need to thread
well long explanation but, im trying to get the bot to createchannels while simultaneously sending things in the channels
that's why asyncio is there, for concurrency
although if you're attempting to make a spam bot, it isn't going to work
if im making a spam bot i assume there is threading needed?
with the threading lib
the problem here is i cant make it make channels and simultaneously spam things in those channels while making them with one command
we don't help with spam bots here
ah, no im not making the bot so i can harm discord servers or anything like that
me and my friends use the bot for shits and giggles in our server although i understand your reason so
👍
Where?
"asynchronous iterator... An object"
Its more of a term as shown in the link, "async iterator" would be a term used for any object that implements the given methods in the documentation
ok

bruh is there way to extract a specific pokemon sprite from this png using python?
do you have a library that you're using?
nope
like, you just want to extract them into their own separate files
yep
you could use something like Pillow
o
then slice the image up into some size
ic
alr i will do it rn thank you
np
!pypi image-slicer
nice making some pokemon game?
💀 i was trying to make a pokemon bot
was?
there are like a thousand pokemon bots already
oh ok
still i will make a pokemon-based bot 💀 anyways have a good day
gl have fun u never know u might make something new innovate 😉
😳 ty
Anyone know why it isn't printing 2?
do u want all the records?
Yes
u can just leave lenght none as default for that
to_list?
u can ask me if u are stuck anywhere 👍 I like pokemon too 😉
aight
yeah
yeah so u can do await bot.db.find({}).to_list(length=None)
guys i'm new at dpy2.0 so idk if much has changed but whenever I try using bot.user.avatar.url, it outputs as "NoneType object has no attribute 'url'"
what am I doing wrong?
hey guys , i want to make a discord bot. i have list of quotes. i want the bot to send it every morning 8:30 am on one of the server channel. how can i do this? im complete noob in making discord bot but i know python
does the bot have a custom avatar?
no I'm pretty sure it's a default avatar
the one discord gives you if you don't have any
then you should use the display_avatar attribute instead of avatar
!d discord.User.display_avatar
property display_avatar```
Returns the user’s display avatar.
For regular users this is just their default avatar or uploaded avatar.
New in version 2.0.
the bot died?
thanks, I'm new to dpy2 so I don't know if something has changed
I think I've heard something changed in the way you use bot.run or bot.login
nvm my internet is slow af
something that has to do with async maybe
but I can't seem to find it anymore so idk
check the migrations
dpy has them listed
i think he needs to change cog loading
i'm not using cogs rn
use run
but yeah it did mess up my cogs with other projects
and it's something I haven't fixed yet
if u use start u will have to setup ur own logger
okok
not necessary tho
discord.utils.setup_logging(*, handler=..., formatter=..., level=..., root=True)```
A helper function to setup logging.
This is superficially similar to [`logging.basicConfig()`](https://docs.python.org/3/library/logging.html#logging.basicConfig "(in Python v3.10)") but uses different defaults and a colour formatter if the stream can display colour.
This is used by the [`Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") to set up logging if `log_handler` is not `None`.
New in version 2.0.
there is a more detailed example in dpy github examples 🗿
why a context manager to just run the bot?
guys i dunno whats wrong here it used to work, but maybe you could help?
'dict' object has no attribute 'Cog'
await instance.start() directly is totally usable
You should only use it when running other processes in the same file so it closes which most people just kill the process
still not needed
I still dont like the context managers usage with bots tbh
what does a ctx manager even do to a bot
no, like what does those functions do in the commands.Bot impl
If were talking about what happens when __aenter__ and __aexit__ get called, well, When the context manager opens it opens a websocket connection with the gateway and when closing the lib checks if the bot is in a voice channel it disconnects the bot from the voice channel and then it disconnects from the gateway
Iirc it's dynamic and gets set by @unkempt canyon by the activity or amount of users in the channel or past history with discussions in a certain time frame
How to you guys setup your json file to be updated?
I have a bot with virtual points, and i want to make sure every member starts with 0 points.
I dont want to make it manually by adding a new command
Is it possible?
how can i get options in hybrid commands
Anyone know why?
How do I make the bot change only one permission in a text channel and not affect the others permissions?
!d discord.TextChannel.set_permissions
await set_permissions(target, *, overwrite=see - below, reason=None, **permissions)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sets the channel specific permission overwrites for a target in the channel.
The `target` parameter should either be a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role") that belongs to guild.
The `overwrite` parameter, if given, must either be `None` or [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/latest/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite"). For convenience, you can pass in keyword arguments denoting [`Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions") attributes. If this is done, then you cannot mix the keyword arguments with the `overwrite` parameter.
If the `overwrite` parameter is `None`, then the permission overwrites are deleted.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this...
how to send in specific channel after button pressed?
getting this error
AttributeError: 'NoneType' object has no attribute 'send'```
How do you define channel2?
channel2 = client.get_channel(channel_sent_in)
Then the channel was not found
But it works for other function
Im confused why it wldnt work
Can you show the code of the command?
Ofc 🙂
await interaction.response.send_message(f'Approved and sent to #{channel_sent_in}!')
embed_approve = discord.Embed(title=f"{channel_sent_in} ping!", color=discord.Color.purple())
embed_approve.add_field(name='Message: ', value=f"{message.content}")
embed_approve.add_field(name='Sent in by: ', value=f"{message.author}")
embed_approve.set_footer(text=f'Provided by Donks#1048 • {current_time}')
channel2 = client.get_channel(channel_sent_in)
await channel2.send(embed=embed_approve)```
shld i change to fetch then?
Let me try that now 🙂
In channel_id: Value "staff-spam" is not snowflake.```
Got this error now
you have to pass in an integer and staff-spam isnt an int
like this? channel2 = client.get_channel(channel_sent_in) or await client.fetch_channel(int(channel_sent_in))
depends if channel_sent_in can be converted to an integer
channel_sent_in = message.channel
I think you can just use channel_sent_in because it's already a channel 
message.channel.id straight away...
let me send my whole code
as might have to change bits around
async def on_message(message):
button1 = Button(label="Approve!",style=discord.ButtonStyle.green)
button2 = Button(label="Disapprove!",style=discord.ButtonStyle.red)
view = View()
view.add_item(button1)
view.add_item(button2)
message_channel = message.channel.id
user_id = message.author.id
channel_sent_in = message.channel
# Check if message has content
if message.content is not None and message_channel == 640107609801752577 or message_channel == 1011257952142888970:
# Add message content to list
msg_list.append(message.content)
print(msg_list)
channel = client.get_channel(1017118446284177419)
embed = discord.Embed(title=f'Message detected in #{channel_sent_in}', color=10181046)
embed.add_field(name='Message: ', value=f'{message.content}')
embed.add_field(name='User: ', value=f'{message.author}')
embed.set_footer(text=f'Provided by Donks#1048 • {current_time}')
await channel.send(embed=embed, view=view)
async def button_callback(interaction):
await interaction.response.send_message(f'Approved and sent to #{channel_sent_in}!')
embed_approve = discord.Embed(title=f"{channel_sent_in} ping!", color=discord.Color.purple())
embed_approve.add_field(name='Message: ', value=f"{message.content}")
embed_approve.add_field(name='Sent in by: ', value=f"{message.author}")
embed_approve.set_footer(text=f'Provided by Donks#1048 • {current_time}')
channel2 = client.get_channel(channel_sent_in) or await client.fetch_channel(int(channel_sent_in))
await channel2.send(embed=embed_approve)
async def button_callback_2(interaction):
await interaction.response.send_message(f'Disapproved and warned user')
await interaction.followup.send(f"-warn {message.author.mention}")
button1.callback = button_callback
button2.callback = button_callback_2```
Why do you want to get the channel again?
To see out of two channels , which one they sent in
Like the message_channel and channel_sent_in?
Yea so message_channel to monitor two channels and see if message sent in it
message_channel is just the ID of channel_sent_in
I want to put my bot in 2 discords and if an event happens, say "!ping" i want to my bot to send "pong" to both discords.
how would I achieve this?
both discords in what channel?
Say channel.id(1) or discord A and channel.id(2) in discord B
you could iterate through bot.guilds, filter out other discords, send message to other channel
how would i fix then? 🙂
would "bot.guild.get_channel(123)" work even if bot is in 2 different guilds?
no
would I first have to get the guild?
Ah, well
yes
Just replace
channel2 = client.get_channel(channel_sent_in) or await client.fetch_channel(int(channel_sent_in))
await channel2.send(embed=embed_approve)
with
await channel_sent_in.send(embed=embed_approve)
And I think you're fine
doesn't work for what I want (or I did wrong)
i just want to change one permission and it changes all
by "changes all" I mean like this:
I wanted to keep the permissions that the member had already set and just change the permission of send_messages, for example
I think you can do something like
og_perms = channel.overwrites_for(member)
og_perms.update(send_messages = False)
await channel.set_permissions(member, overwrite=og_perms)
it works! thank you v much
Basically, you just edit the send_messages permission of the member and apply it without editing the other permissions
one more question, how would i go about warning the player if i press the disapprove button?
got this so far but dnt work
async def warn(ctx, member: discord.Member, *, reason="Not Specified"):
channel = client.get_channel(1013425592898703470)
if member == ctx.author:
await ctx.send("You cannot warn urself!")
else:
em = discord.Embed(title="**WARNED**", description=f"{member} was warned because: {reason}", color=discord.Color.red())
em2 = discord.Embed(title="**WARNED**", description=f"You have been warned because: {reason}", color=discord.Color.red())
await member.send(embed=em2)
await ctx.send(embed=em)```
await interaction.response.send_message(f'Disapproved and warned user')
await interaction.followup.send(f"-warn {message.author.mention}")```
It worked. ty
Anyone know whats wrong
from nextcord import commands
class Bot(commands.Bot):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.persistent_views_added = False
async def on_ready(self):
print('Logged in as ' + bot.user.name)
print('-----------------------------------------------')
bot = Bot(command_prefix="-", intents=nextcord.Intents.all())
@bot.slash_command(description="Test!", guild_ids=[989497807595507752])
@commands.has_permissions(administrator=True)
async def apply(ctx):
await ctx.guild.create_text_channel(f"{ctx.user.name}-apply")
embed = nextcord.Embed(
title="Your Application has been created!",
description="Go to the channel that has been created for your application <#>"
)
await ctx.channel.send(embed=embed)
bot.run("token")```
Error:
C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\health_check.py:23: DistributionWarning: discord.py is installed which is incompatible with nextcord. Please remove this library by using pip3 uninstall discord.py
warn(message, DistributionWarning, stacklevel=0)
Traceback (most recent call last):
File "c:\discordBot.py\main.py", line 2, in <module>
from nextcord import commands
ImportError: cannot import name 'commands' from 'nextcord' (C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord_init_.py)
Read the error message :D
"Please remove this library by using pip3 uninstall discord.py"
lmao no two or 3 timing between discord api libs 🤣
already tryed
nextcord.ext for commands
Hey, does somebody know how to create slash commands?
which library?
any actually
it's personal preference, have you created any bot before this one?
except pycord
💀
dont use pycord
py-cord 🫂
and which library did you use
you can create slash commands with discord.py too
see the second message in the channel's pins
Ah okay
I would prefer hikari and hikari-lightbulb but that's comparatively harder to work with, discord.py is ok too
maybe i should try it hikari...
it just even sounds bad for me
Im currently not at home
nice
hikari yes
I have to read it later
when i have time...
try creating slash commands with hikari alone, you'll have fun getting a headache
right, it's the best guide I have. Can't give anything more than that
not like the best as in universally the best 💀
autocorrect
lol
cant find the problem
from nextcord.ext import commands
class Bot(commands.Bot):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.persistent_views_added = False
async def on_ready(self):
print('Logged in as ' + bot.user.name)
print('-----------------------------------------------')
bot = Bot(command_prefix="-", intents=nextcord.Intents.all())
@bot.slash_command(description="Test!", guild_ids=[989497807595507752])
@commands.has_permissions(administrator=True)
async def apply(ctx):
await ctx.guild.create_text_channel(f"{ctx.user.name}")
embed = nextcord.Embed(
title="Your Application has been created!",
description="Go to the channel that has been created for your application <#>"
)
await ctx.channel.send(embed=embed)
bot.run("Token")```
error:
Ignoring exception in command None:
nextcord.ext.commands.errors.CommandNotFound: Command "apply" is not found```
it's a slash command, and you are executing it as -apply
i tryed both
and what happens if you execute a slash command?
nothing just wait 2 sec need to try something
@bot.slash_command(description="Test!", guild_ids=[989497807595507752])
that was the problem
im blind
why is this not warning a user when dissaprove button pressed?
async def warn(ctx, member: discord.Member, *, reason="Not Specified"):
channel = client.get_channel(1013425592898703470)
if member == ctx.author:
await ctx.send("You cannot warn urself!")
else:
em = discord.Embed(title="**WARNED**", description=f"{member} was warned because: {reason}", color=discord.Color.red())
em2 = discord.Embed(title="**WARNED**", description=f"You have been warned because: {reason}", color=discord.Color.red())
await member.send(embed=em2)
await ctx.send(embed=em)
async def button_callback_2(interaction):
await interaction.response.send_message(f'Disapproved and warned user')
await interaction.followup.send(f"-warn {message.author.mention}")```
first of all it's @client.command()
with brackets
and second i dont even see any buttons here, only callback
there is
let me send code for them
async def on_message(message):
button1 = Button(label="Approve!",style=discord.ButtonStyle.green)
button2 = Button(label="Disapprove!",style=discord.ButtonStyle.red)
view = View()
view.add_item(button1)
view.add_item(button2)
message_channel = message.channel.id
user_id = message.author.id
channel_sent_in = message.channel
# Check if message has content
if message.content is not None and message_channel == 640107609801752577 or message_channel == 1011257952142888970:
# Add message content to list
msg_list.append(message.content)
print(msg_list)
channel = client.get_channel(1017118446284177419)
embed = discord.Embed(title=f'Message detected in #{channel_sent_in}', color=10181046)
embed.add_field(name='Message: ', value=f'{message.content}')
embed.add_field(name='User: ', value=f'{message.author}')
embed.set_footer(text=f'Provided by Donks#1048 • {current_time}')
await channel.send(embed=embed, view=view)
async def button_callback(interaction):
await interaction.response.send_message(f'Approved and sent to #{channel_sent_in}!')
embed_approve = discord.Embed(title=f"{channel_sent_in} ping!", color=discord.Color.purple())
embed_approve.add_field(name='Message: ', value=f"{message.content}")
embed_approve.add_field(name='Sent in by: ', value=f"{message.author}")
embed_approve.set_footer(text=f'Provided by Donks#1048 • {current_time}')
await channel_sent_in.send(embed=embed_approve)
these buttons don't have any callback specified
button2.callback = button_callback_2```
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
let me send whole code
@client.command()
async def warn(ctx, member: discord.Member, *, reason="Not Specified"):
channel = client.get_channel(1013425592898703470)
if member == ctx.author:
await ctx.send("You cannot warn urself!")
else:
em = discord.Embed(title="**WARNED**", description=f"{member} was warned because: {reason}", color=discord.Color.red())
em2 = discord.Embed(title="**WARNED**", description=f"You have been warned because: {reason}", color=discord.Color.red())
await member.send(embed=em2)
await ctx.send(embed=em)
@client.event
async def on_message(message):
button1 = Button(label="Approve!",style=discord.ButtonStyle.green)
button2 = Button(label="Disapprove!",style=discord.ButtonStyle.red)
view = View()
view.add_item(button1)
view.add_item(button2)
message_channel = message.channel.id
user_id = message.author.id
channel_sent_in = message.channel
# Check if message has content
if message.content is not None and message_channel == 640107609801752577 or message_channel == 1011257952142888970:
# Add message content to list
msg_list.append(message.content)
print(msg_list)
channel = client.get_channel(1017118446284177419)
embed = discord.Embed(title=f'Message detected in #{channel_sent_in}', color=10181046)
embed.add_field(name='Message: ', value=f'{message.content}')
embed.add_field(name='User: ', value=f'{message.author}')
embed.set_footer(text=f'Provided by Donks#1048 • {current_time}')
await channel.send(embed=embed, view=view)
async def button_callback(interaction):
await interaction.response.send_message(f'Approved and sent to #{channel_sent_in}!')
embed_approve = discord.Embed(title=f"{channel_sent_in} ping!", color=discord.Color.purple())
embed_approve.add_field(name='Message: ', value=f"{message.content}")
embed_approve.add_field(name='Sent in by: ', value=f"{message.author}")
embed_approve.set_footer(text=f'Provided by Donks#1048 • {current_time}')
await channel_sent_in.send(embed=embed_approve)
async def button_callback_2(interaction):
await interaction.response.send_message(f'Disapproved and warned user')
await interaction.followup.send(f"-warn {message.author.mention}")
button1.callback = button_callback
button2.callback = button_callback_2
buttons callbacks should be set before adding the buttons to the view, and you are doing that after everything is done and the message is sent
and don't forget that if you are moving the button.callback = ... up, then you should move your callback functions up too, so they won't be referenced before assigement
yes i have done this 🙂
how would i now make it so when disapprove button clicked, it will execute the warn command
uhm, you really should not execute a command anywhere in your code...
how would i go about, warning the user then?
so ive got this discord.py bot on github, and i put it on heroku. it was written in 1.7.3 discord.py and i want to update it to 2.0, can i just update the requirements.txt file and change the code directly on github? will the changes be applied automatically on heroku?
i would exec the command somewhere myself tbh
but why not, I'm asking the reason
though I don't prefer doing that myself
how to add nsfw cmds in bot??
by making them
Hello guys i got question i wanna make my bot add user in ticket when i send his id or user automatique since im New in discord.py can u help me guys please
sure, what have you done till now
you just have to change channel's permissions
uff keeds how to make i am asking
what is keeds? and what type of answer are you expecting
you said you want to add nsfw cmds then make them and add them
Its a quite subjective general question which depends on abstractions
depends on what you mean by "nsfw", because discord doesn't have any "nsfw commands" implemented, so if you want to check the age or warn the user you have to do it yourself
also you can make a command so it could only be executed in nsfw channel
you probably mean the resources required by "how to make nsfw command"?
if yes, you're looking for some NSFW api, can google and find plenty of them
in discord.py there is commands.nsfw_only deco
could u plz tell me a gud one?
every api is not authentic for nsfw ones
?
no idea, just Google it
wdym, there are plenty of NSFW only APIs, use them?
it reminds me of an update by dank memer
,
wait a min lemme find it
we have very different nsfw meanings
we do
accidents happen with everything online, even discord API messes up often
I just realized I wasn't supposed to post that too
?
I wanna make bot when i send user name and tag he add him automatique in ticket
I dont know how do i make bot do it
$add command
you are importing from bot.py, you should just use import constants
same dir import
Example :
When i send user the bot add him in ticket
Roblox 😭
Bro is definitely scamming some little kids
?
I dont even play roblox
I got paid for it
You got paid before even coding
idk how that works
Hi master
hi
He said do bot for automatique trade or idk so im doing it
I think you wanna help him right @silk fulcrum

a discord bot for trading 💀
why can’t you just use a bot that’s already existing that does everything your asking 
Hunter is typing
I'm thinking... Why tf Dank Memer even needs too much money to run. Dude just buy a VPS for like 10-15 USD a month and you're all set. Imagine telling people you need hundreds of dollars a month to run a bot
Fr
You only need like 20USD a month which you can always buy offers or bundles, which include more time or performance
I’m hosting on aws for free
ok
😊
Tell that to Dank Memer and Droplet Development, who indirectly tell people they need hundreds of dollars a month
😭
How is a bot so hard to maintain? a single experienced person can maintain a bot like that with time, There only excuse is probably: "Inflation"
You know what i fucking mean
no, severe e-rash
😔😒
😔
😔
First time i get correct for using an incorrect word
Lmao
Hunter dont delete the message bro
Thats spelling kek
Did it so u don't feel bad just cz I corrected u
^^^
🫂
contextual english says you just posted a present tense verb for a past tense action
now he will feel worse cus you deleted it
ok
That was totally not my intention :D
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
Seriously lets stop fooling around
to!
Anyways, I'm happy being a bot dev. At least I don't get caught into these traps lol
why u so serious:(
He's andy v2
oh ok
Ill take that as a compliment
Question:
How can I turn an Emoji into a link? Somewhat like this (Image)
So far, I have this code:
@commands.slash_command(name="e-magnify", description="Makes an emoji larger.")
async def magnify_emoji(self, ctx, emoji:disnake.Emoji):
EmojiEmbed = disnake.Embed(title="...",
description="...",
colour=disnake.Colour(0x2f3136))
await ctx.send(embed=EmojiEmbed)
Or rather turning it into a link... How can I get the bot to get the link of the emoji?
If I can't reply today, I'll ask again tomorrow lol. Gotta do some assignments
!d discord.Emoji.url
property url```
Returns the URL of the emoji.
Ahh, ez as that. Gotchu. Thanks!
how can i ping roles
!d discord.Role.mention
property mention```
Returns a string that allows you to mention a role.
<@role_id>*
or <@your_role_id>
🐧
lmao
🗿
btw. Does the same apply to stickers?
thank you
!d discord.Sticker.url
The URL for the sticker’s image.
ok
hi okimii
I think dank memer's command usage rate was something like 30-100 commands/second they used to sell nsfw for 2$-30$/month
I'm not okimii?
Gotchu. Thanks again lol
it was included in their premium perk
when did I specifically greet you
:sus:
Who else gets assumed for no fucking reason theyre okimii?
vote em
your fault, should go back to inexistence
Indirect points smh
noid will vote you for fooling around and u will be thrown into ot2
So youre telling me not to exist?
Real mature on your part
together
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
lol
.topic
Suggest more topics here!
well balanced huh
ok
yes
Nice quarrel
nice pfp
Hey what happened to okimii
Idk
he quit discord and other socials
Gone into hiding, wouldn't blame him with the current Russian political climate
and I think a poweful vps was really required during those times of msg based commands and dank memer's hype
he's Russian?
no
No, he's an undercover Cia agent performing lawful operations in International airspace
wtf
Or just doesn't like social media
so cringe
cringw
reqwst
.uwu does this work here?
It just doesnt know the type?
Eh, still, even a VPS with 8 GB RAM and 3 CPUs costs only 20 USD a month (galaxy gate)
How do I get a Slash Command ID? I've tried bot.get_command(<String name>).id but HybridCommand has no attribute named id
And they got better deals if u need more RAM/CPU, so they charging soo much patrol is an overkill
from bot import Bot
from discord.ext.commands import Bot as _Bot # `Bot` is probably an instance of `commands.Bot`
Bot: _Bot
print(Bot)
Youre not using the Class thats not an error just a warning
I think you can set the root directory in a config file for your project, like pyproject.toml or something related to your env
Why private namespaces?
or go to bot/bot.py and set Bot: commands.Bot = commands.Bot(etc...)
It should
You havent answered my question
imagine not sub-classing 😔
If names collide you use a suffix with a _ and not a prefix of _
I think you can't import discord.ext.commands or from discord.ext.commands that way anyway
Why not?
I remember it raising an exception consistently on my machine
It should work
I imagine it should
Yeah, its just the accessing of a specific folder/dir
I know
ok
Wait it should only work if ext is a subpackage in discord
If it's a simple folder, it explains why it doesn't work
And why from discord.ext import commands does
Yes
you have a comma after channel_id
https://stackoverflow.com/a/64103291/17268995
Try this out
Anyone know how to make a bot edit a message the bot sent
!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 "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 "(in Python v3.10)") of [`File`](https://discordpy.readthedocs.io/en/latest/api.html#discord.File "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 "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 "(in Python v3.10)") of [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
You’ll notice this returns the sent message
is it possible to do with a message.reply
I believe that returns the sent message as well
A lot of discords CREATE endpoints will return the created resource
async def send_warning(user, reason, channel):
em = discord.Embed(title="**WARNED**", description=f"{user} was warned because: {reason}",
color=discord.Color.red())
em2 = discord.Embed(title="**WARNED**", description=f"You have been warned because: {reason}",
color=discord.Color.red())
await channel.send(embed=em)
await user.send(embed=em2)
@client.command()
async def warn(ctx, user: discord.Member):
await send_warning(user, 'my fancy reason')```
how to send first warning to channel?
as error is py await send_warning(message.author, f'Suggesting non-needed post for {channel_sent_in}') TypeError: send_warning() missing 1 required positional argument: 'channel'
I mean, you're literally accepting a channel argument and not passing it while calling the function either
class User:
name: str
_id: int
async def send_warning(user: User, reason: str, channel):
...
#calling it using
await send_warning(user, "fancy reason", channel_where)
how would i call it tho
how wld fix then thx 🙂
pass a channel argument when calling send_warning
not working hmm
uhh guys how to fix
"decouple.UndefinedValueError: SECRET_KEY not found. Declare it as envvar or define a default value"
how to fix this issue??
Guys I want to give a role when something happened (not member joined). Which event should I use? I tried on_ready and on_connect but it did not work.
Hey!
I have a leveling system but the level command is just erroring
Here is my code!
https://hastebin.com/suruhaline.sql
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
heres whats in users.json
{"755155481458114630": {"experience": 36, "level": 2}}
when something happens
What thing?
This whole code should be re-written, Its missing logic, good abstractions and code in general, a good actual database and non blocking tasks
I mean like when your money reaches $1000 I want to give a role to you
Or like rank system. When you text 100+ messages I want to give a role to you
Umm what are the ways to earn money? If you can tell some then I may find any easy way to do that
That can be done using on_message event, you need to store number of messages somewhere
Like you are starting with 100$ and you do some gambling and increase your money. When your money reaches 1000$ I want to give you a role for exp: "Rich".
Then what?
someone can help in #help-pretzel ?
It's an internal method
I don't really know much about it nor it's documented
it's at least syntactically valid
Okay
ill just send the full thing bc my brain died
Nice
@client.command()
async def redeem(ctx, key):
tokens = open(r"C:\Users\ewill\OneDrive\Desktop\DevScripts\PYFILES\tokens\keys.txt", "r")
used = open(r"C:\Users\ewill\OneDrive\Desktop\DevScripts\PYFILES\tokens\usedkey.txt", "r")
keylist = tokens.read()
redeemed = used.read()
if key in keylist and key not in redeemed:
await used.write(key)
await ctx.reply(f"`{key}`-is now redeemed.")
user = ctx.message.author
role = discord.utils.get(user.guild.roles, name="Buyer")
await user.add_roles(role, atomic=True)
ticket = await ctx.guild.create_text_channel(f"{ctx.author.name}#{ctx.author.discriminator}")
await ctx.reply(f"Ticket created #{ticket}")
await ticket.send(f"{ctx.author.mention} // `.send [YOUR MESSAGE]` // `This will delete in 60 seconds`")
await asyncio.sleep(60)
await ticket.delete()
elif key in keylist and redeemed:
await ctx.reply('`Token Already Redeemed`')
else:
await ctx.reply('`Token not found`')
Thank you 
elif key in keylist and redeemed
this is probably a gotcha
you mean
elif key in keylist and key in redeemed
let me check
bot still wont say anything
@client.command()
async def redeem(ctx, key):
tokens = open(r"C:\Users\ewill\OneDrive\Desktop\DevScripts\PYFILES\tokens\keys.txt", "r")
used = open(r"C:\Users\ewill\OneDrive\Desktop\DevScripts\PYFILES\tokens\usedkey.txt", "r")
keylist = tokens.read()
redeemed = used.read()
if key in keylist and key not in redeemed:
await used.write(key)
await ctx.reply(f"`{key}`-is now redeemed.")
user = ctx.message.author
role = discord.utils.get(user.guild.roles, name="Buyer")
await user.add_roles(role, atomic=True)
ticket = await ctx.guild.create_text_channel(f"{ctx.author.name}#{ctx.author.discriminator}")
await ctx.reply(f"Ticket created #{ticket}")
await ticket.send(f"{ctx.author.mention} // `.send [YOUR MESSAGE]` // `This will delete in 60 seconds`")
await asyncio.sleep(60)
await ticket.delete()
elif key in keylist and key in redeemed:
await ctx.reply('`Token Already Redeemed`')
else:
await ctx.reply('`Token not found`')
well. Put some logging messages or print statements and make sure it's running at all
is this a slash command?
do you have other commands that are working?
yeah i tried another command and it works
it started acting up
if key in keylist and key not in redeemed:
when i added this part
seems like boost bot 
no
ppl who use full path 😔
im selling pings in my discord server
less go
i just want it to work 
Just hardcode and hope for the best
people who use one drive 🗿
well one drives not too bad ig its good to have backups
slow af + resource consuming
And paid ;-;
People who never close files opened with open are sus
thats y use context managers for open ops
Or they have probably forgot that and then rewrite their whole program just cz there is a massive resource usage
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
!to
» microsoft-build-tools
» tools
» off-topic-names
None of this has anything to do with why his program isn't working. Yes, closing the file is a good idea, but don't they close at the end of the function anyway?
well i agree it consumes a lot of resources on bg 💀 but are there better options?
nope they still remain open
Btw looking at the path I have some bad suspects
whats the issue with your command tho?
how to make bot with oython
tokens
Idk whom we are helping. I just jumped into the convo 😅
What tokens
its like serial numbers
they get after buying
RrSnyx9aXU
oDM62ZQXsF
7Nkpp9IIpn
PtBVrRBVWv
TIUiPjep4t
looks like that
how to make bot with oython
sussy sus
dropbox, google drive
That's not some 3rd party thing right?
by learning python
Not python only
drive is fine but it stores it doesn't auto backup stuff not sure about dropbox
you gotta learn some basic python concepts
and then use a library like discord.py ( or it forks) , hikari, etc
noid just wants to refute whatever i speak 🥲
You take your python, feed it and then it goes(?) to learning courses. After it learns, it needs a brain implant so it can code, after that it will create a bot for you if it studied hard
I correct you so you can succeed in life
🗿
Maybe study up on literature or even better the whole language of English!
Want to get more out of Google apps at work or school?
...
idk i never tried
u come and teach me
I'm ok
that way we will code a discord bot in english
don't think one onedrive provides anything particularly that google drive doesn't
when you overheard "python is plain English"
English the programming language is terrible
i am just gonna go take a break 🥲🚶
shore
Noid am I doing good*
lolcode is better
queen elizabeth died 
Names start with capital letters and so do sentences.
what
⚰️
About 10 minutes ago
The Pal Street Boys say writing a name in lowercase is taking the pride of it away.
await used.write(key) here you are trying to write to a file object that you opened in read mode
But discuss in OT please
oh ok
Imagine doing Queen Elizabeth like that.
also
Queen Elizabeth did but not Queen Elizabeth ||
why u arguing then 💀
Terrible*
and then in 12345.777 seconds it turns that it is fake
that's a lot of seconds
when a variable is garbage collected, it calls the __del__ method of the file. This will close the file. If there are no references to a variable, its __del__ will eventually get called
yessir my bad 😔
Shes probably chilling in her room knowing she has retired
Obviously it is better to just close it explicitly though
that happens after the programme finishes running or is closed while its running the file is open
But I
import gc
gc.disable()```
consuming memory
what
rip
Memory leaks😩
Help my screen is blue for some reason 😢
Is it okay if I put it into sushi
no
But it has rice
fish have a bad effect on monitors
Oh okay
Fish makes a monitor act a bit fishy
shit happens, doesn't it 😔
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
Use ot channels for discussions that arent on topic!
ratio
i mean its not ancient times so atbest they gonna get a holiday at worst nothing happens 
yes that happens when the code exits, apparently that will happen after the execution of bot.run(), i.e when your bot stops running
completely missed it
I wasn't even reading the convo lmao
such a long token
that code....jeez
hey
please help me guys
nextcord.ext.commands.errors.MissingRequiredArgument: ctx is a required argument that is missing.
I'm getting this error
there is a self parameter i have. When i delete it the bot's work but i need that self parameter
what can i do?
why does the code not see the ctx parameter
could you show the rest of the code that is above this?
why are you using add_command?
you're supposed to load commands in cogs with bot.add_cog
if I don't type that command, I get a command not found error this time
def setup(bot):
bot.add_cog(Music(bot))
I already have
did you use load_extension?
good, that will add the command,no need to do it manually
But it says command not found this time
in your main file, bot.load_extension(filepath)
or with async if you're on 2.0
@client.command()
async def load(ctx, extension):
client.load_extension(f"cogs.{extension}")
await ctx.send(f"Loaded {extension}.")
print(f"Loaded {extension}.")```
client.load_extension(f"cogs.{extension}")
RuntimeWarning: Enable tracemalloc to get the object allocation traceback```
sir can you check dm
The method is a coroutine upon the new update of 2.0
why
what should i do here to get the fix
what do you understand from this line
RuntimeWarning: coroutine 'BotBase.load_extension' was never awaited
hint: it's asking you to await something
?
is there any listener to the audit logs of a guild?
Omg I am gonna lose my mind
kk
guys how can i add a role automatically when something happened (not member joined)
!d discord.Member.add_roles
await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")s.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
just call this when you want to
you can get the member with guild.get_member if you have an id
that is the point
what is the point
there is no event which does meet my request
you haven't told us what the request is
like reaching a point
you've only told us what it's not which doesn't narrow it down
what is 1000 point
like dollars?
ok, so you're storing that data yourself right
In sql yes
SQL*
aight
Its a term and is pronounced S-Q-L!
okay i got it
ignore okimi
Hes not even here
mhm
How can you ignore someone that isnt participating in a conversation?
guys can we get to the point?
not related to discord.py itself but I wanted to use it for a bot.
Is there a dictionary like data structure that would let me access an entry using 2 different keys like for example:
datastructure = {
"key1", "100" --- maps to ----> {entry 1}
"key2", "105" --- maps to ----> {entry 2}
}
so when I do
datastructure.get['key1'] or datastructure.get['100'] I would receive {entry 1}
datastructure.get['key2'] or datastructure.get['105'] = {entry 2}
and it can be assumed that there will never be conflicts with the keys
i couldn't find anything about this
so what's your db schema
there is a wallet, a bank and networth
ok but you're storing the member id right
yes
You can use duplicate values with different keys or you can make a dataclass which is handy when parsing something like a hashmap and converting it into a python object
and the guild id
no idea what a dataclass is but ill look into it. Thanks for the help 😄 is there something similar to that in java or cpp ? I'm very new to python
so you're storing user_id but no information of the guild, how will you get the Member then
!d dataclasses.dataclass
@dataclasses.dataclass(*, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False)```
This function is a [decorator](https://docs.python.org/3/glossary.html#term-decorator) that is used to add generated [special method](https://docs.python.org/3/glossary.html#term-special-method)s to classes, as described below.
The [`dataclass()`](https://docs.python.org/3/library/dataclasses.html#dataclasses.dataclass "dataclasses.dataclass") decorator examines the class to find `field`s. A `field` is defined as a class variable that has a [type annotation](https://docs.python.org/3/glossary.html#term-variable-annotation). With two exceptions described below, nothing in [`dataclass()`](https://docs.python.org/3/library/dataclasses.html#dataclasses.dataclass "dataclasses.dataclass") examines the type specified in the variable annotation.
The order of the fields in all of the generated methods is the order in which they appear in the class definition.
ah
in source code?
what
i'm not sure for Java or C++ as i'm not currently skilled enough
it's alright, thank you for all the help ❤️
Doesn't user_id already give member information?
no, it gives user information
every member has a userid
sounds like you want a multidict
store the guild id too bruh
then add roles to the member
with this
dude that is the p o i nt
which event or command does this thing
wtf are you talking about
you store user_id and guild_id
when user points >= 1000
bot.get_guild to get guild
bot.get_member to get member
member.add_roles to add roles
It behaves mostly like a regular dict but it may have several values for the same key and preserves insertion ordering.
Is this the one you are referring to?
I wanted the opposite thing, different keys pointing to the same value/row.
posting links arent against the rules right
i wasn't referring to a particular module, just the concept
not at all
okay
aah okay
but we doing things under @bot.command or @bot.event
Depends on what they direct to, as its content may break the rules and will most likely get deleted
which one should i use
it might be easier to just have an sqlite db in memory

ah okay
I once got banned for posting random link like amongus-is-sus.com
💀
I was just testing out link regex 😩
he do be kinda sussy tho
guys how do i make my bots every 7 hours send annoucement ?
IM NEW at discord.py so sorry
!d discord.ext.tasks.loop
@discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/latest/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
no no, the message wasnt directed at you!
i have question where do i past it ?
in which lines
I don't know enough about it to say that you're wrong. But this implies that none of the variables you create while your bot is running are ever garbage collected. Which would be pretty wild
Create some class with overridden __del__ and see if it gets invoked?
help*
@slate swan
is there a way to make that User 1 button be same width as User 2 .. more text button?
cause discord removes spaces
No
Unless you want to add a lot of 0 width chars
Which looks weird on different devices
im thinking about that but
i think making reference in message above buttons and then using numbers is better way
Paranoid
This chat does that to you
Constantly on edge for the next “intents is a required argument” question
NoneType attribute errors😏
“My commands don’t work no errors”
!d discord.ext.commands.has_role
@discord.ext.commands.has_role(item)```
A [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member invoking the command has the role specified via the name or ID specified.
If a string is specified, you must give the exact name of the role, including caps and spelling.
If an integer is specified, you must give the exact snowflake ID of the role.
If the message is invoked in a private message context then the check will return `False`.
This check raises one of two special exceptions, [`MissingRole`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") if the user is missing a role, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
Changed in version 1.1: Raise [`MissingRole`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")...
ty
async def notifier_channel(ctx, channel : discord.TextChannel):
I want this to have a error handling function incase they dont provide a text channel. How do I do that?
hey noid, can i make an exception like if has the role then continue
else: ctx.send?
the check() returns with errors
how do i add choice slash commands to my bot? like an option to choose from like: berry,fruit,egg,bananana that sort of thing
garbage collectors are not really reliable :p
Just catch MissingRole in a local error handler
what?
If a wrong object is passed a conversion error would probably be present, you can always have default values and a check
?
Use typing.Literal
from typing import Literal
...
@client.tree.comand()
async def food(interaction, opt: Literal["berry", "fruit", ...]):
await interaction.response.send_message(opt)
You can always lower the string you will use to check in an expression
how i can add 2 button in 1 message in discord.py v2.0?
is that how discord.py does it? weird impl as usual
do i put it here
In https://github.com/Rapptz/discord.py/blob/master/examples/app_commands/transformers.py they have many good examples
add the buttons to your view object using add_item and send the view
is the "Literal" in opt: Literal a variable?
A literal value
over a type
!d typing.Literal its a class in the typing Library
typing.Literal```
A type that can be used to indicate to type checkers that the corresponding variable or function parameter has a value equivalent to the provided literal (or one of several literals). For example:
```py
def validate_simple(data: Any) -> Literal[True]: # always returns True
...
MODE = Literal['r', 'rb', 'w', 'wb']
def open_helper(file: str, mode: MODE) -> str:
...
open_helper('/some/path', 'r') # Passes type check
open_helper('/other/path', 'typo') # Error in type checker
```...
why not just do
if message.content.lower() in words:
```?
i can but the berry/fruit thing by doing like Liter(choices) right

