File tree Expand file tree Collapse file tree 1 file changed +22
-5
lines changed Expand file tree Collapse file tree 1 file changed +22
-5
lines changed Original file line number Diff line number Diff line change 37
37
Coroutine ,
38
38
List ,
39
39
Optional ,
40
+ Type ,
40
41
TypeVar ,
41
42
Union ,
42
43
)
@@ -131,24 +132,40 @@ def remove_application_command(
131
132
"""
132
133
return self .application_commands .pop (command .id )
133
134
134
- def get_command (self , id : str , / ) -> Optional [ApplicationCommand ]:
135
+ def get_command (
136
+ self ,
137
+ name : str ,
138
+ guild_ids : Optional [List [int ]] = None ,
139
+ type : Type [ApplicationCommand ] = SlashCommand ,
140
+ ) -> Optional [ApplicationCommand ]:
135
141
"""Get a :class:`.ApplicationCommand` from the internal list
136
142
of commands.
137
143
138
144
.. versionadded:: 2.0
139
145
140
146
Parameters
141
147
-----------
142
- id: :class:`str`
143
- The id of the command to get.
148
+ name: :class:`str`
149
+ The name of the command to get.
150
+ guild_ids: List[:class:`int`]
151
+ The guild ids associated to the command to get.
152
+ type: Type[:class:`.ApplicationCommand`]
153
+ The type of the command to get. Defaults to :class:`.SlashCommand`.
144
154
145
155
Returns
146
156
--------
147
- Optional[:class:`ApplicationCommand`]
157
+ Optional[:class:`. ApplicationCommand`]
148
158
The command that was requested. If not found, returns ``None``.
149
159
"""
150
160
151
- return self .application_commands .get (id )
161
+ for command in self .application_commands .values ():
162
+ if (
163
+ command .name == name
164
+ and isinstance (command , type )
165
+ ):
166
+ if guild_ids is not None and command .guild_ids != guild_ids :
167
+ return
168
+ return command
152
169
153
170
get_application_command = get_command
154
171
You can’t perform that action at this time.
0 commit comments