Repository: Rapptz/discord.py
File: discord/app_commands/models.py (Python)

Code before:
                _object = guild.get_channel(self.id)
        elif guild and self.type is AppCommandPermissionType.role:
            _object = guild.get_role(self.id)

        if _object is None:
            _object = Object(id=self.id)

        self.object = _object

    def to_dict(self) -> ApplicationCommandPermissions:
        return {
            'id': self.object.id,
            'type': self.type.value,
            'permission': self.permission,
        }


class GuildAppCommandPermissions:
    """Represents the permissions for an application command in a guild.

    Attributes
    -----------
    application_id: :class:`int`
        The application ID.
    command: :class:`.AppCommand`
        The application command assosiated with the permissions.
    id: :class:`int`
        ID of the command or the application ID.
        When the this is the application ID instead of a command ID,
        the permissions apply to all commands that do not contain explicit overwrites.
    guild: :class:`.Guild`
        The guild assosiated with the permissions.
    guild_id: :class:`int`
        The guild ID assosiated with the permissions.
    permissions: List[:class:`AppCommandPermissions`]
       The permissions, this is a max of 100.
    """

    __slots__ = ('id', 'application_id', 'command', 'guild_id', 'guild', 'permissions', '_state')

    def __init__(self, *, data: GuildApplicationCommandPermissions, state: ConnectionState, command: AppCommand) -> None:
        self._state: ConnectionState = state
        self.command: AppCommand = command

        self.id: int = int(data['id'])
        self.application_id: int = int(data['application_id'])
        self.guild_id: int = int(data['guild_id'])

        self.guild: Optional[Guild] = self._state._get_guild(self.guild_id)
        self.permissions: List[AppCommandPermissions] = [
            AppCommandPermissions(data=value, guild=self.guild, state=self._state) for value in data['permissions']

Review comment (security):
```suggestion
        The application command associated with the permissions.
```

Code after:
        elif guild and self.type is AppCommandPermissionType.channel:
            if self.id == (guild.id - 1):
                _object = AllChannels(guild)
            else:
                _object = guild.get_channel(self.id)
        elif guild and self.type is AppCommandPermissionType.role:
            _object = guild.get_role(self.id)

        if _object is None:
            _object = Object(id=self.id)

        self.target: Union[Object, User, Member, Role, AllChannels, GuildChannel] = _object

    def to_dict(self) -> ApplicationCommandPermissions:
        return {
            'id': self.target.id,
            'type': self.type.value,
            'permission': self.permission,
        }


class GuildAppCommandPermissions:
    """Represents the permissions for an application command in a guild.

    .. versionadded:: 2.0

    Attributes
    -----------
    application_id: :class:`int`
        The application ID.
    command: :class:`.AppCommand`
        The application command associated with the permissions.
    id: :class:`int`
        ID of the command or the application ID.
        When this is the application ID instead of a command ID,
        the permissions apply to all commands that do not contain explicit overwrites.
    guild_id: :class:`int`
        The guild ID associated with the permissions.
    permissions: List[:class:`AppCommandPermissions`]
       The permissions, this is a max of 100.
    """

    __slots__ = ('id', 'application_id', 'command', 'guild_id', 'permissions', '_state')

    def __init__(self, *, data: GuildApplicationCommandPermissions, state: ConnectionState, command: AppCommand) -> None:
        self._state: ConnectionState = state
        self.command: AppCommand = command

        self.id: int = int(data['id'])
        self.application_id: int = int(data['application_id'])
        self.guild_id: int = int(data['guild_id'])