Skip to content

Discord Models

Note

The following classes come from the scurrypy.models module.


ApplicationModel dataclass

Bases: DataModel

Represents a Discord application.

id: int instance-attribute

ID of the application.

name: str instance-attribute

Name of the application.

icon: Optional[str] instance-attribute

Icon hash of the application.

description: Optional[str] instance-attribute

Description of the application.

bot_public: Optional[bool] instance-attribute

If the application is public.

bot_require_code_grant: Optional[bool] instance-attribute

If full OAuth2 code grant is required.

bot: Optional[UserModel] instance-attribute

Partial bot user object of the application.

terms_of_service_url: Optional[str] instance-attribute

Terms of Service URL of the application

privacy_policy: Optional[str] instance-attribute

Privacy Policy URL of the application.

owner: Optional[UserModel] instance-attribute

Partial user object of the owner of the application.

guild_id: Optional[int] instance-attribute

Guild ID associated with the application.

guild: Optional[GuildModel] instance-attribute

Partial guild object of the associated guild.

cover_image: Optional[str] instance-attribute

Image hash of rich presence invite cover.

flags: Optional[int] instance-attribute

Public flags of the application. See ApplicationFlags.

approximate_guild_count: Optional[int] instance-attribute

Approximate guild count of the guilds that installed the application.

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss

ApplicationFlags

Application flags (bitwise constants).

GATEWAY_PRESENCE = 1 << 12 class-attribute instance-attribute

Privileged intent to receive presence_update events.

GATEWAY_PRESENCE_LIMITED = 1 << 13 class-attribute instance-attribute

Intent to receive presence_update events.

GATEWAY_GUILD_MEMBERS = 1 << 14 class-attribute instance-attribute

Privileged intent to receive member-related events.

GATEWAY_GUILD_MEMBERS_LIMITED = 1 << 15 class-attribute instance-attribute

Intent to receive member-related events.

VERIFICATION_PENDING_GUILD_LIMIT = 1 << 16 class-attribute instance-attribute

Indicates unusual growth of an app that prevents verification.

GATEWAY_MESSAGE_CONTENT = 1 << 18 class-attribute instance-attribute

Privileged intent to receive message content.

GATEWAY_MESSAGE_CONTENT_LIMITED = 1 << 19 class-attribute instance-attribute

Intent to receive message content.


PinnedMessageModel dataclass

Bases: DataModel

Pinned message data.

message: MessageModel instance-attribute

Message resource of the pinned message.

pinned_at: Optional[str] instance-attribute

ISO8601 timestamp of when the message was pinned.

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss

ChannelModel dataclass

Bases: DataModel

Represents a Discord guild channel.

id: int instance-attribute

ID of the channel.

type: int instance-attribute

Type of channel.

guild_id: Optional[int] instance-attribute

Guild ID of the channel.

parent_id: Optional[int] instance-attribute

Category ID of the channel.

position: Optional[int] instance-attribute

Position of the channel.

name: Optional[str] instance-attribute

Name of the channel.

topic: Optional[str] instance-attribute

Topic of the channel.

nsfw: Optional[bool] instance-attribute

If the channel is flagged NSFW.

last_message_id: Optional[int] instance-attribute

ID of the last message sent in the channel.

last_pin_timestamp: Optional[str] instance-attribute

ISO8601 timestamp of the last pinned messsage in the channel.

rate_limit_per_user: Optional[int] instance-attribute

Seconds user must wait between sending messages in the channel.

permissions: Optional[int] instance-attribute

Permissions for the invoking user in this channel. Includes role and overwrite calculations. [INT_LIMIT]

user_can

Checks permissions to see if permission bit is toggled.

Warning

If permission field is None, this function always returns False.

Parameters:

  • permission_bit (int) –

    permission bit. See Permissions.

Returns:

  • bool

    whether the user has this permission

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss


EmojiModel dataclass

Bases: DataModel

Represents a Discord emoji.

name: str instance-attribute

Name of emoji.

id: int = 0 class-attribute instance-attribute

ID of the emoji (if custom).

animated: bool = False class-attribute instance-attribute

If the emoji is animated. Defaults to False.

mention: str property

For use in message content.

api_code: str property

Return the correct API code for this emoji (URL-safe).

url: str property

Return the full qualifying link for this emoji.

Important

This only works for custom Discord emojis (those with an ID). Unicode emojis will return None.

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss


GuildMemberModel dataclass

Bases: DataModel

Represents a guild member.

roles: list[int] instance-attribute

List of roles registered to the guild member.

user: UserModel instance-attribute

User data associated with the guild member.

nick: str instance-attribute

Server nickname of the guild member.

avatar: str instance-attribute

Server avatar hash of the guild mmeber.

joined_at: str instance-attribute

ISO8601 timestamp of when the guild member joined server.

deaf: bool instance-attribute

If the member is deaf in a VC (input).

mute: bool instance-attribute

If the member is muted in VC (output).

permissions: Optional[int] instance-attribute

Total permissions of the member in the channel, including overwrites, returned when in the interaction object. [INT_LIMIT]

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss


ReadyGuildModel dataclass

Bases: DataModel

Guild info from Ready event.

id: int instance-attribute

ID of the associated guild.

unavailable: bool instance-attribute

If the guild is offline.

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss

GuildModel dataclass

Bases: DataModel

Represents a Discord guild.

id: int instance-attribute

ID of the guild.

name: str instance-attribute

Name of the guild.

icon: str instance-attribute

Image hash of the guild's icon.

splash: str instance-attribute

Image hash of the guild's splash.

owner: Optional[bool] instance-attribute

If the member is the owner.

owner_id: int instance-attribute

OD of the owner of the guild.

emojis: list[EmojiModel] instance-attribute

List of emojis registered in the guild.

roles: list[RoleModel] instance-attribute

Roles in the guild.

mfa_level: int instance-attribute

Required MFA level of the guild.

application_id: int instance-attribute

ID of the application if the guild is created by a bot.

system_channel_id: int instance-attribute

Channel ID where system messages go (e.g., welcome messages, boost events).

system_channel_flags: int instance-attribute

System channel flags.

rules_channel_id: int instance-attribute

Channel ID where rules are posted.

max_members: Optional[int] instance-attribute

Maximum member capacity for the guild.

description: str instance-attribute

Description of the guild.

banner: str instance-attribute

Image hash of the guild's banner.

preferred_locale: str instance-attribute

Preferred locale of the guild.

public_updates_channel_id: int instance-attribute

Channel ID of announcement or public updates.

approximate_member_count: int instance-attribute

Approximate number of members in the guild.

nsfw_level: int instance-attribute

NSFW level of the guild.

safety_alerts_channel_id: int instance-attribute

Channel ID for safety alerts.

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss


IntegrationModel dataclass

Bases: DataModel

Represents a guild integration.

id: int instance-attribute

ID of the integration.

name: str instance-attribute

Name of the integration.

type: str instance-attribute

Type of integration (e.g.,'twitch', 'youtube', 'discord', or 'guild_subscription').

enabled: bool instance-attribute

If the integration is enabled.

application: Optional[ApplicationModel] instance-attribute

The bot application for Discord integrations.

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss


InteractionModel dataclass

Bases: DataModel

Represents the interaction model.

type: int instance-attribute

Type of interaction. See InteractionTypes.

id: int instance-attribute

ID of interaction.

token: str instance-attribute

token of interaction.

channel_id: int instance-attribute

ID of the channel where the interaction was sent.

application_id: int instance-attribute

ID of the application that owns the interaction.

app_permissions: int instance-attribute

Bitwise set of permissions pertaining to the location of the interaction. [INT_LIMIT]

member: GuildMemberModel instance-attribute

Guild member invoking the interaction.

locale: str instance-attribute

Invoking user's locale.

guild_locale: str instance-attribute

Locale of the guild the interaction was invoked (if invoked in a guild).

guild_id: Optional[int] instance-attribute

ID of guild the interaction was invoked (if invoked in a guild).

guild: Optional[GuildModel] instance-attribute

Partial guild object of the guild the interaction was invoked (if invoked in a guild).

channel: Optional[ChannelModel] instance-attribute

Partial channel object the interaction was invoked.

bot_can

Checks app_permissions to see if permission bit is toggled.

Parameters:

  • permission_bit (int) –

    permission bit. See Permissions.

Returns:

  • bool

    whether the bot has this permission

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss

InteractionTypes

Interaction types constants.

APPLICATION_COMMAND = 2 class-attribute instance-attribute

Slash command interaction.

MESSAGE_COMPONENT = 3 class-attribute instance-attribute

Message component interaction (e.g., button, select menu, etc.).

APPLICATION_COMMAND_AUTOCOMPLETE = 4 class-attribute instance-attribute

Application command autocompletion.

MODAL_SUBMIT = 5 class-attribute instance-attribute

Modal submit interaction.

InteractionCallbackModel dataclass

Bases: DataModel

Represents the interaction callback response object.

interaction: InteractionCallbackDataModel instance-attribute

The interaction object associated with the interaction response.

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss

InteractionCallbackDataModel dataclass

Bases: DataModel

Represents the interaction callback object.

id: int instance-attribute

ID of the interaction.

type: int instance-attribute

Type of interaction. See InteractionCallbackTypes.

activity_instance_id: str instance-attribute

Instance ID of activity if an activity was launched or joined.

response_message_id: int instance-attribute

ID of the message created by the interaction.

response_message_loading: bool instance-attribute

If the interaction is in a loading state.

response_message_ephemeral: bool instance-attribute

If the interaction is ephemeral.

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss

InteractionCallbackTypes

Interaction callback types constants.

PONG = 1 class-attribute instance-attribute

Acknowledge a Ping.

CHANNEL_MESSAGE_WITH_SOURCE = 4 class-attribute instance-attribute

Respond to an interaction with a message.

DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE = 5 class-attribute instance-attribute

Acknowledge an interaction and edit a response later. User sees a loading state.

DEFERRED_UPDATE_MESSAGE = 6 class-attribute instance-attribute

Acknowledge an interaction and edit the original message later. The user does NOT see a loading state. (Components only)

UPDATE_MESSAGE = 7 class-attribute instance-attribute

Edit the message in which the component was attached.

APPLICATION_COMMAND_AUTOCOMPLETE_RESULT = 8 class-attribute instance-attribute

Respond to an autocomplete interaction with suggested choices.

MODAL = 9 class-attribute instance-attribute

Respond to an interaction with a popup modal (not available for MODAL_SUBMIT and PING interactions).

LAUNCH_ACTIVITY = 12 class-attribute instance-attribute

Launch an activity associated with the app (Activities must be enabled).

InteractionDataTypes

Interaction data types constants.

SLASH_COMMAND = 1 class-attribute instance-attribute

The interaction is a slash command.

USER_COMMAND = 2 class-attribute instance-attribute

The interaction is attached to a user.

MESSAGE_COMMAND = 3 class-attribute instance-attribute

The interaction is attached to a message.


MessageModel dataclass

Bases: DataModel

A Discord message.

id: int instance-attribute

ID of the message.

channel_id: int instance-attribute

Channel ID of the message.

author: UserModel instance-attribute

User data of author of the message.

content: str instance-attribute

Content of the message.

pinned: bool instance-attribute

If the message is pinned.

type: int instance-attribute

Type of message.

webhook_id: Optional[int] instance-attribute

ID of the webhook if the message is a webhook.

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss


RoleModel dataclass

Bases: DataModel

Represents a Discord role.

id: int instance-attribute

ID of the role.

name: str instance-attribute

Name of the role.

colors: RoleColorModel instance-attribute

Colors of the role.

hoist: bool instance-attribute

If the role is pinned in user listing.

position: int instance-attribute

Position of the role.

managed: bool instance-attribute

If the role is managed by an integration.

mentionable: bool instance-attribute

If the role is mentionable.

flags: int instance-attribute

Role flags combined as a bitfield.

icon: Optional[str] instance-attribute

Icon hash of the role.

permissions: str instance-attribute

permission bits set.

unicode_emoji: Optional[str] instance-attribute

Unicode emoji of the role.

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss

RoleColorModel dataclass

Bases: DataModel

Role color data.

primary_color: int instance-attribute

Primary color of the role.

secondary_color: int instance-attribute

Secondary color of the role. Creates a gradient.

tertiary_color: int instance-attribute

Tertiary color of the role. Creates a holographic style.

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss


UserModel dataclass

Bases: DataModel

Describes the User object.

id: int instance-attribute

ID of the user.

username: str instance-attribute

Username of the user.

discriminator: str instance-attribute

Discriminator of the user (#XXXX)

global_name: str instance-attribute

Global name of the user.

avatar: str instance-attribute

Image hash of the user's avatar.

bot: Optional[bool] instance-attribute

If the user is a bot.

system: Optional[bool] instance-attribute

If the user belongs to an OAuth2 application.

mfa_enabled: Optional[bool] instance-attribute

Whether the user has two factor enabled.

banner: Optional[str] instance-attribute

Image hash of the user's banner.

accent_color: Optional[int] instance-attribute

Color of user's banner represented as an integer.

locale: Optional[str] instance-attribute

Chosen language option of the user.

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss