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

Code before:
        self.arguments: List[Argument] = [
            Argument(parent=self, state=self._state, data=d)
            for d in data.get('options', [])
            if is_app_command_argument_type(d['type'])
        ]

    def to_dict(self) -> 'ApplicationCommandOption':
        return {
            'name': self.name,
            'type': self.type.value,
            'description': self.description,
            'required': self.required,
            'choices': [choice.to_dict() for choice in self.choices],
            'options': [arg.to_dict() for arg in self.arguments],
        }  # type: ignore # Type checker does not understand this literal.


class AppCommandPermissions:
    """Represents the permissions for an application command.

    Attributes
    -----------
    guild: :class:`.Guild`
        The guild assosiated with this permission.
    id: :class:`int`
        ID of which this permission is for, it can be a channel, guild, guild-1, user or role ID.
    object: Union[:class:`.AllChannels`, :class:`.GuildChannel`, :class:`.Role`, :class:`.Member`, :class:`~discord.User`, :class:`.Object`]
        The role, user, or channel assosiated with this permission. Falls back to :class:`.Object` if not found in cache.
    type: :class:`.AppCommandPermissionType`
        The type of permission.
    permission: :class:`bool`
        The permission value. True for allow, False for deny.
    """

    __slots__ = ('id', 'type', 'permission', 'object', 'guild', '_state')

    def __init__(self, *, data: ApplicationCommandPermissions, guild: Optional[Guild], state: ConnectionState) -> None:
        self._state: ConnectionState = state
        self.guild: Optional[Guild] = guild

        self.id: int = int(data['id'])
        self.type: AppCommandPermissionType = try_enum(AppCommandPermissionType, data['type'])
        self.permission: bool = data['permission']

        _object: Optional[Union[Object, User, Member, Role, AllChannels, GuildChannel]] = None

        if self.type is AppCommandPermissionType.user:
            if guild:
                _object = guild.get_member(self.id)
            else:
                _object = self._state.get_user(self.id)

Review comment (security):
```suggestion
        The ID of the permission target, such as a role, channel, or guild. The special ``guild_id - 1`` sentinel
        is used to represent "all channels".
```

Code after:
        self.arguments: List[Argument] = [
            Argument(parent=self, state=self._state, data=d)
            for d in data.get('options', [])
            if is_app_command_argument_type(d['type'])
        ]

    def to_dict(self) -> 'ApplicationCommandOption':
        return {
            'name': self.name,
            'type': self.type.value,
            'description': self.description,
            'required': self.required,
            'choices': [choice.to_dict() for choice in self.choices],
            'options': [arg.to_dict() for arg in self.arguments],
        }  # type: ignore # Type checker does not understand this literal.


class AppCommandPermissions:
    """Represents the permissions for an application command.

    .. versionadded:: 2.0

    Attributes
    -----------
    guild: :class:`~discord.Guild`
        The guild assosiated with this permission.
    id: :class:`int`
        The ID of the permission target, such as a role, channel, or guild.
        The special ``guild_id - 1`` sentinel is used to represent "all channels".
    target: Any
        The role, user, or channel associated with this permission. This could also be the :class:`AllChannels` sentinel type.
        Falls back to :class:`~discord.Object` if the target could not be found in the cache.
    type: :class:`.AppCommandPermissionType`
        The type of permission.
    permission: :class:`bool`
        The permission value. True for allow, False for deny.
    """

    __slots__ = ('id', 'type', 'permission', 'target', 'guild', '_state')

    def __init__(self, *, data: ApplicationCommandPermissions, guild: Optional[Guild], state: ConnectionState) -> None:
        self._state: ConnectionState = state
        self.guild: Optional[Guild] = guild

        self.id: int = int(data['id'])
        self.type: AppCommandPermissionType = try_enum(AppCommandPermissionType, data['type'])
        self.permission: bool = data['permission']

        _object = None

        if self.type is AppCommandPermissionType.user: