@@ -82,6 +82,8 @@ def get_cog_commands(self, cog: commands.Cog):
82
82
for x in res :
83
83
x .cog = cog
84
84
if isinstance (x , model .CogCommandObject ):
85
+ if x .name in self .commands .keys ():
86
+ raise error .DuplicateCommand (x .name )
85
87
self .commands [x .name ] = x
86
88
else :
87
89
if x .base in self .commands .keys ():
@@ -102,8 +104,12 @@ def get_cog_commands(self, cog: commands.Cog):
102
104
if x .subcommand_group :
103
105
if x .subcommand_group not in self .subcommands :
104
106
self .subcommands [x .base ][x .subcommand_group ] = {}
107
+ if x .name in self .subcommands [x .base ][x .subcommand_group ].keys ():
108
+ raise error .DuplicateCommand (f"{ x .base } { x .subcommand_group } { x .name } " )
105
109
self .subcommands [x .base ][x .subcommand_group ][x .name ] = x
106
110
else :
111
+ if x .name in self .subcommands [x .base ].keys ():
112
+ raise error .DuplicateCommand (f"{ x .base } { x .name } " )
107
113
self .subcommands [x .base ][x .name ] = x
108
114
109
115
def remove_cog_commands (self , cog ):
@@ -290,8 +296,10 @@ def add_slash_command(self,
290
296
name = name .lower ()
291
297
if name in self .commands .keys ():
292
298
tgt = self .subcommands [name ]
293
- has_subcommands = tgt ["has_subcommands" ]
294
- guild_ids += tgt ["guild_ids" ]
299
+ if not tgt .has_subcommands :
300
+ raise error .DuplicateCommand (name )
301
+ has_subcommands = tgt .has_subcommands
302
+ guild_ids += tgt .allowed_guild_ids
295
303
_cmd = {
296
304
"func" : cmd ,
297
305
"description" : description if description else "No description." ,
@@ -370,8 +378,12 @@ def add_subcommand(self,
370
378
if subcommand_group :
371
379
if subcommand_group not in self .subcommands [base ].keys ():
372
380
self .subcommands [base ][subcommand_group ] = {}
381
+ if name in self .subcommands [base ][subcommand_group ].keys ():
382
+ raise error .DuplicateCommand (f"{ base } { subcommand_group } { name } " )
373
383
self .subcommands [base ][subcommand_group ][name ] = model .SubcommandObject (_sub , base , name , subcommand_group )
374
384
else :
385
+ if name in self .subcommands [base ].keys ():
386
+ raise error .DuplicateCommand (f"{ base } { name } " )
375
387
self .subcommands [base ][name ] = model .SubcommandObject (_sub , base , name )
376
388
self .logger .debug (
377
389
f"Added subcommand `{ base } { subcommand_group if subcommand_group else '' } { cmd .__name__ if not name else name } `" )
0 commit comments