Je viens d'avoir des problèmes de synchronisation et une discussion sur le discord officiel m'a permis de comprendre pourquoi il ne fallait pas self.tree.sync() chaque chargement du bot, je vous mets les explication de la documentation en dessous (en anglais) pour faire court il s'agit de problèmes de ratelimit par discord et il vaut mieux le faire manuellement avec une commande
Auto Syncing (your command tree) Sucks, and here's why: Syncing your command tree automatically causes extra unnecessary requests to be made, this is because you only need to sync when commands are updated. *see ?tag whensync for a more nuanced list on when to sync. What syncing does is send your commands to discord for one guild or globally. If you haven't changed your command's descriptions, added/removed commands, changed names, parameters, etc. you shouldn't sync, since you'd only be updating discord with the commands they already have without doing any changes, which is pointless and a waste of an API request to a limit with an already tight rate limit. *see ?tag whatsync for a more nuanced on what syncing is, and how to do so. Oh and also, syncing your tree sometimes breaks discord, making commands not pop up for users until they restart their discord client, switch channels, or any other mysterious random events, which just inconveniences the end users of your bot for no reason. Where should I sync instead? It's better to sync using a normal (message) command (or even an on_message if you prefer Client) You can even use just a simple eval to do so. *for example:?tag umbras sync command or the jsk sync command from the debugging tool Jishaku (see ?tag jsk) *But I don't have the new message content intent... What now? Bots can still receive message content when the bot is mentioned in it, or in DMs! You could set the bot prefix to commands.when_mentioned *Oh, and if you're one of those people who restarts their bot very frequently instead of using extensions and reloading them, this could cause rate limit issues too. (see ?tag extensions)
Sync when you... Basic Added/Removed a command Added/Modified/Removed autocomplete (decorator, transformer) Added/Removed an argument Added/Modified/Removed locale strings Converted the global/guild command to a guild/global command Modify Changed a command's... name (name= kwarg, function name) description (description= kwarg, docstring) Changed an argument's... name (rename decorator, param name) choices (Literal, choices decorator, enum type) description (describe decorator, docstring) type (arg: str str is the type here) Permissions Added/Modified/Removed permissions: default_permissions (decorator, kwarg) nsfw (kwarg) Changed installs or contexts (decorators): allowed_installs allowed_contexts guild_install, user_install, guild_only, dm_only, private_channel_only Do not sync when you... Changed anything in the command/autcomplete function's body (after the async def (): part) Added/Modified/Removed library side checks: (@)app_commands.checks... (@)commands...(.check) @app_commands.checks.(dynamic_)cooldown(...) This is the same for hybrid app commands
Quand tu commences à utiliser la librairie ce n'est pas très utile mais quand tu commences à avancer et à faire des projets de plus en plus gros tu vas avoir besoin d'une certaine architecture pour ton code et celle que je présente dans la vidéo est selon moi la meilleure. Merci beaucoup hehe !
Je viens d'avoir des problèmes de synchronisation et une discussion sur le discord officiel m'a permis de comprendre pourquoi il ne fallait pas self.tree.sync() chaque chargement du bot, je vous mets les explication de la documentation en dessous (en anglais)
pour faire court il s'agit de problèmes de ratelimit par discord et il vaut mieux le faire manuellement avec une commande
Auto Syncing (your command tree) Sucks, and here's why:
Syncing your command tree automatically causes extra unnecessary requests to be made, this is because you only need to sync when commands are updated.
*see ?tag whensync for a more nuanced list on when to sync.
What syncing does is send your commands to discord for one guild or globally. If you haven't changed your command's descriptions, added/removed commands, changed names, parameters, etc. you shouldn't sync, since you'd only be updating discord with the commands they already have without doing any changes, which is pointless and a waste of an API request to a limit with an already tight rate limit.
*see ?tag whatsync for a more nuanced on what syncing is, and how to do so.
Oh and also, syncing your tree sometimes breaks discord, making commands not pop up for users until they restart their discord client, switch channels, or any other mysterious random events, which just inconveniences the end users of your bot for no reason.
Where should I sync instead?
It's better to sync using a normal (message) command (or even an on_message if you prefer Client) You can even use just a simple eval to do so.
*for example:?tag umbras sync command or the jsk sync command from the debugging tool Jishaku (see ?tag jsk)
*But I don't have the new message content intent... What now?
Bots can still receive message content when the bot is mentioned in it, or in DMs! You could set the bot prefix to commands.when_mentioned
*Oh, and if you're one of those people who restarts their bot very frequently instead of using extensions and reloading them, this could cause rate limit issues too. (see ?tag extensions)
Sync when you...
Basic
Added/Removed a command
Added/Modified/Removed autocomplete (decorator, transformer)
Added/Removed an argument
Added/Modified/Removed locale strings
Converted the global/guild command to a guild/global command
Modify
Changed a command's...
name (name= kwarg, function name)
description (description= kwarg, docstring)
Changed an argument's...
name (rename decorator, param name)
choices (Literal, choices decorator, enum type)
description (describe decorator, docstring)
type (arg: str str is the type here)
Permissions
Added/Modified/Removed permissions:
default_permissions (decorator, kwarg)
nsfw (kwarg)
Changed installs or contexts (decorators):
allowed_installs
allowed_contexts
guild_install, user_install, guild_only, dm_only, private_channel_only
Do not sync when you...
Changed anything in the command/autcomplete function's body (after the async def (): part)
Added/Modified/Removed library side checks:
(@)app_commands.checks...
(@)commands...(.check)
@app_commands.checks.(dynamic_)cooldown(...)
This is the same for hybrid app commands
Très intéressant, j'en parlerais quand je ferais une nouvelle formation sur discord.py
Je comprend pas j'arrive pas a mettre de flèche vers la droite sur VS code
tu fais "-" et ">" c'est suffisant, mais VScode ne le transforme pas en flèche malheureusement
Je n'ai pas compris à quoi cela servait de crée un "bot avancée"
Sinon génial !
Quand tu commences à utiliser la librairie ce n'est pas très utile mais quand tu commences à avancer et à faire des projets de plus en plus gros tu vas avoir besoin d'une certaine architecture pour ton code et celle que je présente dans la vidéo est selon moi la meilleure. Merci beaucoup hehe !
En plus cela devient bien plus pratique pour créer des Cogs, etc...