Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Commit 2cc637d

Browse files
committed
Feat: Change bot command tree syncing to stop duplicate commands
1 parent 907140a commit 2cc637d

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

  • projects/Chat-GPT-Discord-Bot

projects/Chat-GPT-Discord-Bot/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
class MyClient(discord.Client):
4343
def __init__(self, *, intents: discord.Intents):
44-
super().__init__(heartbeat_timeout=120, intents=intents) # heartbeat_timeout prevents the bot disconnecting from discord when running the dalle commands
44+
super().__init__(intents=intents)
4545
# A CommandTree is a special type that holds all the application command
4646
# state required to make it work. This is a separate class because it
4747
# allows all the extra states to be opt-in.
@@ -57,9 +57,9 @@ def __init__(self, *, intents: discord.Intents):
5757
# This allows for faster bot testing and development.
5858
async def setup_hook(self):
5959
# This copies the global commands over to your guild(s).
60-
self.tree.copy_global_to(guild=discord_server_1)
60+
self.tree.clear_commands(guild=discord_server_1)
6161
await self.tree.sync(guild=discord_server_1)
62-
self.tree.copy_global_to(guild=discord_server_2)
62+
self.tree.clear_commands(guild=discord_server_2)
6363
await self.tree.sync(guild=discord_server_2)
6464
# You can replace these 4 lines with "await self.tree.sync()" if you want the bots commands to...
6565
# be added to all servers its in (won't take long if your bot isn't in many servers otherwise it could take up to an hour)

0 commit comments

Comments
 (0)