@@ -50,6 +50,13 @@ async def sync_tree(self, ctx: commands.Context[commands.Bot], guild: discord.Gu
50
50
await self .bot .tree .sync (guild = ctx .guild )
51
51
await ctx .reply ("Application command tree synced." )
52
52
53
+ @sync_tree .error
54
+ async def sync_error (self , ctx : commands .Context [commands .Bot ], error : Exception ) -> None :
55
+ if isinstance (error , commands .MissingRequiredArgument ):
56
+ await ctx .send (f"Please specify a guild to sync application commands to. { error } " )
57
+ else :
58
+ logger .error (f"Error syncing application commands: { error } " )
59
+
53
60
@commands .has_guild_permissions (administrator = True )
54
61
@dev .command (
55
62
name = "clear_tree" ,
@@ -131,6 +138,22 @@ async def load_cog(self, ctx: commands.Context[commands.Bot], *, cog: str) -> No
131
138
await ctx .send (f"Cog { cog } loaded." )
132
139
logger .info (f"Cog { cog } loaded." )
133
140
141
+ @load_cog .error
142
+ async def load_error (self , ctx : commands .Context [commands .Bot ], error : Exception ) -> None :
143
+ if isinstance (error , commands .MissingRequiredArgument ):
144
+ await ctx .send (f"Please specify an cog to load. { error } " )
145
+ elif isinstance (error , commands .ExtensionAlreadyLoaded ):
146
+ await ctx .send (f"The specified cog is already loaded. { error } " )
147
+ elif isinstance (error , commands .ExtensionNotFound ):
148
+ await ctx .send (f"The specified cog is not found. { error } " )
149
+ elif isinstance (error , commands .ExtensionFailed ):
150
+ await ctx .send (f"Failed to load cog: { error } " )
151
+ elif isinstance (error , commands .NoEntryPointError ):
152
+ await ctx .send (f"The specified cog does not have a setup function. { error } " )
153
+ else :
154
+ await ctx .send (f"Failed to load cog: { error } " )
155
+ logger .error (f"Failed to load cog: { error } " )
156
+
134
157
@commands .has_guild_permissions (administrator = True )
135
158
@dev .command (
136
159
name = "unload_cog" ,
@@ -169,6 +192,15 @@ async def unload_cog(self, ctx: commands.Context[commands.Bot], *, cog: str) ->
169
192
logger .info (f"Cog { cog } unloaded." )
170
193
await ctx .send (f"Cog { cog } unloaded." )
171
194
195
+ @unload_cog .error
196
+ async def unload_error (self , ctx : commands .Context [commands .Bot ], error : Exception ) -> None :
197
+ if isinstance (error , commands .MissingRequiredArgument ):
198
+ await ctx .send (f"Please specify an extension to unload. { error } " )
199
+ elif isinstance (error , commands .ExtensionNotLoaded ):
200
+ await ctx .send (f"That cog is not loaded. { error } " )
201
+ else :
202
+ logger .error (f"Error unloading cog: { error } " )
203
+
172
204
@commands .has_guild_permissions (administrator = True )
173
205
@dev .command (
174
206
name = "reload_cog" ,
@@ -208,14 +240,6 @@ async def reload_cog(self, ctx: commands.Context[commands.Bot], *, cog: str) ->
208
240
await ctx .send (f"Cog { cog } reloaded." )
209
241
logger .info (f"Cog { cog } reloaded." )
210
242
211
- @sync_tree .error
212
- async def sync_error (self , ctx : commands .Context [commands .Bot ], error : Exception ) -> None :
213
- if isinstance (error , commands .MissingRequiredArgument ):
214
- await ctx .send (f"Please specify a guild to sync application commands to. { error } " )
215
-
216
- else :
217
- logger .error (f"Error syncing application commands: { error } " )
218
-
219
243
@reload_cog .error
220
244
async def reload_error (self , ctx : commands .Context [commands .Bot ], error : Exception ) -> None :
221
245
if isinstance (error , commands .MissingRequiredArgument ):
@@ -226,31 +250,6 @@ async def reload_error(self, ctx: commands.Context[commands.Bot], error: Excepti
226
250
await ctx .send (f"Error reloading cog: { error } " )
227
251
logger .error (f"Error reloading cog: { error } " )
228
252
229
- @unload_cog .error
230
- async def unload_error (self , ctx : commands .Context [commands .Bot ], error : Exception ) -> None :
231
- if isinstance (error , commands .MissingRequiredArgument ):
232
- await ctx .send (f"Please specify an extension to unload. { error } " )
233
- elif isinstance (error , commands .ExtensionNotLoaded ):
234
- await ctx .send (f"That cog is not loaded. { error } " )
235
- else :
236
- logger .error (f"Error unloading cog: { error } " )
237
-
238
- @load_cog .error
239
- async def load_error (self , ctx : commands .Context [commands .Bot ], error : Exception ) -> None :
240
- if isinstance (error , commands .MissingRequiredArgument ):
241
- await ctx .send (f"Please specify an cog to load. { error } " )
242
- elif isinstance (error , commands .ExtensionAlreadyLoaded ):
243
- await ctx .send (f"The specified cog is already loaded. { error } " )
244
- elif isinstance (error , commands .ExtensionNotFound ):
245
- await ctx .send (f"The specified cog is not found. { error } " )
246
- elif isinstance (error , commands .ExtensionFailed ):
247
- await ctx .send (f"Failed to load cog: { error } " )
248
- elif isinstance (error , commands .NoEntryPointError ):
249
- await ctx .send (f"The specified cog does not have a setup function. { error } " )
250
- else :
251
- await ctx .send (f"Failed to load cog: { error } " )
252
- logger .error (f"Failed to load cog: { error } " )
253
-
254
253
255
254
async def setup (bot : commands .Bot ) -> None :
256
255
await bot .add_cog (Dev (bot ))
0 commit comments