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

Code before:

    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']
        ]

    def to_dict(self) -> _BaseGuildApplicationCommandPermissions:
        return {'permissions': [p.to_dict() for p in self.permissions]}


def app_command_option_factory(
    parent: ApplicationCommandParent, data: ApplicationCommandOption, *, state: Optional[ConnectionState] = None

Review comment (security):
```suggestion
        The guild ID associated with the permissions.
```

Code after:
        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'])
        self.permissions: List[AppCommandPermissions] = [
            AppCommandPermissions(data=value, guild=self.guild, state=self._state) for value in data['permissions']
        ]

    def to_dict(self) -> Dict[str, Any]:
        return {'permissions': [p.to_dict() for p in self.permissions]}

    @property