@@ -108,7 +108,7 @@ def application_commands(self) -> list[ApplicationCommand]:
108108 return list (self ._application_commands .values ())
109109
110110 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.
112112
113113 This is usually not called, instead the :meth:`command` or
114114 other shortcut decorators are used instead.
@@ -143,7 +143,7 @@ def add_application_command(self, command: ApplicationCommand) -> None:
143143 def remove_application_command (
144144 self , command : ApplicationCommand
145145 ) -> ApplicationCommand | None :
146- """Remove a :class:`.ApplicationCommand` from the internal list
146+ """Remove an :class:`.ApplicationCommand` from the internal list
147147 of commands.
148148
149149 .. versionadded:: 2.0
@@ -156,16 +156,15 @@ def remove_application_command(
156156 Returns
157157 -------
158158 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,
160160 ``None`` is returned instead.
161161 """
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
169168
170169 @property
171170 def get_command (self ):
@@ -185,7 +184,7 @@ def get_application_command(
185184 guild_ids : list [int ] | None = None ,
186185 type : type [ApplicationCommand ] = ApplicationCommand ,
187186 ) -> ApplicationCommand | None :
188- """Get a :class:`.ApplicationCommand` from the internal list
187+ """Get an :class:`.ApplicationCommand` from the internal list
189188 of commands.
190189
191190 .. versionadded:: 2.0
0 commit comments