How do you reload & sync commands in cogs? #9746
Unanswered
ItsCubeTime
asked this question in
Q&A
Replies: 2 comments
-
Bump, I don't think I got this working |
Beta Was this translation helpful? Give feedback.
0 replies
-
To get things work for me I need to do something like this: from importlib import import_module
bot: AutoShardedBot
bot.tree.clear_commands()
await bot.tree.sync()
# prevent rate limiting:
await asyncio.sleep(1)
# your cog modules:
cogs = ["cogs.foo", "cogs.bar", "cogs.baz"]
# load or reload each of them:
for cog in cogs:
module = import_module(cog)
if module.__name__ in bot.extensions:
await bot.reload_extension(module.__name__)
else:
await bot.load_extension(module.__name__)
await bot.tree.sync() |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have an extension
modpinmsgtobottom
, with a cogModPinMsgToBottomPy_COG
:And another extension
developmentUtilitiesCog
with a cogDevelopmentUtilities_Cog
which defines a commandreloadextension
:Running
/reloadextension modpinmsgtobottom
is supposed to hot reload the code in mymodpinmsgtobottom
extension (which it seems to do just fine, in that I can change function definitions and changes take effect immediately).The only issue is that the commands doesnt seem to sync (I cant see new commands without restarting the entire bot). Am I missing something?
Thanks for reading 💝
Beta Was this translation helpful? Give feedback.
All reactions