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

Code before:
        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)
        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`

Review comment (suggestion):
```suggestion
        self.target: Union[Object, User, Member, Role, AllChannels, GuildChannel] = _object
```

Code after:

    __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:
            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`