Skip to content

Commit

Permalink
Make command.permissions not Optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Dorukyum committed Oct 21, 2021
1 parent 15ac255 commit 2ef3550
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions discord/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,12 @@ async def register_commands(self) -> None:
self.application_commands[i["id"]] = cmd

# Permissions
permissions = [] if cmd.permissions is None else [perm.to_dict() for perm in cmd.permissions if perm.guild_id is None or (
permissions = [perm.to_dict() for perm in cmd.permissions if perm.guild_id is None or (
perm.guild_id == guild_id and perm.guild_id in cmd.guild_ids)]
guild_permissions.append({"id": i["id"], "permissions": permissions})

for global_command in global_permissions:
permissions = [] if global_command['permissions'] is None else [perm.to_dict() for perm in global_command['permissions'] if
permissions = [perm.to_dict() for perm in global_command['permissions'] if
perm.guild_id is None or (
perm.guild_id == guild_id and perm.guild_id in cmd.guild_ids)]
guild_permissions.append({"id": global_command["id"], "permissions": permissions})
Expand Down
2 changes: 1 addition & 1 deletion discord/commands/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def __init__(self, func: Callable, *args, **kwargs) -> None:

# Permissions
self.default_permission = kwargs.get("default_permission", True)
self.permissions: Optional[List[Permission]] = getattr(func, "__app_cmd_perms__", None)
self.permissions: List[Permission] = getattr(func, "__app_cmd_perms__", []) + kwargs.get("permissions", [])


def parse_options(self, params) -> List[Option]:
Expand Down

0 comments on commit 2ef3550

Please sign in to comment.