From f4ac1fb5d5a60999b6fc266657e5d77a5ab183b7 Mon Sep 17 00:00:00 2001 From: ChUrl Date: Fri, 28 Oct 2022 14:18:52 +0200 Subject: [PATCH] sync commands to guilds --- bot.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bot.py b/bot.py index 521ce7d..9595544 100644 --- a/bot.py +++ b/bot.py @@ -29,6 +29,9 @@ class HeidiClient(discord.Client): def __init__(self, *, intents: discord.Intents): super().__init__(status="Nur eine kann GNTM werden!", intents=intents) + # Separate object that keeps all application command state + self.tree = app_commands.CommandTree(self) + self.prefix = "Heidi, " self.prefix_regex = "^" + self.prefix @@ -59,6 +62,14 @@ class HeidiClient(discord.Client): "sag .+$": self.say_voiceline } + # Synchronize commands to guilds + async def setup_hook(self): + self.tree.copy_global_to(guild=LINUS_GUILD) + await self.tree.sync(guild=LINUS_GUILD) + + self.tree.copy_global_to(guild=TEST_GUILD) + await self.tree.sync(guild=TEST_GUILD) + # Helpers ------------------------------------------------------------------------------------ def _help_text(self):