File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 15
15
from bot .button_loaders .common import CommonButtonLoader
16
16
from bot .cogs .cogs_manager import CogsManager
17
17
from bot .core .admin import process_list_modules , process_sync_commands
18
+ from bot .utils .console_logger import console_logger
18
19
from bot .utils .decorators import admin_only
19
20
20
21
@@ -149,6 +150,21 @@ async def sync_commands(self, interaction: discord.Interaction):
149
150
ctx = await commands .Context .from_interaction (interaction )
150
151
await process_sync_commands (ctx )
151
152
153
+ @commands .Cog .listener ()
154
+ async def on_guild_join (self , guild : discord .Guild ):
155
+ """
156
+ Trigger when bot joins a server.
157
+
158
+ Args:
159
+ guild (discord.Guild): The server that the bot is joining.
160
+
161
+ """
162
+ try :
163
+ await self .bot .tree .sync (guild = guild )
164
+ console_logger .info (f"Synced commands for guild: { guild .name } ({ guild .id } )" )
165
+ except Exception as e :
166
+ console_logger .info (f"Failed to sync commands for guild { guild .name } : { e } " )
167
+
152
168
153
169
async def setup (bot : commands .Bot ):
154
170
"""
You can’t perform that action at this time.
0 commit comments