forked from cbrxyz/pi-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add top-level sync command and sync script
It is generally best practice to not rate limit the slash command registration endpoint, so syncing should be done manually rather than on ready. A script is provided to simply login the bot and sync commands in case the sync command signature ever gets modified.
- Loading branch information
Showing
2 changed files
with
100 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
""" | ||
A script file to manually sync the file | ||
Run: | ||
``` | ||
python sync_commands.py | ||
``` | ||
within your venv and it will sync all commands including the /sync command | ||
""" | ||
|
||
import asyncio | ||
import logging | ||
|
||
from rich.logging import RichHandler | ||
|
||
import bot | ||
from src.discord.globals import DEV_TOKEN, TOKEN, dev_mode | ||
|
||
|
||
async def main(): | ||
logger = logging.getLogger() | ||
logger.addHandler(RichHandler(rich_tracebacks=True)) | ||
token = DEV_TOKEN if dev_mode else TOKEN | ||
async with bot.bot: | ||
await bot.bot.login(token) | ||
await bot.bot.sync_commands() | ||
|
||
exit(0) | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.run(main()) |