@@ -108,7 +108,7 @@ def application_commands(self) -> list[ApplicationCommand]:
108
108
return list (self ._application_commands .values ())
109
109
110
110
def add_application_command (self , command : ApplicationCommand ) -> None :
111
- """Adds a :class:`.ApplicationCommand` into the internal list of commands.
111
+ """Adds an :class:`.ApplicationCommand` into the internal list of commands.
112
112
113
113
This is usually not called, instead the :meth:`command` or
114
114
other shortcut decorators are used instead.
@@ -143,7 +143,7 @@ def add_application_command(self, command: ApplicationCommand) -> None:
143
143
def remove_application_command (
144
144
self , command : ApplicationCommand
145
145
) -> ApplicationCommand | None :
146
- """Remove a :class:`.ApplicationCommand` from the internal list
146
+ """Remove an :class:`.ApplicationCommand` from the internal list
147
147
of commands.
148
148
149
149
.. versionadded:: 2.0
@@ -156,16 +156,15 @@ def remove_application_command(
156
156
Returns
157
157
-------
158
158
Optional[:class:`.ApplicationCommand`]
159
- The command that was removed. If the name is not valid then
159
+ The command that was removed. If the command has not been added,
160
160
``None`` is returned instead.
161
161
"""
162
- if command .id is None :
163
- try :
164
- index = self ._pending_application_commands .index (command )
165
- except ValueError :
166
- return None
167
- return self ._pending_application_commands .pop (index )
168
- return self ._application_commands .pop (command .id , None )
162
+ if command .id :
163
+ self ._application_commands .pop (command .id , None )
164
+
165
+ if command in self ._pending_application_commands :
166
+ self ._pending_application_commands .remove (command )
167
+ return command
169
168
170
169
@property
171
170
def get_command (self ):
@@ -185,7 +184,7 @@ def get_application_command(
185
184
guild_ids : list [int ] | None = None ,
186
185
type : type [ApplicationCommand ] = ApplicationCommand ,
187
186
) -> ApplicationCommand | None :
188
- """Get a :class:`.ApplicationCommand` from the internal list
187
+ """Get an :class:`.ApplicationCommand` from the internal list
189
188
of commands.
190
189
191
190
.. versionadded:: 2.0
0 commit comments