#discord-bots
1 messages · Page 973 of 1
Some people are under the misconception that making it a coroutine function would make it suddenly not blocking
Still blocks
I find that generally people don't have that well of an understanding of asynchronous programming, it's more like "if it gives you an error, slap await in front of it""
Which is... distasteful
If your gonna do async, go all out
It’s pretty important to have an understanding, otherwise it would be like black magic
Yeah, that only hinders your learning
yes
just use an executor
yo guys how do I check if a member exists in a guild by uid
if id in [m.id for m in guild.members]: # a list of IDs of all the server members
return 'exists'
This is super in-efficient
Just check get_member
If Guild.get_member returns None the member doesn’t exist
Else it would return the member instance
Yes it’s a hash lookup
Makes sense
how do I create guild object I forgot lol
You don't
List comp would be O(n) and contains would also be O(n) so O(2n) yea
The library provides them for you
oh ok
ah yeah, makes sense
so I do get_member ?
Yes
Optional member object, yes
ok thanks
get_member() -> Optional[discord.Member]
what do I have to import fir guild
Hm?
undefined
I'm not following
is this just get_member or guild.get_member
It's a method of discord.Guild object, so it's guild.get_member()
who cares as long as it works
It’s not hard, and it saves computing time especially for a language like python
hole in cup, still holds water but still leaks
That's a questionable philosophy
sounds like something I'll hear in r/programminghumor
help?
@commands.group()
async def message(self, ctx):
await ctx.send("do !message create {text}")
@message.command()
async def create(self, ctx, *, text=None):
if text == None:
await ctx.send("text is required")
else:
await ctx.send(f"{text}")
it sends both do !message create {text} and text is required if i do !message create but i want it to send only the text is required message when doing !message create and text is required if doing !message only idk if this makes sense
Yup, makes sense; Add this check in your main command:
if not ctx.invoked_subcommand:
# do !message create {text} first
thank you!
Anytime
nah
this error doing my head in
https://caught-lackin-in-8k-by-cyberghost.cf/x8Ra9m2Q
def get_prefix(ctx:commands.Context):
conn = sqlite3.connect('./sql/ghost_bot.db')
c = conn.cursor()
c.execute('CREATE TABLE IF NOT EXISTS ghost_bot(guild_id TEXT,prefix TEXT)')
c.execute(f'SELECT ghost_bot WHERE guild_id = {ctx.guild.id}')
result = c.fetchone()
if result:
prefix = str(result[0])
if not result:
prefix = '.'
conn.commit()
c.close()
conn.close()
return prefix
looks likel somewhere you're using this get_prefix function, but you passed two argument instead of one
like*
I'm passing it where the prefix for the bot would be defined
as per the parameters that you've passed, it is ONLY suppose to get ctx argument
I dont understand where its getting the second param from though 
And that error shows every few seconds rendering the bot basically useless lol
show the code if u don't mind
i mean.. the place where you've used that function
What should i use to detect if a message is sent in any channel of a discord server
But from a specific server id
bot = commands.Bot(command_prefix=get_prefix, intents=intents)
- use message event
- check for the message channel (channel of that guild/server)
- do your stuff
hmm well..
just remove that py ... :commands.Context ig?
at this point anything is worth a try 
at least nothing wrong with trying ig :'/
lmfaoo
can ya send the whole traceback?
File "C:\Python310\lib\site-packages\discord\client.py", line 375, in _run_event
await coro(*args, **kwargs)
File "C:\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1279, in on_message
await self.process_commands(message)
File "C:\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1274, in process_commands
ctx = await self.get_context(message)
File "C:\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1173, in get_context
prefix = await self.get_prefix(message)
File "C:\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1089, in get_prefix
ret = await discord.utils.maybe_coroutine(prefix, self, message) # type: ignore
File "C:\Python310\lib\site-packages\discord\utils.py", line 617, in maybe_coroutine
value = f(*args, **kwargs)
TypeError: get_prefix() takes 1 positional argument but 2 were given```
what if it dont like the func name
File "C:\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1089, in get_prefix
ret = await discord.utils.maybe_coroutine(prefix, self, message) # type: ignore
specifically cos that
File "C:\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1173, in get_context
prefix = await self.get_prefix(message)
``` i'm thinking cuz of this lmao
nope name seems fine
cos i still get error when tryna execute any cmd
mayn I still gotta add a function to whitelist guilds so I can make a cmd for it 
i cant get past this prefix bs
u really didn't get any error stuff above this?
🤔 ** ** || i'm feeling brainless btw, lmao||
get_prefix takes in 2 args iirc, bot and message
that's not even in their code lmao
i renamed the func to _get_prefix
firstly ure still supplying it in your bot constructor, and secondly its not really needed
async def get_prefix(bot, message):
...
wdym its not needed, its how it fetches per server prefix from the sqlite file. Also why would I need the message param? how exactly does that help c.execute(f'SELECT ghost_bot WHERE guild_id = {ctx.guild.id}')
i meant u renaming it to _get_prefix from get_prefix isnt needed, and the 2nd param u provide is a message object and not a context object so u can just do message.guild.id instead
the first param (bot) doesn't need to be used, but needs to be passed
and the message param is required because get_prefix gets called on every message sent which the bot can see
ah yea thanks for clarifying, well lets hope this ends my troubles
I believe that worked but now its saying theres no column called prefix when in the line above its literally ```py
c.execute('CREATE TABLE IF NOT EXISTS ghost_bot(guild_id TEXT,prefix TEXT)')

do you have an sql file viewer?
does the column exist?
show error
Traceback (most recent call last):
File "C:\Python310\lib\site-packages\discord\client.py", line 375, in _run_event
await coro(*args, **kwargs)
File "C:\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1279, in on_message
await self.process_commands(message)
File "C:\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1274, in process_commands
ctx = await self.get_context(message)
File "C:\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1173, in get_context
prefix = await self.get_prefix(message)
File "C:\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1089, in get_prefix
ret = await discord.utils.maybe_coroutine(prefix, self, message) # type: ignore
File "C:\Python310\lib\site-packages\discord\utils.py", line 619, in maybe_coroutine
return await value
File "c:\Users\Admin\Desktop\Ghost-Utilities-Bot\bot.py", line 17, in get_prefix
c.execute(f'SELECT prefix WHERE guild_id = {message.guild.id}')
sqlite3.OperationalError: no such column: prefix
boutta yeet this laptop out the window XD
dont u also have to specify the table to select from...?
oh yeah
also cyber don't use f-strings inside of execute statements
How else do i pass {message.guild.id}?
its safe since its only the guild id
but yes its bad practice
c.execute('select prefix from ghost_bot where guild_id=?', (message.guild.id,))
Omg im a genius I thought it was that 
XD
I mean thanks
Traceback (most recent call last):
File "C:\Python310\lib\site-packages\discord\client.py", line 375, in _run_event
await coro(*args, **kwargs)
File "C:\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1279, in on_message
await self.process_commands(message)
File "C:\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1274, in process_commands
ctx = await self.get_context(message)
File "C:\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1173, in get_context
prefix = await self.get_prefix(message)
File "C:\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1089, in get_prefix
ret = await discord.utils.maybe_coroutine(prefix, self, message) # type: ignore
File "C:\Python310\lib\site-packages\discord\utils.py", line 619, in maybe_coroutine
return await value
File "c:\Users\Admin\Desktop\Ghost-Utilities-Bot\bot.py", line 17, in get_prefix
c.execute('SELECT prefix FROM ghost_bot WHERE guild_id = ?', (message.guild.id))
ValueError: parameters are of unsupported type
yes, I love errors
oh yea
uh in 1 element tuples u add a trailing comma and its str(message.guild.id)
str(message.guild.id)
the guild_id column is a text type
would it be better if I changed to int?
yes
much
BIGINT, sure because it makes the most sense
change it to BIGINT though
dont think sqlite supports bigint
and also its a good practice to add trailing commas to one elment tuples
nvm
instead of message.guild.id do message.guild.id,
i mean SQL does and SQLite3 uses SQL? 🤔
I would add this to mariadb but the stupid connector says refused despite connecting from a user thats whitelisted on all ips
I dont need to add str still do I?
would I add the comma inside or outside the brackets?
inside the tuple of course
Indeed sqlite only has integer type and all the others are just aliases to it. It has automatic field memory management or smth
I believe thats worked guys thanks so much!
yw
I would add a way to drop a row once bot leaves a guild but it seems a bit like a sticky one
Just put strict WHERE cond
thats easy
DELETE FROM guilds WHERE id = ...```
You always have time to remember it 👍
Ah yes
how hard would it be to port from sqlite to aiosqlite?
Cos my main aim is to use aiosqlite but I wanted to get something up n running first
not very hard, it's just an async bridge
so nothing will change except stuff will need to be awaited like
await c.execute(...)```
Would this be corrrect?
https://caught-lackin-in-8k-by-cyberghost.cf/rqITO2ar
await execute(...)
await connect(...)
yes, also await connect
do conn = await aiosqlite.connect(...)
and c = await conn.cursor
and result = await c.fetchone()
Oh I see I didn't think that was allowed
Ive only started messing with async when I started this project
yea allg
AttributeError: 'Result' object has no attribute 'execute'
C:\Python310\lib\site-packages\discord\client.py:380: RuntimeWarning: coroutine 'Connection.cursor' was never awaited
await self.on_error(event_name, *args, **kwargs)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback```

oh wait
line 15
I been up all night doing dis XD
Thanks @green bluff and @boreal ravine
one last thing
@commands.command()
@commands.check_any(
commands.is_owner(),
commands.has_permissions(administrator=True))
async def rsay(self, ctx, channel:discord.TextChannel=None, *, message):
if commands.check_any()==True:
await ctx.message.delete()
if channel != None:
await channel.send(str(message))
else:
await ctx.reply("Please provide a channel.")
else:
await ctx.reply("lol no")
it replies the lol no
despite being owner
how do i do the check?
u don't need if commands.check_any() == True:
It will raise an error
And you catch it in an error handler and do something
!d discord.ext.commands.CheckAnyFailure
exception discord.ext.commands.CheckAnyFailure(checks, errors)```
Exception raised when all predicates in [`check_any()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check_any "discord.ext.commands.check_any") fail.
This inherits from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
New in version 1.3.
I believe I already have that in my errorhandler
highest_salaries = salary.sort_values(by='salary', ascending=False)
eighth_highest_salary = tenpaid.get['salary'].index[9]
eighth_player_name = tenpaid.get['name'].index[9]
print('Player:', eighth_player_name, '\nSalary:', eighth_highest_salary)
what is the issue with this code?
yo wrong channel

where can i go?
claim a help channel ig
Hello, I'm looing to discuss with someone about the intents.json, and if or how to implement entities?
intents.json? whats that
how the chat bot does the conversation
oh sorry, I should mention i'm trying to make a chatbot work
class discord.Intents(**kwargs)```
Wraps up a Discord gateway intent flag.
Similar to [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions"), the properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools.
To construct an object you can pass keyword arguments denoting the flags to enable or disable.
This is used to disable certain gateway features that are unnecessary to run your bot. To make use of this, it is passed to the `intents` keyword argument of [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").
New in version 1.5...
Is the class you will use
Since you are making a chatbot you would need Intents.default() along with Intents.message_content
Is there a way to fetch a guild's name and owner from an id?
if the bot is not in said guild
I don't believe so
no, even if you try to fetch it you would get a discord.Forbidden error
Rip
async def join(ctx):
channel = bot.get_channel(940989023105712178)
await channel.connect()```
```discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'connect'```
It's can't find the channel. (940989023105712178)
Is the channel you are trying to get a voice channel?
my problem is solved anyways thanks
thanks
Help me
cogs/music.py
from discord.ext import commands
class Radio(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command()
async def join(self, ctx):
channel = ctx.author.voice.channel
if ctx.author.voice != None:
channel.connect()
await ctx.send('Successful')
else:
await ctx.send('Pls join to voice channel')
def setup(client):
client.add_cog(Radio(client))```
Sorry we don't help with music bots.
import os
from discord.ext import commands
client = commands.Bot(command_prefix='+',help_command=None,activity=discord.Game(name='Дристаю толчёк 24/7'))
@client.event
async def on_ready():
print('Bot online')
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
client.load_extension(f'cogs.{filename[:-3]}')
token = os.environ.get('Token')
client.run(token)```
any way to get role icons?
One sec
it's await channel.connect()
Only managed to find it in disnake
:/
!d disnake.Role.icon
property icon```
Returns the role’s icon asset, if available.
New in version 2.0.
that's okay
!d discord.Role.icon
property icon```
Returns the role’s icon asset, if available.
Note
If this is `None`, the role might instead have unicode emoji as its icon if [`unicode_emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role.unicode_emoji "discord.Role.unicode_emoji") is not `None`.
If you want the icon that a role has displayed, consider using [`display_icon`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role.display_icon "discord.Role.display_icon").
New in version 2.0.
Oh this exists as well
Oh
just include await before channel.connect()
copy this if you don't get it
from discord.ext import commands
class Radio(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command()
async def join(self, ctx):
channel = ctx.author.voice.channel
if ctx.author.voice != None:
await channel.connect()
await ctx.send('Successful')
else:
await ctx.send('Pls join to voice channel')
def setup(client):
client.add_cog(Radio(client))```
This will error
from where?
channel = ctx.author.voice.channel
ah i only saw await error on his shell
Yeah you'd have to do if member.voice: channel = ...
nah i tired this code it works without error
anyway
await ctx.guild.change_voice_state(self_mute=True, self_deaf=True)
this thing is not working
i doubt that guild has a change_voice_state method
!d discord.Guild.change_voice_state
await change_voice_state(*, channel, self_mute=False, self_deaf=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Changes client’s voice state in the guild.
New in version 1.4.
yeah
Thats because you're in a vc
ah
got it
still don't work
await ctx.guild.change_voice_state(channel=channel, self_mute=True, self_deaf=True)
it seems like this line is getting ignored
no error
!d discord.Message.pin
await pin(*, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Pins the message.
You must have the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to do this in a non-private channel context.
thx
block of code?
yes
async def join(ctx):
channel = bot.get_channel(940989023105712178)
await channel.connect(timeout=99999999)
await ctx.guild.change_voice_state(channel=channel, self_mute=True, self_deaf=True)```
As timeout just pass None for inf
it connects to te channel right?
ok
yes it does
I don't think you need to do channel.connect
yeah it works
how do i define pin?
or try first to change the voice state then connect
@spring flax
You don't
yes working fine now
async def join(ctx):
channel = bot.get_channel(940989023105712178)
# await channel.connect(timeout=None)
await ctx.guild.change_voice_state(channel=channel, self_mute=True, self_deaf=True)```
Cool
?
oh
Sure if that's what you want to pin
"pin" is not defined
await pin(*, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Pins the message.
You must have the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to do this in a non-private channel context.
@bot.command()
async def note(ctx, *, text):
message = ctx.message
await message.delete()
await ctx.send(f'{text}')
await pin(*, reason = None)
can clicking a button take you to a different channel
or is that not possible
like the same way doing #discord-bots could
@placid skiff @spring flax @cloud dawn
Don't literally copy paste the example function.
@bot.command()
async def note(ctx, *, text: str):
await ctx.message.delete()
msg = await ctx.send(text)
await msg.pin()
thank you
Thank you
how would i print an embed?
like i got code like this
@commands.Cog.listener()
async def on_message(self, message):
print(message)
and i wanna check if message has an embed and if yes then print embed title
for example i wanna print Members part of this command
Message has an embeds attribute
!d discord.Message.embeds
A list of embeds the message has.
Alr thanks
how would i make a reminder command? so i could do !remind (time till bot reminds) (text)
Store the time when the command was used in a database
And have a task to check if any of the reminders time is up
And remind them
Or just use asyncio
Please tell me you don't mean asyncio.sleep
If
If your duration is like < 100 seconds maybe that's ok
Otherwise no definitely
If many users use your reminder command it will cause problems
It's better to just go with tasks and a database than to risk losing all of the data because your bot died
Hmm how about going at the CommandTree on_error? Best to subclass it i guess?
is on_error a method of CommandTree ?( yes im aware its an event too)
Yeah but since there really is no clean way to do it otherwise.
I'm using Client so cogs is not really an option right now.
async def my_handler(...):
...
command_tree = app_commands.CommandTree(...)
command_tree.on_error = my_handler
``` you can do this if you dont want to subclass..
What do you think?
i prefer subclassing most of the things, but since i've never used discord.py's app commands cant say
Been using it for about 3 days but it's pretty messy.
i honestly dont like the implementation
Logically you would use Client with the slash commands but without cogs you need to make your own Group solution.
Disnake made good use of the Bot class by just also allowing to set None for command_prefix.
But since you can't do that in discord.py Bot class is pretty useless and annoying.
Thus now working with Client I don't have cogs as well as listeners. 
that sucks, well you can make the command trees in different folders and import to add them maybe
if that works?!
Right now I got it set it up like a class in each folder and just importing the class and adding the Group class to the tree.
Which is the same as the cogs but without the reloading and unloading etc. Didn't use unload but reloading was kinda nice.
well thats kinda efficient
but still it would be really better if there was something like cogs for this
from discord import Interaction
from discord.app_commands import Group, command, describe, check
from decorators import is_bot_owner
from log import log
from ui.buttons import Confirm
from utils.view import inter_timeout
class Core(Group, name="core"):
"""Core functionality of the bot"""
@command(name="stop", description="Shutdown the bot")
@describe(forced="Forced shutdown of the bot")
@check(is_bot_owner)
async def _stop_bot(self, interaction: Interaction, forced: bool = False) -> None:
view = Confirm(
conf_msg="Shutting down the bot.",
canc_msg="Canceled bot shutdown."
)
await interaction.response.send_message("Are you sure you want to shut the bot?", view=view)
if await inter_timeout(interaction, view) and view.value:
log.info("Shutdown command received")
if forced:
exit(0)
await interaction.client.close()
This is my "cog"
Just one command for now, I'm making the base first, thinking about how to structure it, currently busy with the error system then the DB and then I can add more cmds
ah cool :D
and what about the command options, how do you get that done?
You mean the forced option?
like thats a slash command isnt it, how do you take arguments from user
Ah with args & kwargs plus typehint
for example the forced kwarg here is optional and it's only a bool
So the typehint is the datatype and after the equal will be the representing default value.
You can also assign it to a function and change the name and do even bigger Params if you wanna get real fancy.
Here is my source code I'm working on rn https://github.com/Pandabweer/dpy-dispy/
the Group class looks like cogs but meant for a commandtree
also, what if you use Bot with a command tree and without message_content intents, does it error out or something?
Most likely
Since command_prefix basically is reading a message.
But the bot currently has 0 intents on
you can just override Bot's on_message event and it wont try reading the content
Tbh that sounds like a big mess
I just need to figure out a lot of stuff like how to get multiple groups and reloading groups for both I got an idea.
I was thinking about using the importlib for the import walk trough the dirs looking for the Group subclass and for the debug commands i was thinking about re-syncing for the specific set guild since you can re-sync per Group when passed.
But seeing as such, this is not really beginner friendly at all since most people will likely just put everything in one file to avoid all of these issues.
Idk if many people are interested in creating slash commands anyways.
hi can i ask aiosqlite questions here
try #databases
hello im wondering how you can make a python discord bot online 24/7
self host or buy VPS
yo how do I check who banned a user?
if they can they would have done it already
whats the check tho
like I have this for on_member_leave:
try:
banned = await member.guild.fetch_ban(member)
except discord.NotFound:
banned = False``` but how do I get who banned them
well thats still answer
audit logs
Is there a way to check if a user has permissions by using the user object itself?
Oh
you can get the member for that user and then get the perms tho
!d discord.Guild.get_member , user.id goes here
get_member(user_id, /)```
Returns a member with the given ID.
Changed in version 2.0: `user_id` parameter is now positional-only.
and then you can do member.guild_permissions
!d discord.Guild.audit_logs check the audits
async for ... in audit_logs(*, limit=100, before=..., after=..., oldest_first=..., user=..., action=...)```
Returns an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.10)") that enables receiving the guild’s audit logs.
You must have the [`view_audit_log`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.view_audit_log "discord.Permissions.view_audit_log") permission to use this.
Examples
Getting the first 100 entries:
```py
async for entry in guild.audit_logs(limit=100):
print(f'{entry.user} did {entry.action} to {entry.target}')
```...
@client.command()
async def select(ctx):
await ctx.send(
"Selects!",
components=[
Select(
placeholder="Select something!",
options=[
SelectOption(label="Yes", value="a"),
SelectOption(label="No", value="b"),
],
custom_id="select1",
)
],
)
interaction = await client.wait_for(
"select_option", check=lambda inter: inter.custom_id == "select1"
)
await interaction.send(content=f"{interaction.values[0]} selected!")
this is my code i get no errors but the command is unresponsive
also i didnt used on_message in any other parts of my code
arent they checking it when a member is removed tho?
discord api is blocking my bot for some reason can anyone help
wrong event tho
replit?
yes
stop using replit
temporary solution: type kill 1 in shell
Help me
cogs/music.py
from discord.ext import commands
class Radio(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command()
async def join(self, ctx):
channel = ctx.author.voice.channel
if ctx.author.voice != None:
await channel.connect()
await ctx.send('Successful')
else:
await ctx.send('Pls join to voice channel')
@commands.command
async def leave(self, ctx):
if ctx.voice_client == None:
await ctx.send('Bot is not in voice channel')
else:
await ctx.voice_client.disconnect()
await ctx.send('Bot is disconnected')
def setup(client):
client.add_cog(Radio(client))```
then what am i supposed to use
self host/vps
bad indentation in the leave command
any help?
reply with ping
perhaps an on_command_error?
How can you stop and restart a bot with python?
in on_user_update color=self.log_channel.guild.get_member(after.id).colour, AttributeError: 'NoneType' object has no attribute 'colour'
Why am i keeping getting this error? - The stuff works, but i keep getting this error.
Main file
Mark the leave command and click 'tab'
sorry but, what to change?
!intents
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.
is there sort of code i shoud put in?
i have this in the main file
Do you have member intents?
two sec, im gonna check
Main file and discord developer portal
intents = discord.Intents.all()
intents.members = True```
i have it, but not in the cog, should i also have in the cog?
If you explicitly enable all, you don't need to set members to True
okay, so i should just delete that?
Yes it's unnecessary
Im gonna check if it work :)
This then means that member is returning None.
it's color
Aliases iirc
O
so i should change the "colour" to color
then what you mean
its work now
You're doing guild.get_member in a user update event?
to see something
Hey @proud rain!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
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.
you have color=self.log_channel.guild.get_member(after.id).colour, in a on_user_update.
so?
what's the best lyrics api guys
a discord.User is a any discord user, he doesn't have to be in the guild that the command is invoked in or your guild where you're testing. For this, you'd need discord.Member
doing user.color will always return the default color by the way
so you don't need that
i'm just saying that if the member isn't in the guild that the self.log_channel is in, there will be an error
saying member not found
discord dropdowns same as disnake dropdowns?
because you're using guild.get_member on a user
you can't change the behaviour of a dropdown
not sure that haven't used dpy since it was stopped
i don't like some of the things they're doing
I switched back
I had to await setups and load_extensions
it worked instantly
I'm impressed
maybe they have a example on the github?
lemme check
yeah they are exactly the same
Copyright (c) 2015-present Rapptz
so that's why disnake has the same dropdowns
it's a fork after all
ok Imma start slash commands for a good sake
nice
so many people are asking here about them aswell
That doesn't really change anything, the code base is licensed under MIT, so it's VERY permissive. Forks just need to include the copyright notice and they can literally change every aspect of the library
@spring flax
what
You mean disnake or dpy
Ah yes it's in a gist
where
Lemme fetch a link for you
thanks
Nvm sorry it's not that
f
@heady sluice this https://gist.github.com/Rapptz/c4324f17a80c94776832430007ad40e6#slash-commands-and-context-menu-commands
I dunno I use disnake
ay I was quite close
add me as friend, i need help
property tree```
The command tree responsible for handling the application commands in this bot.
New in version 2.0.
See how they define client
so I got it
this is a support channel you can ask here.
okay, but what should i change
so it only accepts one tree?
you're doing color=self.log_channel.guild.get_member(after.id).colour.
this will always return a color of None.
so why put it, just remove the color kawrg.
logically
I don't really know about slash commands in dpy sorry
me neither bro
kids create an instance of commands.Bot
Adults subclass commands.Bot and create an instance of the subclass
me neither
cant find the line
it's in your code

@Cog.listener()
async def on_user_update(self, before, after):
if before.name != after.name:
embed = Embed(title="Navne Skifte",
colour=after.colour,
timestamp=datetime.utcnow())
fields = [("Før:", before.name, False),
("Efter:", after.name, False)]
for name, value, inline in fields:
embed.add_field(name=name, value=value, inline=inline)
embed.set_footer(text=f'{after.author.display_name}')
await self.log_channel.send(embed=embed)
if before.discriminator != after.discriminator:
embed = Embed(title="Discriminator Skifte",
colour=after.colour,
timestamp=datetime.utcnow())
fields = [("Før:", before.discriminator, False),
("Efter:", after.discriminator, False)]
for name, value, inline in fields:
embed.add_field(name=name, value=value, inline=inline)
embed.set_footer(text=f'{after.author.display_name}')
await self.log_channel.send(embed=embed)
if before.avatar_url != after.avatar_url:
embed = Embed(title="Profilbillede Skifte",
description="Nyt billede er nedenunder, og gamle er til højre.",
color=self.log_channel.guild.get_member(after.id).colour,
timestamp=datetime.utcnow())
embed.set_thumbnail(url=before.avatar_url)
embed.set_image(url=after.avatar_url)
await self.log_channel.send(embed=embed)```

Yes but the point of my sentence was to say we don't use discord.Client which is more low-level but we use comnands.Bot which has tree attribute
if before.avatar_url != after.avatar_url:
embed = Embed(title="Profilbillede Skifte",
description="Nyt billede er nedenunder, og gamle er til højre.",
color=self.log_channel.guild.get_member(after.id).colour,
timestamp=datetime.utcnow())```
discord.errors.ClientException: This client already has an associated command tree.
I should change how I do that though
Use bot.tree don't create new one ig
bot has a tree already

so it cannot have more
should i do that with them all
!d discord.ext.commands.Bot.tree
property tree```
The command tree responsible for handling the application commands in this bot.
New in version 2.0.
And yeah it has app_command decorator I am pretty sure
in the on_user_update
yep
that sucks
why would you need 2?
don't see bot.app_command()
they are all returning None, so yes.
I mean @bot.tree.app_command
aren't they just command groups?
but its not working
nop
what is not working
i just tried switching profile pic, and it didnt send
Eh wait there's no such thing yea
I see add_command in every example
so what is the error
bot.tree.add_command Ig
its not sending
!d discord.on_user_update is a thing
discord.on_user_update(before, after)```
Called when a [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") updates their profile.
This is called when one or more of the following things change:
• avatar
• username
• discriminator...
idrk if you need intents or not tho
the bot launched, how do I know it's being registered?
!d discord.app_commands.CommandTree.command
command(*, name=..., description=..., guild=..., guilds=...)```
Creates an application command directly under this tree.
got it
There must be some kind of event or smth
have you used app commands in disnake?
And I heard something like you need to call tree.sync
Yeah and implementation there is more convenient
Cause it's more high level
Dpy is like low-level and it usually means less convenient but more control
error
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: RuntimeError: PyNaCl library needed in order to use voice
help pls
i love how disnake makes app commands bound to your bot an not a tree to me it makes more sense.
Is replit the only way of building a bot
Haven't implemented slash commands using disnake yet but i heard it's easy
I wonder how easy though
What?
Definitely no but what do you mean build a bot
I want the bot to stay online even after terminating my program
Replit is definitely not for that
Then what am I supposed to use
Self host or a vps
If you want to make your bot be on 24/7 be prepared to spend money
Or get a sugar daddy
iirc Azure / AWS offer free trials, but you will need to put in a credit card to verify you're human. This is normal across all free tier offering services. @velvet haven
You need to install pynacl
pip install pynacl
ok i try it
Hi, do you know what the atomic argument of Member.add_roles does in dpy?
In the docs it says: atomic (bool) – Whether to atomically add roles. This will ensure that multiple operations will always be applied regardless of the current state of the cache.
I don't understand that 😶
Ah shit
I just watched a youtube on how to create a bot using replit
Not necessarily I agree with what he’s saying because on replit you can use the express package to launch a web host url, then you can go to uptimerobot.com and host the bot 24/7
@velvet haven
Yep
Search it up on Yt for help on it
There are multiple reason replit is highly recommended to not use for hosting
Why
Replit isn't even meant for hosting
replit isn't made for hosting discord bots though, replit gives a the link for a reason (hint: for web related stuff)
Here
Anyways I gtg cya y’all
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix="!", intents=discord.Intents.all(), help_command=None)
@bot.event
async def on_ready():
print(discord.__version__)
print("Gotchu homie.")
@bot.event
async def on_command_error(ctx: commands.Context, error: Exception):
#some handling
@bot.tree.command()
async def hello(interaction):
print(type(interaction))
@bot.command()
async def load_cogs(ctx):
#load cogs
await bot.tree.sync()
bot.run(TOKEN)
```any reason why my hello command isn't registered?
Oh shit i'm sorry raven if i pinged you
does your bot have the application.commands scope enabled in the server
I'll check
that's fine
no worries
it's got admin
so probably
that what you meant?
anyone here in the epikhost server?
yes
ask
word in msg.content?
i am using replit
okay but not related
wait one sec
msg = message.content i gave this already
sad_words = ["sad", "depressed", "unhappy", "angry", "miserable", "depressing"]
where did you define that
in the starting
show the whole command
ok
import discord
import os
import json
import requests
import random
client = discord.Client()
sad_words = ["sad", "depressed", "unhappy", "angry", "miserable", "depressing"]
starter_encouragements = [
"Cheer up!",
"Hang in there."
"You are a great person!"
]
def get_quote():
response = requests.get("https://zenquotes.io/api/random")
json_data = json.loads(response.text)
quote = json_data[0]['q'] +" -" + json_data[0]['a']
return(quote)
@client.event
async def on_ready():
print ('We Have Logged In As {0.user}' .format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if msg.content.startswith('Inspire'):
quote = get_quote()
await message.channel.send(quote)
msg = message.content
if any(word in msg.content for word in sad_words):
awaitmessage.channel.send(random.choice(
starter_encourangements))
client.run(os.getenv('TOKEN'))
okay, sad_words is not in your on_message's scope
and, bad tutorial.
actually
xd
What error does it say
so what do i do?
which I would recommend learning python for
wait
How ironic
bro can someone teach me python
it's probably being maintained
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
!indents
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
Corey Schafer
And do projects like this it’s helpful
give aliases
just different decos mostly
who's that?
you got it
On YouTube

okay
whos Corey well hes a goat 😎
If you don’t know Corey Schafer then ur not a true programmer that’s the truth
😳
In this Python Object-Oriented Tutorial, we will begin our series by learning how to create and use classes within Python. Classes allow us to logically group our data and functions in a way that is easy to reuse and also easy to build upon if need be. Let's get started.
Python OOP 1 - Classes and Instances - https://youtu.be/ZDa-Z5JzLYM
Python...
seems like a nice guy
k
He is
ive seen live streams hes a pretty chill guy
i am not
havent seen lucas code in a while
🤨 🤨 🤨 🤨
oh but seen swastik more than needed
further tips:
json = bad practice
requests = blocking
bot > client
and for myself,
slash commands != work
the error is all your code
what error
same one
rude
🏃♂️ pycord
dunno what was it before
intendation thingy
show
im not being rude its just not the best code at all which can be done better. not from a yt tutorial
?
@bot.tree.command()
async def hello(interaction):
print(type(interaction))
@bot.command()
async def load_cogs(ctx):
for extension in os.listdir("cogs"):
if extension.startswith("cog"):
await bot.load_extension(f"cogs.{extension[:-3]}")
print(f"Loaded {extension[:-3]}")
await bot.tree.sync()
```registeredn't
i dont use master
:kek: you guys going back to dpy?
I've got app commands scope now
and all intents
and waited for 1 hr?
1hr?
yea, the globals take 1 hr to register...
if its guild specific it gets added right at the moment
discord still frightens me
what if I close the script now and pass a guild to tree.sync()
the command will be created
oh wait I didn't even invoke the command which syncs
god damnit me
@bot.tree.command()
async def hello(interaction):
print(type(interaction))
@bot.command()
async def load_cogs(ctx):
for extension in os.listdir("cogs"):
if extension.startswith("cog"):
await bot.load_extension(f"cogs.{extension[:-3]}")
print(f"Loaded {extension[:-3]}")
await bot.tree.sync(guild=ctx.guild)
and command invoked
slash commandn't so I'm waiting
bot < client
no
You don't need bot to make slash commands
I have normal commands
Using Bot acc make slash command obsolete lol
bot < client because bot is a subclass of client
That too

b ain't there anyways
what's your point?
?
im literally asking what is your point
to have slash commands
who even uses builtin slash commands anyway
but then you might as well use builtin
slash has no real incentive, like nfts
god this is beginning to be annoying
Slash is pretty good
You need to assign the guild_ids to the command or group
other people can't see it
you can't typehint a lot of stuff, like members, guilds, or things to slash commands
this was the example
await tree.sync(guild=discord.Object(id=MY_GUILD_ID))
which is mildly annoying
It's better in almost every aspect.
- discord forces you to it
Yeah but you also need to do that on your commands or Group
except for the fact that i'd have to change half of my code to support it if i were to switch
unfortunate for you
indeed
They announced slash commands almost 2 years ago I think devs were given more than enough time.
still won't stop me
i started developing my bot 2 months ago
only heard of this, slash commands mandated fiasco after a month
How is that Discords fault?
@tree.command(guild=discord.Object(id=MY_GUILD_ID))
async def range(interaction: discord.Interaction, value: app_commands.Range[int, 1, 100]):
await interaction.response.send_message(f'Your value is {value}', ephemeral=True)
```ah I see
which was after 60+ of my commands were not compatible after just changing @commands.command to @commands.slash_command
Yes :3
i just don't see why they have to be mandated
They are not, if you got under 75 guilds you can just use the prefix
but what about for bigger bots?
like, mee6 for example
And if you got a valid reason to have message intents you can also just ask Discord.
how would you do that?
don't you think MEE6 has connections to discord
you do that when you try to whitelist your bot ( verify)
Just make an appeal but it has to be a genuine reason not like "i want to use custom prefix"
verifying is called whitelisting?
hmm alr
No it's just verified.
getting the bot verified is verification
getting intents is data whitelisting
o okay
Most likely the message intents will be really sensitive, so most likely you can't use custom prefixes anyways.
if you request for message intents, the verification is gonna be very specific about everything
btw, check out https://discord.com/developers/docs/topics/rate-limits, and click on the colon at the end of this line -
Note that normal route rate-limiting headers will also be sent in this response. The rate-limiting response will look something like the following:
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Damn a code-snippet of your most used command, aka determine the skill of the programmer Discord do be strict.
I was asked for the same
what intents did you ask for?
wait how would you determine which is your most used command?
Eh, u can share the snippet for any command
Why do you want message intents tough?
cool enough
but ill now stick to slash commands only
I'm trying to make a 0 intents bot.
Oh, cool
that sounds
message and member too,
i had boards 🏃♂️ so just deleted the bot
API calling
we call it a Rest client
actually, intents do lots of API calls on startup, right?
No?
then how do they get the data?
It's literally just sending the READY payload with the intents key
MichaelA
I mean, not as simple as that but that's the crux
Oh, idk who's he nvm
oh discord returns it all in one
does some freaky stuff in this class https://github.com/Rapptz/discord.py/blob/b47675772051ce18f801f1952c33bd1f223cbb7d/discord/state.py#L161
discord/state.py line 161
class ConnectionState:```
why is it when I do
bot = commands.Bot(command_prefix=commands.when_mentioned_or(get_prefix), intents=intents)
it gives the error TypeError: tuple for startswith must only contain str, not function
but when I do
bot = commands.Bot(command_prefix=get_prefix, intents=intents)
it works fine?
how would I go about fixing it so when bot gets mentioned it replies with the set prefix?
return commands.when_mentioned_or("the prefix")(bot, message)
``` in your get_prefix function
!d discord.Member.activity
property activity```
Returns the primary activity the user is currently doing. Could be `None` if no activity is being done.
Note
Due to a Discord API limitation, this may be `None` if the user is listening to a song on Spotify with a title longer than 128 characters. See [GH-1738](https://github.com/Rapptz/discord.py/issues/1738) for more information.
Note
A user may have multiple activities, these can be accessed under [`activities`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member.activities "discord.Member.activities").
you can use the .name attribute to get the name
how do you handle this?
discord.app_commands.errors.CommandNotFound: Application command 'hello' not found
really bad question
lmao
thanks
nah dunno
cuz you have interaction, not ctx
so it's weird to have it in on_command_error
and I did so, it wasn't handled
are you trying to add slash command?
no it's added
check indentation maybe?
cos its not registering whatever it is
as a slash command
but incase it wasn't resynced after the command is registered, it throws an app command not found error
it's registered
if it wasn't, it would just be sent as a message
but if I remove the command again, and I don't resync, it throws this error
I need to learn to add slash commands still
when I mention the bot it won't send the prefix, do I have to make a message for it to send or is it similar to the default help menu where it should do it automatically?
you would have to use a on_message event for that
!d discord.Message.mentions check if bot.user is in the mentions
A list of Member that were mentioned. If the message is in a private message then the list will be of User instead. For messages that are not of type MessageType.default, this array can be used to aid in system messages. For more information, see system_content.
Warning
The order of the mentions list is not in any particular order so you should not rely on it. This is a Discord limitation, not one with the library.
no, thats not how you take an argument in python
note, this isn't true
async def function(member: discord.Member):
activity = member.activity```
right, you can't typehint to guild
but you can to member
but why would you typehint to a guild

@bot.event
async def on_mentions(bot,ctx,):
if ctx.bot.mentions:
embed = discord.Embed(titlle='The current prefix for this server is: ', description=f'{get_prefix}', color=0x000000)
await ctx.reply(embed=embed)
return
else:
return
not sure what to do here
Hello there, I would like the know what's the easiest way to display the prefix of the bot for a set server in its name?
by editing its server name
Considering that I have a Json file for each server
property me```
Similar to [`Client.user`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.user "discord.Client.user") except an instance of [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member"). This is essentially used to get the member version of yourself.
Mmh
And use .edit(nickname=new nickname)
can bots edit their own server names?
Ah nice !
So ctx.guild.me
And then that thing.edit
So
user = ctx.guild.me
user.edit(nickname=new nickname)
Is that right?
And I could do that in the set up function
guys i want to start to build a bot but idk how to start
^
help pls
If they have change nickname perms.yes
await user.edit
do you have any experience with python
yes 3 months
import discord
from discord import app_commands
from discord.ext import commands
class Slashes(commands.Cog):
def __init__(self, bot):
self.bot = bot
print(self.__cog_app_commands__)
for command in self.__cog_app_commands__:
self.bot.tree.add_command(command, guild=discord.Object(id=935587959095320676))
self.bot.tree.add_command(self.Voices())
@app_commands.command()
async def say(self, interaction: discord.interactions.Interaction, text: str):
await interaction.response.send_message(text)
@app_commands.command()
async def get_id(self, interaction, member: discord.Member):
await interaction.response.send_message(member.id)
class Voices(app_commands.Group):
@app_commands.command()
@app_commands.describe(name="Egy név")
async def name(self, interaction, name: str):
await interaction.response.send_message(f"A voice channeled neve mostantól {name}. *(csak teszt)*")
async def setup(bot):
await bot.add_cog(Slashes(bot))
```say and get_id are added but not name
oh I know why BRU
why do I ask before thinking
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\core.py", line 191, in wrapped
ret = await coro(*args, **kwargs)
File "c:\botok\Clanbot\Bot.py", line 48, in load_cogs
await bot.tree.sync(guild=discord.Object(id=935587959095320676))
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\app_commands\tree.py", line 891, in sync
data = await self._http.bulk_upsert_guild_commands(self.client.application_id, guild.id, payload=payload)
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\http.py", line 400, in request
kwargs['data'] = utils._to_json(kwargs.pop('json'))
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\utils.py", line 600, in _to_json
return json.dumps(obj, separators=(',', ':'), ensure_ascii=True)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3312.0_x64__qbz5n2kfra8p0\lib\json\__init__.py", line 234, in dumps
return cls(
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3312.0_x64__qbz5n2kfra8p0\lib\json\encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3312.0_x64__qbz5n2kfra8p0\lib\json\encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3312.0_x64__qbz5n2kfra8p0\lib\json\encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type Command is not JSON serializable
Ho Yeah of course
hi guys
name overwrote something
unfortunate
how can i install discord.ui ?
Don't name your folder discord, will make you suffer

@bot.event
async def on_mentions(bot,ctx,):
if ctx.bot.mentions:
embed = discord.Embed(titlle='The current prefix for this server is: ', description=f'{get_prefix}', color=0x000000)
await ctx.reply(embed=embed)
return
else:
return
bot not replying w prefix
wtf
those parameters are really wrong, the event doesn't exist and you didn't call get_prefix
Lol
also not
It's on message
mentioned_in(message)```
Checks if the member is mentioned in the specified message.
don't use mentiond_in in these type of stuff it's True even for role and everyone mentions
perhaps if bot.user.mentioned_in(message)
!d discord.ClientUser.mentioned_in
mentioned_in(message)```
Checks if the user is mentioned in the specified message.
Ah okay
is that for commands.when_mentioned also?
Nope
so
@bot.event
async def on_message(message):
if bot.user.mentioned_in(message):
await message.channel.send("I was mentioned")
consider @bot.listen()
without everyone pings... idk
async def on_message(message):
if bot.user in message.mentions:
# your stuff``` 🐢
mmmmmmm
sure!
next thing I could think of was if bot.user.mentioned_in(message) and not message.mention_everyone:
but yours is better
you know i've never even thought about decoraters with making bots 
are there any other ones apart from @bot.event
hello can someone help me test my little pony chat please
oh yeah, ofc but are there any others
@commands.has_permissions
I've been using lots of decos lately
@commands.has_role
i've only had to ever use ones for slash commands and event
Surely
!d discord.app_commands.check
@discord.app_commands.check(predicate)```
A decorator that adds a check to an application command.
These checks should be predicates that take in a single parameter taking a [`Interaction`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.Interaction "discord.Interaction"). If the check returns a `False`-like value then during invocation a [`CheckFailure`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.app_commands.CheckFailure "discord.app_commands.CheckFailure") exception is raised and sent to the appropriate error handlers.
These checks can be either a coroutine or not.
Examples
Creating a basic check to see if the command invoker is you...
and i basically learnt all of my python knowledge through making bots
what will it look like for a user
not show the slash command?
or an error message?
I think discords experimenting with that
will raise an error ( CheckFailure)
Slash command permissions I mean
oh
similar to normal commands
then I'll need an error handler for slash commands
!d discord.app_commands.CommandTree.on_error
await on_error(interaction, command, error)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
A callback that is called when any command raises an [`AppCommandError`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.app_commands.AppCommandError "discord.app_commands.AppCommandError").
The default implementation prints the traceback to stderr if the command does not have any error handlers attached to it.
Subclass or decorator
async def on_error(interaction, command, error):
#handling
bot.tree.on_error = on_error
can i get help here?
yes
im making a discord bot, and im trying to do a transfer command, my database is with JSON, sincerely im not viewing what is my error on code.
Error: bot don't reply and nothing happens in json
attachments:
does bot have a tree attr?
yeah
!d discord.ext.commands.Bot.tree
property tree```
The command tree responsible for handling the application commands in this bot.
New in version 2.0.
oh
oh and only bot does
yea that would do
not client
@slate swan can help me?
just proved people wrong
proved what? 😂




