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

Code before:
                _object = self._state.get_user(self.id)
        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.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'])

Review comment (security):
```suggestion
    """Represents the permissions for an application command in a guild.

    .. versionadded:: 2.0

    Attributes
```

Code after:
        if self.type is AppCommandPermissionType.user:
            if guild:
                _object = guild.get_member(self.id)
            else:
                _object = self._state.get_user(self.id)
        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