Skip to content

Commit

Permalink
Avoid unnecessary generators
Browse files Browse the repository at this point in the history
  • Loading branch information
EQUENOS committed Sep 18, 2023
1 parent 424ed03 commit a2b0677
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions disnake/ext/commands/interaction_bot_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,25 +267,25 @@ def application_commands(self) -> Set[InvokableApplicationCommand]:
@property
def slash_commands(self) -> Set[InvokableSlashCommand]:
"""Set[:class:`InvokableSlashCommand`]: A set of all slash commands the bot has."""
return set(
return {
cmd for cmd in self.all_app_commands.values() if isinstance(cmd, InvokableSlashCommand)
)
}

@property
def user_commands(self) -> Set[InvokableUserCommand]:
"""Set[:class:`InvokableUserCommand`]: A set of all user commands the bot has."""
return set(
return {
cmd for cmd in self.all_app_commands.values() if isinstance(cmd, InvokableUserCommand)
)
}

@property
def message_commands(self) -> Set[InvokableMessageCommand]:
"""Set[:class:`InvokableMessageCommand`]: A set of all message commands the bot has."""
return set(
return {
cmd
for cmd in self.all_app_commands.values()
if isinstance(cmd, InvokableMessageCommand)
)
}

@property
def all_slash_commands(self) -> Dict[str, InvokableSlashCommand]:
Expand Down Expand Up @@ -348,7 +348,6 @@ def add_app_command(self, app_command: InvokableApplicationCommand) -> None:
TypeError
The app command passed is not an instance of :class:`InvokableApplicationCommand`.
"""

if not isinstance(self, disnake.Client):
raise NotImplementedError("This method is only usable in disnake.Client subclasses")

Expand Down Expand Up @@ -475,7 +474,6 @@ def remove_app_command(
Optional[:class:`InvokableApplicationCommand`]
The app command that was removed. If the key data was not valid then ``None`` is returned instead.
"""

if guild_ids is None:
# a global command may end up being a local command if test_guilds were specified
# so we should remove this "global" command from each test guild
Expand Down

0 comments on commit a2b0677

Please sign in to comment.