@@ -81,19 +81,23 @@ class ApplicationCommandMixin:
81
81
def __init__ (self , * args , ** kwargs ) -> None :
82
82
super ().__init__ (* args , ** kwargs )
83
83
self ._pending_application_commands = []
84
- self .application_commands = {}
84
+ self ._application_commands = {}
85
85
86
86
@property
87
87
def pending_application_commands (self ):
88
88
return self ._pending_application_commands
89
89
90
90
@property
91
91
def commands (self ) -> List [Union [ApplicationCommand , Any ]]:
92
- commands = list ( self .application_commands . values ())
92
+ commands = self .application_commands
93
93
if self ._supports_prefixed_commands :
94
94
commands += self .prefixed_commands
95
95
return commands
96
96
97
+ @property
98
+ def application_commands (self ) -> List [ApplicationCommand ]:
99
+ return list (self ._application_commands .values ())
100
+
97
101
def add_application_command (self , command : ApplicationCommand ) -> None :
98
102
"""Adds a :class:`.ApplicationCommand` into the internal list of commands.
99
103
@@ -130,7 +134,7 @@ def remove_application_command(
130
134
The command that was removed. If the name is not valid then
131
135
``None`` is returned instead.
132
136
"""
133
- return self .application_commands .pop (command .id )
137
+ return self ._application_commands .pop (command .id )
134
138
135
139
def get_command (
136
140
self ,
@@ -158,7 +162,7 @@ def get_command(
158
162
The command that was requested. If not found, returns ``None``.
159
163
"""
160
164
161
- for command in self .application_commands .values ():
165
+ for command in self ._application_commands .values ():
162
166
if (
163
167
command .name == name
164
168
and isinstance (command , type )
@@ -229,7 +233,7 @@ async def register_commands(self) -> None:
229
233
guild_ids = None ,
230
234
type = i ["type" ],
231
235
)
232
- self .application_commands [i ["id" ]] = cmd
236
+ self ._application_commands [i ["id" ]] = cmd
233
237
234
238
# Permissions (Roles will be converted to IDs just before Upsert for Global Commands)
235
239
global_permissions .append ({"id" : i ["id" ], "permissions" : cmd .permissions })
@@ -263,7 +267,7 @@ async def register_commands(self) -> None:
263
267
else :
264
268
for i in cmds :
265
269
cmd = find (lambda cmd : cmd .name == i ["name" ] and cmd .type == i ["type" ] and int (i ["guild_id" ]) in cmd .guild_ids , self .pending_application_commands )
266
- self .application_commands [i ["id" ]] = cmd
270
+ self ._application_commands [i ["id" ]] = cmd
267
271
268
272
# Permissions
269
273
permissions = [
@@ -354,7 +358,7 @@ async def register_commands(self) -> None:
354
358
if len (new_cmd_perm ["permissions" ]) > 10 :
355
359
print (
356
360
"Command '{name}' has more than 10 permission overrides in guild ({guild_id}).\n will only use the first 10 permission overrides." .format (
357
- name = self .application_commands [new_cmd_perm ["id" ]].name ,
361
+ name = self ._application_commands [new_cmd_perm ["id" ]].name ,
358
362
guild_id = guild_id ,
359
363
)
360
364
)
@@ -404,7 +408,7 @@ async def process_application_commands(self, interaction: Interaction) -> None:
404
408
return
405
409
406
410
try :
407
- command = self .application_commands [interaction .data ["id" ]]
411
+ command = self ._application_commands [interaction .data ["id" ]]
408
412
except KeyError :
409
413
self .dispatch ("unknown_command" , interaction )
410
414
else :
0 commit comments