Data Classes#

Some classes are just there to be data containers, this lists them.

Unlike models you are allowed to create most of these yourself, even if they can also be used to hold attributes.

Nearly all classes here have __slots__ defined which means that it is impossible to have dynamic attributes to the data classes.

The only exception to this rule is Object, which is made with dynamic attributes in mind.

class discord.Object(id)[source]#

Represents a generic Discord object.

The purpose of this class is to allow you to create ‘miniature’ versions of data classes if you want to pass in just an ID. Most functions that take in a specific data class with an ID can also take in this class as a substitute instead. Note that even though this is the case, not all objects (if any) actually inherit from this class.

There are also some cases where some WebSocket events are received in strange order and when such events happened you would receive this class rather than the actual data class. These cases are extremely rare.

x == y

Checks if two objects are equal.

x != y

Checks if two objects are not equal.

hash(x)

Returns the object’s hash.

id#

The ID of the object.

Type:

int

Parameters:

id (Union[SupportsInt, str, bytes, bytearray]) –

property created_at#

Returns the snowflake’s creation time in UTC.

property worker_id#

Returns the worker id that made the snowflake.

property process_id#

Returns the process id that made the snowflake.

property increment_id#

Returns the increment id that made the snowflake.

class discord.SelectOption(*, label, value=..., description=None, emoji=None, default=False)[source]#

Represents a discord.SelectMenu’s option.

These can be created by users.

New in version 2.0.

label#

The label of the option. This is displayed to users. Can only be up to 100 characters.

Type:

str

value#

The value of the option. This is not displayed to users. If not provided when constructed then it defaults to the label. Can only be up to 100 characters.

Type:

str

description#

An additional description of the option, if any. Can only be up to 100 characters.

Type:

Optional[str]

default#

Whether this option is selected by default.

Type:

bool

Parameters:
property emoji#

The emoji of the option, if available.

class discord.Intents(**kwargs)[source]#

Wraps up a Discord gateway intent flag.

Similar to Permissions, the properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools.

To construct an object you can pass keyword arguments denoting the flags to enable or disable.

This is used to disable certain gateway features that are unnecessary to run your bot. To make use of this, it is passed to the intents keyword argument of Client.

New in version 1.5.

x == y

Checks if two flags are equal.

x != y

Checks if two flags are not equal.

x + y

Adds two flags together. Equivalent to x | y.

x - y

Subtracts two flags from each other.

x | y

Returns the union of two flags. Equivalent to x + y.

x & y

Returns the intersection of two flags.

~x

Returns the inverse of a flag.

hash(x)

Return the flag’s hash.

iter(x)

Returns an iterator of (name, value) pairs. This allows it to be, for example, constructed as a dict or a list of pairs.

value#

The raw value. You should query flags via the properties rather than using this raw value.

Type:

int

Parameters:

kwargs (bool) –

classmethod all()[source]#

A factory method that creates a Intents with everything enabled.

classmethod none()[source]#

A factory method that creates a Intents with everything disabled.

classmethod default()[source]#

A factory method that creates a Intents with everything enabled except presences, members, and message_content.

guilds[source]#

Whether guild related events are enabled.

This corresponds to the following events:

This also corresponds to the following attributes and classes in terms of cache:

It is highly advisable to leave this intent enabled for your bot to function.

Type:

bool

members[source]#

Whether guild member related events are enabled.

This corresponds to the following events:

This also corresponds to the following attributes and classes in terms of cache:

For more information go to the member intent documentation.

Note

This intent is privileged, meaning that bots in over 100 guilds that require this intent would need to request this intent on the Developer Portal.

Type:

bool

bans[source]#

Alias of moderation.

Changed in version 2.5: Changed to an alias.

Type:

bool

moderation[source]#

Whether guild moderation related events are enabled.

This corresponds to the following events:

This does not correspond to any attributes or classes in the library in terms of cache.

Type:

bool

emojis[source]#

Alias of emojis_and_stickers.

Changed in version 2.0: Changed to an alias.

Type:

bool

emojis_and_stickers[source]#

Whether guild emoji and sticker related events are enabled.

New in version 2.0.

This corresponds to the following events:

This also corresponds to the following attributes and classes in terms of cache:

Type:

bool

integrations[source]#

Whether guild integration related events are enabled.

This corresponds to the following events:

This does not correspond to any attributes or classes in the library in terms of cache.

Type:

bool

webhooks[source]#

Whether guild webhook related events are enabled.

This corresponds to the following events:

This does not correspond to any attributes or classes in the library in terms of cache.

Type:

bool

invites[source]#

Whether guild invite related events are enabled.

This corresponds to the following events:

This does not correspond to any attributes or classes in the library in terms of cache.

Type:

bool

voice_states[source]#

Whether guild voice state related events are enabled.

This corresponds to the following events:

This also corresponds to the following attributes and classes in terms of cache:

Note

This intent is required to connect to voice.

Type:

bool

presences[source]#

Whether guild presence related events are enabled.

This corresponds to the following events:

This also corresponds to the following attributes and classes in terms of cache:

For more information go to the presence intent documentation.

Note

This intent is privileged, meaning that bots in over 100 guilds that require this intent would need to request this intent on the Developer Portal.

Type:

bool

messages[source]#

Whether guild and direct message related events are enabled.

This is a shortcut to set or get both guild_messages and dm_messages.

This corresponds to the following events:

This also corresponds to the following attributes and classes in terms of cache:

Note that due to an implicit relationship this also corresponds to the following events:

Note

message_content is required to receive the actual content of guild messages.

Type:

bool

guild_messages[source]#

Whether guild message related events are enabled.

See also dm_messages for DMs or messages for both.

This corresponds to the following events:

This also corresponds to the following attributes and classes in terms of cache:

Note that due to an implicit relationship this also corresponds to the following events:

Without the message_content intent enabled, the following fields are either an empty string or empty array:

For more information go to the message content intent documentation.

Type:

bool

dm_messages[source]#

Whether direct message related events are enabled.

See also guild_messages for guilds or messages for both.

This corresponds to the following events:

This also corresponds to the following attributes and classes in terms of cache:

Note that due to an implicit relationship this also corresponds to the following events:

Type:

bool

reactions[source]#

Whether guild and direct message reaction related events are enabled.

This is a shortcut to set or get both guild_reactions and dm_reactions.

This corresponds to the following events:

This also corresponds to the following attributes and classes in terms of cache:

Type:

bool

guild_reactions[source]#

Whether guild message reaction related events are enabled.

See also dm_reactions for DMs or reactions for both.

This corresponds to the following events:

This also corresponds to the following attributes and classes in terms of cache:

Type:

bool

dm_reactions[source]#

Whether direct message reaction related events are enabled.

See also guild_reactions for guilds or reactions for both.

This corresponds to the following events:

This also corresponds to the following attributes and classes in terms of cache:

Type:

bool

typing[source]#

Whether guild and direct message typing related events are enabled.

This is a shortcut to set or get both guild_typing and dm_typing.

This corresponds to the following events:

This does not correspond to any attributes or classes in the library in terms of cache.

Type:

bool

guild_typing[source]#

Whether guild and direct message typing related events are enabled.

See also dm_typing for DMs or typing for both.

This corresponds to the following events:

This does not correspond to any attributes or classes in the library in terms of cache.

Type:

bool

dm_typing[source]#

Whether guild and direct message typing related events are enabled.

See also guild_typing for guilds or typing for both.

This corresponds to the following events:

This does not correspond to any attributes or classes in the library in terms of cache.

Type:

bool

message_content[source]#

Whether the bot will receive message content in guild messages.

This corresponds to the following attributes:

These attributes will still be available for messages received from interactions, the bot’s own messages, messages the bot was mentioned in, and DMs.

New in version 2.0.

Note

As of September 2022 using this intent requires opting in explicitly via the Developer Portal to receive the actual content of the guild messages. This intent is privileged, meaning that bots in over 100 guilds that require this intent would need to request this intent on the Developer Portal. See https://support-dev.discord.com/hc/en-us/articles/4404772028055 for more information.

Type:

bool

scheduled_events[source]#

Whether “scheduled event” related events are enabled.

This corresponds to the following events:

This also corresponds to the following attributes and classes in terms of cache:

Type:

bool

auto_moderation_configuration[source]#

Whether guild auto moderation configuration events are enabled.

This corresponds to the following events:

Type:

bool

auto_moderation_execution[source]#

Whether guild auto moderation execution events are enabled.

This corresponds to the following events:

Type:

bool

Attributes
Methods
class discord.ShardInfo(parent, shard_count)[source]#

A class that gives information and control over a specific shard.

You can retrieve this object via AutoShardedClient.get_shard() or AutoShardedClient.shards.

New in version 1.4.

id#

The shard ID for this shard.

Type:

int

shard_count#

The shard count for this cluster. If this is None then the bot has not started yet.

Type:

Optional[int]

Parameters:
  • parent (Shard) –

  • shard_count (int | None) –

is_closed()[source]#

Whether the shard connection is currently closed.

Return type:

bool

await disconnect()[source]#

This function is a coroutine.

Disconnects a shard. When this is called, the shard connection will no longer be open.

If the shard is already disconnected this does nothing.

Return type:

None

await reconnect()[source]#

This function is a coroutine.

Disconnects and then connects the shard again.

Return type:

None

await connect()[source]#

This function is a coroutine.

Connects a shard. If the shard is already connected this does nothing.

Return type:

None

property latency#

Measures latency between a HEARTBEAT and a HEARTBEAT_ACK in seconds for this shard.

is_ws_ratelimited()[source]#

Whether the websocket is currently rate limited.

This can be useful to know when deciding whether you should query members using HTTP or via the gateway. :rtype: bool

New in version 1.6.

Message#

class discord.AllowedMentions(*, everyone=True, users=True, roles=True, replied_user=True)[source]#

A class that represents what mentions are allowed in a message.

This class can be set during Client initialisation to apply to every message sent. It can also be applied on a per-message basis via abc.Messageable.send() for more fine-grained control.

everyone#

Whether to allow everyone and here mentions. Defaults to True.

Type:

bool

users#

Controls the users being mentioned. If True (the default) then users are mentioned based on the message content. If False then users are not mentioned at all. If a list of abc.Snowflake is given then only the users provided will be mentioned, provided those users are in the message content.

Type:

Union[bool, List[abc.Snowflake]]

roles#

Controls the roles being mentioned. If True (the default) then roles are mentioned based on the message content. If False then roles are not mentioned at all. If a list of abc.Snowflake is given then only the roles provided will be mentioned, provided those roles are in the message content.

Type:

Union[bool, List[abc.Snowflake]]

replied_user#

Whether to mention the author of the message being replied to. Defaults to True.

New in version 1.6.

Type:

bool

classmethod all()[source]#

A factory method that returns a AllowedMentions with all fields explicitly set to True

New in version 1.5.

classmethod none()[source]#

A factory method that returns a AllowedMentions with all fields set to False

New in version 1.5.

class discord.MessageReference(*, message_id, channel_id, guild_id=None, fail_if_not_exists=True)[source]#

Represents a reference to a Message.

New in version 1.5.

Changed in version 1.6: This class can now be constructed by users.

message_id#

The id of the message referenced.

Type:

Optional[int]

channel_id#

The channel id of the message referenced.

Type:

int

guild_id#

The guild id of the message referenced.

Type:

Optional[int]

fail_if_not_exists#

Whether replying to the referenced message should raise HTTPException if the message no longer exists or Discord could not fetch the message.

New in version 1.7.

Type:

bool

resolved#

The message that this reference resolved to. If this is None then the original message was not fetched either due to the Discord API not attempting to resolve it or it not being available at the time of creation. If the message was resolved at a prior point but has since been deleted then this will be of type DeletedReferencedMessage.

Currently, this is mainly the replied to message when a user replies to a message.

New in version 1.6.

Type:

Optional[Union[Message, DeletedReferencedMessage]]

Parameters:
  • message_id (int) –

  • channel_id (int) –

  • guild_id (int | None) –

  • fail_if_not_exists (bool) –

classmethod from_message(message, *, fail_if_not_exists=True)[source]#

Creates a MessageReference from an existing Message.

New in version 1.6.

Parameters:
  • message (Message) – The message to be converted into a reference.

  • fail_if_not_exists (bool) –

    Whether replying to the referenced message should raise HTTPException if the message no longer exists or Discord could not fetch the message.

    New in version 1.7.

Returns:

A reference to the message.

Return type:

MessageReference

property cached_message#

The cached message, if found in the internal message cache.

property jump_url#

Returns a URL that allows the client to jump to the referenced message.

New in version 1.7.

Methods
class discord.PartialMessage(*, channel, id)[source]#

Represents a partial message to aid with working messages when only a message and channel ID are present.

There are two ways to construct this class. The first one is through the constructor itself, and the second is via the following:

Note that this class is trimmed down and has no rich attributes.

New in version 1.6.

x == y

Checks if two partial messages are equal.

x != y

Checks if two partial messages are not equal.

hash(x)

Returns the partial message’s hash.

channel#

The channel associated with this partial message.

Type:

Union[TextChannel, Thread, DMChannel, VoiceChannel, StageChannel]

id#

The message ID.

Type:

int

Parameters:
property jump_url#

Returns a URL that allows the client to jump to this message.

await delete(*, delay=None, reason=None)#

This function is a coroutine.

Deletes the message.

Your own messages could be deleted without any proper permissions. However, to delete other people’s messages, you need the manage_messages permission.

Changed in version 1.1: Added the new delay keyword-only parameter.

Parameters:
  • delay (Optional[float]) – If provided, the number of seconds to wait in the background before deleting the message. If the deletion fails then it is silently ignored.

  • reason (Optional[str]) – The reason for deleting the message. Shows up on the audit log.

Raises:
  • Forbidden – You do not have proper permissions to delete the message.

  • NotFound – The message was deleted already

  • HTTPException – Deleting the message failed.

Return type:

None

await publish()#

This function is a coroutine.

Publishes this message to your announcement channel.

You must have the send_messages permission to do this.

If the message is not your own then the manage_messages permission is also needed.

Raises:
  • Forbidden – You do not have the proper permissions to publish this message.

  • HTTPException – Publishing the message failed.

Return type:

None

await pin(*, reason=None)#

This function is a coroutine.

Pins the message.

You must have the manage_messages permission to do this in a non-private channel context.

Parameters:

reason (Optional[str]) –

The reason for pinning the message. Shows up on the audit log.

New in version 1.4.

Raises:
  • Forbidden – You do not have permissions to pin the message.

  • NotFound – The message or channel was not found or deleted.

  • HTTPException – Pinning the message failed, probably due to the channel having more than 50 pinned messages.

Return type:

None

await unpin(*, reason=None)#

This function is a coroutine.

Unpins the message.

You must have the manage_messages permission to do this in a non-private channel context.

Parameters:

reason (Optional[str]) –

The reason for unpinning the message. Shows up on the audit log.

New in version 1.4.

Raises:
  • Forbidden – You do not have permissions to unpin the message.

  • NotFound – The message or channel was not found or deleted.

  • HTTPException – Unpinning the message failed.

Return type:

None

await add_reaction(emoji)#

This function is a coroutine.

Add a reaction to the message.

The emoji may be a unicode emoji or a custom guild Emoji.

You must have the read_message_history permission to use this. If nobody else has reacted to the message using this emoji, the add_reactions permission is required.

Parameters:

emoji (Union[Emoji, Reaction, PartialEmoji, str]) – The emoji to react with.

Raises:
  • HTTPException – Adding the reaction failed.

  • Forbidden – You do not have the proper permissions to react to the message.

  • NotFound – The emoji you specified was not found.

  • InvalidArgument – The emoji parameter is invalid.

Return type:

None

await remove_reaction(emoji, member)#

This function is a coroutine.

Remove a reaction by the member from the message.

The emoji may be a unicode emoji or a custom guild Emoji.

If the reaction is not your own (i.e. member parameter is not you) then the manage_messages permission is needed.

The member parameter must represent a member and meet the abc.Snowflake abc.

Parameters:
Raises:
  • HTTPException – Removing the reaction failed.

  • Forbidden – You do not have the proper permissions to remove the reaction.

  • NotFound – The member or emoji you specified was not found.

  • InvalidArgument – The emoji parameter is invalid.

Return type:

None

await clear_reaction(emoji)#

This function is a coroutine.

Clears a specific reaction from the message.

The emoji may be a unicode emoji or a custom guild Emoji.

You need the manage_messages permission to use this.

New in version 1.3.

Parameters:

emoji (Union[Emoji, Reaction, PartialEmoji, str]) – The emoji to clear.

Raises:
  • HTTPException – Clearing the reaction failed.

  • Forbidden – You do not have the proper permissions to clear the reaction.

  • NotFound – The emoji you specified was not found.

  • InvalidArgument – The emoji parameter is invalid.

Return type:

None

await clear_reactions()#

This function is a coroutine.

Removes all the reactions from the message.

You need the manage_messages permission to use this.

Raises:
  • HTTPException – Removing the reactions failed.

  • Forbidden – You do not have the proper permissions to remove all the reactions.

Return type:

None

await reply(content=None, **kwargs)#

This function is a coroutine.

A shortcut method to abc.Messageable.send() to reply to the Message.

New in version 1.6.

Returns:

The message that was sent.

Return type:

Message

Raises:
  • HTTPException – Sending the message failed.

  • Forbidden – You do not have the proper permissions to send the message.

  • InvalidArgument – The files list is not of the appropriate size, or you specified both file and files.

Parameters:

content (str | None) –

to_reference(*, fail_if_not_exists=True)#

Creates a MessageReference from the current message.

New in version 1.6.

Parameters:

fail_if_not_exists (bool) –

Whether replying using the message reference should raise HTTPException if the message no longer exists or Discord could not fetch the message.

New in version 1.7.

Returns:

The reference to this message.

Return type:

MessageReference

property created_at#

The partial message’s creation time in UTC.

guild#

The guild that the partial message belongs to, if applicable.

await fetch()[source]#

This function is a coroutine.

Fetches the partial message to a full Message.

Returns:

The full message.

Return type:

Message

Raises:
  • NotFound – The message was not found.

  • Forbidden – You do not have the permissions required to get a message.

  • HTTPException – Retrieving the message failed.

await edit(**fields)[source]#

This function is a coroutine.

Edits the message.

Changed in version 1.7: discord.Message is returned instead of None if an edit took place.

Parameters:
  • content (Optional[str]) – The new content to replace the message with. Could be None to remove the content.

  • embed (Optional[Embed]) – The new embed to replace the original with. Could be None to remove the embed.

  • embeds (Optional[List[Embed]]) –

    A list of embeds to upload. Must be a maximum of 10.

    New in version 2.0.

  • suppress (bool) – Whether to suppress embeds for the message. This removes all the embeds if set to True. If set to False this brings the embeds back if they were suppressed. Using this parameter requires manage_messages.

  • delete_after (Optional[float]) – If provided, the number of seconds to wait in the background before deleting the message we just edited. If the deletion fails, then it is silently ignored.

  • allowed_mentions (Optional[AllowedMentions]) – Controls the mentions being processed in this message. If this is passed, then the object is merged with allowed_mentions. The merging behaviour only overrides attributes that have been explicitly passed to the object, otherwise it uses the attributes set in allowed_mentions. If no object is passed at all then the defaults given by allowed_mentions are used instead.

  • view (Optional[View]) –

    The updated view to update this message with. If None is passed then the view is removed.

    New in version 2.0.

  • fields (Any) –

Returns:

The message that was edited.

Return type:

Optional[Message]

Raises:
  • NotFound – The message was not found.

  • HTTPException – Editing the message failed.

  • Forbidden – Tried to suppress a message without permissions or edited a message’s content or embed that isn’t yours.

class discord.File(fp, filename=None, *, description=None, spoiler=False)[source]#

A parameter object used for abc.Messageable.send() for sending file objects.

Note

File objects are single use and are not meant to be reused in multiple abc.Messageable.send()s.

fp#

A file-like object opened in binary mode and read mode or a filename representing a file in the hard drive to open.

Note

If the file-like object passed is opened via open then the modes ‘rb’ should be used.

To pass binary data, consider usage of io.BytesIO.

Type:

Union[os.PathLike, io.BufferedIOBase]

filename#

The filename to display when uploading to Discord. If this is not given then it defaults to fp.name or if fp is a string then the filename will default to the string given.

Type:

Optional[str]

description#

The description of a file, used by Discord to display alternative text on images.

Type:

Optional[str]

spoiler#

Whether the attachment is a spoiler.

Type:

bool

Parameters:

Embed#

class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None, fields=None, author=None, footer=None, image=None, thumbnail=None)[source]#

Represents a Discord embed.

len(x)

Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.

bool(b)

Returns whether the embed has any data set.

New in version 2.0.

For ease of use, all parameters that expect a str are implicitly cast to str for you.

title#

The title of the embed. This can be set during initialisation. Must be 256 characters or fewer.

Type:

str

type#

The type of embed. Usually “rich”. This can be set during initialisation. Possible strings for embed types can be found on discord’s api docs

Type:

str

description#

The description of the embed. This can be set during initialisation. Must be 4096 characters or fewer.

Type:

str

url#

The URL of the embed. This can be set during initialisation.

Type:

str

timestamp#

The timestamp of the embed content. This is an aware datetime. If a naive datetime is passed, it is converted to an aware datetime with the local timezone.

Type:

datetime.datetime

colour#

The colour code of the embed. Aliased to color as well. This can be set during initialisation.

Type:

Union[Colour, int]

Parameters:
classmethod from_dict(data)[source]#

Converts a dict to a Embed provided it is in the format that Discord expects it to be in.

You can find out about this format in the official Discord documentation.

Parameters:

data (dict) – The dictionary to convert into an embed.

Returns:

The converted embed object.

Return type:

Embed

copy()[source]#

Creates a shallow copy of the Embed object.

Returns:

The copied embed object.

Return type:

Embed

Parameters:

self (TypeVar(E, bound= Embed)) –

property footer#

Returns an EmbedFooter denoting the footer contents.

See set_footer() for possible values you can access.

If the footer is not set then None is returned.

Sets the footer for the embed content.

This function returns the class instance to allow for fluent-style chaining.

Parameters:
  • text (str) – The footer text. Must be 2048 characters or fewer.

  • icon_url (str) – The URL of the footer icon. Only HTTP(S) is supported.

  • self (E) –

Return type:

E

Clears embed’s footer information.

This function returns the class instance to allow for fluent-style chaining.

New in version 2.0.

Parameters:

self (TypeVar(E, bound= Embed)) –

Return type:

TypeVar(E, bound= Embed)

property image#

Returns an EmbedMedia denoting the image contents.

Attributes you can access are:

  • url

  • proxy_url

  • width

  • height

If the image is not set then None is returned.

set_image(*, url)[source]#

Sets the image for the embed content.

This function returns the class instance to allow for fluent-style chaining.

Changed in version 1.4: Passing None removes the image.

Parameters:
  • url (str) – The source URL for the image. Only HTTP(S) is supported.

  • self (E) –

Return type:

E

remove_image()[source]#

Removes the embed’s image.

This function returns the class instance to allow for fluent-style chaining.

New in version 2.0.

Parameters:

self (TypeVar(E, bound= Embed)) –

Return type:

TypeVar(E, bound= Embed)

property thumbnail#

Returns an EmbedMedia denoting the thumbnail contents.

Attributes you can access are:

  • url

  • proxy_url

  • width

  • height

If the thumbnail is not set then None is returned.

set_thumbnail(*, url)[source]#

Sets the thumbnail for the embed content.

This function returns the class instance to allow for fluent-style chaining.

Changed in version 1.4: Passing None removes the thumbnail.

Parameters:
  • url (str) – The source URL for the thumbnail. Only HTTP(S) is supported.

  • self (E) –

Return type:

E

remove_thumbnail()[source]#

Removes the embed’s thumbnail.

This function returns the class instance to allow for fluent-style chaining.

New in version 2.0.

Parameters:

self (TypeVar(E, bound= Embed)) –

Return type:

TypeVar(E, bound= Embed)

property video#

Returns an EmbedMedia denoting the video contents.

Attributes include:

  • url for the video URL.

  • height for the video height.

  • width for the video width.

If the video is not set then None is returned.

property provider#

Returns an EmbedProvider denoting the provider contents.

The only attributes that might be accessed are name and url.

If the provider is not set then None is returned.

property author#

Returns an EmbedAuthor denoting the author contents.

See set_author() for possible values you can access.

If the author is not set then None is returned.

set_author(*, name, url=None, icon_url=None)[source]#

Sets the author for the embed content.

This function returns the class instance to allow for fluent-style chaining.

Parameters:
  • name (str) – The name of the author. Must be 256 characters or fewer.

  • url (str) – The URL for the author.

  • icon_url (str) – The URL of the author icon. Only HTTP(S) is supported.

  • self (E) –

Return type:

E

remove_author()[source]#

Clears embed’s author information.

This function returns the class instance to allow for fluent-style chaining.

New in version 1.4.

Parameters:

self (TypeVar(E, bound= Embed)) –

Return type:

TypeVar(E, bound= Embed)

property fields#

Returns a list of EmbedField objects denoting the field contents.

See add_field() for possible values you can access.

If the attribute has no value then None is returned.

append_field(field)[source]#

Appends an EmbedField object to the embed.

New in version 2.0.

Parameters:

field (EmbedField) – The field to add.

Return type:

None

add_field(*, name, value, inline=True)[source]#

Adds a field to the embed object.

This function returns the class instance to allow for fluent-style chaining. There must be 25 fields or fewer.

Parameters:
  • name (str) – The name of the field. Must be 256 characters or fewer.

  • value (str) – The value of the field. Must be 1024 characters or fewer.

  • inline (bool) – Whether the field should be displayed inline.

  • self (TypeVar(E, bound= Embed)) –

Return type:

TypeVar(E, bound= Embed)

insert_field_at(index, *, name, value, inline=True)[source]#

Inserts a field before a specified index to the embed.

This function returns the class instance to allow for fluent-style chaining. There must be 25 fields or fewer.

New in version 1.2.

Parameters:
  • index (int) – The index of where to insert the field.

  • name (str) – The name of the field. Must be 256 characters or fewer.

  • value (str) – The value of the field. Must be 1024 characters or fewer.

  • inline (bool) – Whether the field should be displayed inline.

  • self (TypeVar(E, bound= Embed)) –

Return type:

TypeVar(E, bound= Embed)

clear_fields()[source]#

Removes all fields from this embed.

Return type:

None

remove_field(index)[source]#

Removes a field at a specified index.

If the index is invalid or out of bounds then the error is silently swallowed.

Note

When deleting a field by index, the index of the other fields shift to fill the gap just like a regular list.

Parameters:

index (int) – The index of the field to remove.

Return type:

None

set_field_at(index, *, name, value, inline=True)[source]#

Modifies a field to the embed object.

The index must point to a valid pre-existing field. There must be 25 fields or fewer.

This function returns the class instance to allow for fluent-style chaining.

Parameters:
  • index (int) – The index of the field to modify.

  • name (str) – The name of the field. Must be 256 characters or fewer.

  • value (str) – The value of the field. Must be 1024 characters or fewer.

  • inline (bool) – Whether the field should be displayed inline.

  • self (TypeVar(E, bound= Embed)) –

Raises:

IndexError – An invalid index was provided.

Return type:

TypeVar(E, bound= Embed)

to_dict()[source]#

Converts this embed object into a dict.

Returns:

A dictionary of str embed keys bound to the respective value.

Return type:

Dict[str, Union[str, int, bool]]

Attributes
class discord.EmbedField(name, value, inline=False)[source]#

Represents a field on the Embed object.

New in version 2.0.

name#

The name of the field.

Type:

str

value#

The value of the field.

Type:

str

inline#

Whether the field should be displayed inline.

Type:

bool

Parameters:
  • name (str) –

  • value (str) –

  • inline (bool | None) –

classmethod from_dict(data)[source]#

Converts a dict to a EmbedField provided it is in the format that Discord expects it to be in.

You can find out about this format in the official Discord documentation.

Parameters:

data (dict) – The dictionary to convert into an EmbedField object.

Return type:

EmbedField

to_dict()[source]#

Converts this EmbedField object into a dict.

Returns:

A dictionary of str embed field keys bound to the respective value.

Return type:

Dict[str, Union[str, bool]]

class discord.EmbedAuthor(name, url=None, icon_url=None)[source]#

Represents the author on the Embed object.

New in version 2.5.

name#

The name of the author.

Type:

str

url#

The URL of the hyperlink created in the author’s name.

Type:

str

icon_url#

The URL of the author icon image.

Type:

str

proxy_icon_url#

The proxied URL of the author icon image. This can’t be set directly, it is set by Discord.

Type:

str

Parameters:
  • name (str) –

  • url (str | None) –

  • icon_url (str | None) –

class discord.EmbedFooter(text, icon_url=None)[source]#

Represents the footer on the Embed object.

New in version 2.5.

text#

The text inside the footer.

Type:

str

icon_url#

The URL of the footer icon image.

Type:

str

proxy_icon_url#

The proxied URL of the footer icon image. This can’t be set directly, it is set by Discord.

Type:

str

Parameters:
  • text (str) –

  • icon_url (str | None) –

Attributes
class discord.EmbedMedia(url)[source]#

Represents a media on the Embed object. This includes thumbnails, images, and videos.

New in version 2.5.

url#

The source URL of the media.

Type:

str

proxy_url#

The proxied URL of the media.

Type:

str

height#

The height of the media.

Type:

int

width#

The width of the media.

Type:

int

Parameters:

url (str) –

Attributes
class discord.EmbedProvider[source]#

Represents a provider on the Embed object.

New in version 2.5.

name#

The name of the provider.

Type:

str

url#

The URL of the provider.

Type:

str

Flags#

class discord.MemberCacheFlags(**kwargs)[source]#

Controls the library’s cache policy when it comes to members.

This allows for finer grained control over what members are cached. Note that the bot’s own member is always cached. This class is passed to the member_cache_flags parameter in Client.

Due to a quirk in how Discord works, in order to ensure proper cleanup of cache resources it is recommended to have Intents.members enabled. Otherwise, the library cannot know when a member leaves a guild and is thus unable to clean up after itself.

To construct an object you can pass keyword arguments denoting the flags to enable or disable.

The default value is all flags enabled.

New in version 1.5.

x == y

Checks if two flags are equal.

x != y

Checks if two flags are not equal.

x + y

Adds two flags together. Equivalent to x | y.

x - y

Subtracts two flags from each other.

x | y

Returns the union of two flags. Equivalent to x + y.

x & y

Returns the intersection of two flags.

~x

Returns the inverse of a flag.

hash(x)

Return the flag’s hash.

iter(x)

Returns an iterator of (name, value) pairs. This allows it to be, for example, constructed as a dict or a list of pairs.

value#

The raw value. You should query flags via the properties rather than using this raw value.

Type:

int

Parameters:

kwargs (bool) –

classmethod all()[source]#

A factory method that creates a MemberCacheFlags with everything enabled.

classmethod none()[source]#

A factory method that creates a MemberCacheFlags with everything disabled.

voice[source]#

Whether to cache members that are in voice.

This requires Intents.voice_states.

Members that leave voice are no longer cached.

Type:

bool

joined[source]#

Whether to cache members that joined the guild or are chunked as part of the initial log in flow.

This requires Intents.members.

Members that leave the guild are no longer cached.

Type:

bool

interaction[source]#

Whether to cache members obtained through interactions.

This includes members received through discord.Interaction and discord.Option.

Type:

bool

classmethod from_intents(intents)[source]#

A factory method that creates a MemberCacheFlags based on the currently selected Intents.

Parameters:

intents (Intents) – The intents to select from.

Returns:

The resulting member cache flags.

Return type:

MemberCacheFlags

class discord.ApplicationFlags(**kwargs)[source]#

Wraps up the Discord Application flags.

x == y

Checks if two ApplicationFlags are equal.

x != y

Checks if two ApplicationFlags are not equal.

x + y

Adds two flags together. Equivalent to x | y.

x - y

Subtracts two flags from each other.

x | y

Returns the union of two flags. Equivalent to x + y.

x & y

Returns the intersection of two flags.

~x

Returns the inverse of a flag.

hash(x)

Return the flag’s hash.

iter(x)

Returns an iterator of (name, value) pairs. This allows it to be, for example, constructed as a dict or a list of pairs. Note that aliases are not shown.

New in version 2.0.

value#

The raw value. You should query flags via the properties rather than using this raw value.

Type:

int

Parameters:

kwargs (bool) –

managed_emoji[source]#

Returns True if the application is a managed emoji.

Type:

bool

group_dm_create[source]#

Returns True if the application can create group DMs.

Type:

bool

application_auto_moderation_rule_create_badge[source]#

Returns True if the application uses the Auto Moderation API.

New in version 2.5.

Type:

bool

rpc_has_connected[source]#

Returns True if the application has connected to RPC.

Type:

bool

gateway_presence[source]#

Returns True if the application is verified and is allowed to receive presence information over the gateway.

Type:

bool

gateway_presence_limited[source]#

Returns True if the application is allowed to receive limited presence information over the gateway.

Type:

bool

gateway_guild_members[source]#

Returns True if the application is verified and is allowed to receive guild members information over the gateway.

Type:

bool

gateway_guild_members_limited[source]#

Returns True if the application is allowed to receive limited guild members information over the gateway.

Type:

bool

verification_pending_guild_limit[source]#

Returns True if the application is currently pending verification and has hit the guild limit.

Type:

bool

embedded[source]#

Returns True if the application is embedded within the Discord client.

Type:

bool

gateway_message_content[source]#

Returns True if the application is allowed to read message contents in guilds.

Type:

bool

gateway_message_content_limited[source]#

Returns True if the application is currently pending verification and has hit the guild limit.

Type:

bool

app_commands_badge[source]#

Returns True if the application has registered at least one global application command, and by extension has the badge.

New in version 2.1.

Type:

bool

active[source]#

Returns True if the app is considered active. Applications are considered active if they have had any command executions in the past 30 days.

New in version 2.3.

Type:

bool

class discord.SystemChannelFlags(**kwargs)[source]#

Wraps up a Discord system channel flag value.

Similar to Permissions, the properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools. This allows you to edit the system flags easily.

To construct an object you can pass keyword arguments denoting the flags to enable or disable.

x == y

Checks if two flags are equal.

x != y

Checks if two flags are not equal.

x + y

Adds two flags together. Equivalent to x | y.

x - y

Subtracts two flags from each other.

x | y

Returns the union of two flags. Equivalent to x + y.

x & y

Returns the intersection of two flags.

~x

Returns the inverse of a flag.

hash(x)

Return the flag’s hash.

iter(x)

Returns an iterator of (name, value) pairs. This allows it to be, for example, constructed as a dict or a list of pairs.

value#

The raw value. This value is a bit array field of a 53-bit integer representing the currently available flags. You should query flags via the properties rather than using this raw value.

Type:

int

Parameters:

kwargs (bool) –

join_notifications[source]#

Returns True if the system channel is used for member join notifications.

Type:

bool

premium_subscriptions[source]#

Returns True if the system channel is used for “Nitro boosting” notifications.

Type:

bool

guild_reminder_notifications[source]#

Returns True if the system channel is used for server setup helpful tips notifications.

New in version 2.0.

Type:

bool

join_notification_replies[source]#

Returns True if the system channel is allowing member join sticker replies.

New in version 2.0.

Type:

bool

class discord.MessageFlags(**kwargs)[source]#

Wraps up a Discord Message flag value.

See SystemChannelFlags.

x == y

Checks if two flags are equal.

x != y

Checks if two flags are not equal.

x + y

Adds two flags together. Equivalent to x | y.

x - y

Subtracts two flags from each other.

x | y

Returns the union of two flags. Equivalent to x + y.

x & y

Returns the intersection of two flags.

~x

Returns the inverse of a flag.

hash(x)

Return the flag’s hash.

iter(x)

Returns an iterator of (name, value) pairs. This allows it to be, for example, constructed as a dict or a list of pairs.

New in version 1.3.

value#

The raw value. This value is a bit array field of a 53-bit integer representing the currently available flags. You should query flags via the properties rather than using this raw value.

Type:

int

Parameters:

kwargs (bool) –

crossposted[source]#

Returns True if the message is the original crossposted message.

Type:

bool

is_crossposted[source]#

Returns True if the message was crossposted from another channel.

Type:

bool

suppress_embeds[source]#

Returns True if the message’s embeds have been suppressed.

Type:

bool

source_message_deleted[source]#

Returns True if the source message for this crosspost has been deleted.

Type:

bool

urgent[source]#

Returns True if the source message is an urgent message.

An urgent message is one sent by Discord Trust and Safety.

Type:

bool

has_thread[source]#

Returns True if the source message is associated with a thread.

New in version 2.0.

Type:

bool

ephemeral[source]#

Returns True if the source message is ephemeral.

New in version 2.0.

Type:

bool

loading[source]#

Returns True if the source message is deferred.

The user sees a ‘thinking’ state.

New in version 2.0.

Type:

bool

failed_to_mention_some_roles_in_thread[source]#

Returns True if some roles are failed to mention in a thread.

New in version 2.0.

Type:

bool

suppress_notifications[source]#

Returns True if the source message does not trigger push and desktop notifications.

Users will still receive mentions.

New in version 2.4.

Type:

bool

is_voice_message[source]#

Returns True if this message is a voice message.

New in version 2.5.

Type:

bool

class discord.AttachmentFlags(**kwargs)[source]#

Wraps up the Discord Attachment flags.

x == y

Checks if two flags are equal.

x != y

Checks if two flags are not equal.

x + y

Adds two flags together. Equivalent to x | y.

x - y

Subtracts two flags from each other.

x | y

Returns the union of two flags. Equivalent to x + y.

x & y

Returns the intersection of two flags.

~x

Returns the inverse of a flag.

hash(x)

Return the flag’s hash.

iter(x)

Returns an iterator of (name, value) pairs. This allows it to be, for example, constructed as a dict or a list of pairs. Note that aliases are not shown.

New in version 2.5.

value#

The raw value. You should query flags via the properties rather than using this raw value.

Type:

int

Parameters:

kwargs (bool) –

is_clip[source]#

Returns True if the attachment is a clip.

Type:

bool

is_thumbnail[source]#

Returns True if the attachment is a thumbnail.

Type:

bool

is_remix[source]#

Returns True if the attachment has been remixed.

Type:

bool

class discord.PublicUserFlags(**kwargs)[source]#

Wraps up the Discord User Public flags.

x == y

Checks if two PublicUserFlags are equal.

x != y

Checks if two PublicUserFlags are not equal.

x + y

Adds two flags together. Equivalent to x | y.

x - y

Subtracts two flags from each other.

x | y

Returns the union of two flags. Equivalent to x + y.

x & y

Returns the intersection of two flags.

~x

Returns the inverse of a flag.

hash(x)

Return the flag’s hash.

iter(x)

Returns an iterator of (name, value) pairs. This allows it to be, for example, constructed as a dict or a list of pairs. Note that aliases are not shown.

New in version 1.4.

value#

The raw value. This value is a bit array field of a 53-bit integer representing the currently available flags. You should query flags via the properties rather than using this raw value.

Type:

int

Parameters:

kwargs (bool) –

staff[source]#

Returns True if the user is a Discord Employee.

Type:

bool

partner[source]#

Returns True if the user is a Discord Partner.

Type:

bool

hypesquad[source]#

Returns True if the user is a HypeSquad Events member.

Type:

bool

bug_hunter[source]#

Returns True if the user is a Bug Hunter

Type:

bool

premium_promo_dismissed[source]#

Returns True if the user is marked as dismissed Nitro promotion

Type:

bool

hypesquad_bravery[source]#

Returns True if the user is a HypeSquad Bravery member.

Type:

bool

hypesquad_brilliance[source]#

Returns True if the user is a HypeSquad Brilliance member.

Type:

bool

hypesquad_balance[source]#

Returns True if the user is a HypeSquad Balance member.

Type:

bool

early_supporter[source]#

Returns True if the user is an Early Supporter.

Type:

bool

team_user[source]#

Returns True if the user is a Team User.

Type:

bool

system[source]#

Returns True if the user is a system user (i.e. represents Discord officially).

Type:

bool

bug_hunter_level_2[source]#

Returns True if the user is a Bug Hunter Level 2

Type:

bool

verified_bot[source]#

Returns True if the user is a Verified Bot.

Type:

bool

verified_bot_developer[source]#

Returns True if the user is an Early Verified Bot Developer.

Type:

bool

early_verified_bot_developer[source]#

An alias for verified_bot_developer.

New in version 1.5.

Type:

bool

discord_certified_moderator[source]#

Returns True if the user is a Discord Certified Moderator.

New in version 2.0.

Type:

bool

bot_http_interactions[source]#

Returns True if the bot has set an interactions endpoint url.

New in version 2.0.

Type:

bool

active_developer[source]#

Returns True if the user is an Active Developer.

New in version 2.3.

Type:

bool

all()[source]#

List[UserFlags]: Returns all public flags the user has.

Attributes
class discord.ChannelFlags(**kwargs)[source]#

Wraps up the Discord Channel flags.

x == y

Checks if two ChannelFlags are equal.

x != y

Checks if two ChannelFlags are not equal.

x + y

Adds two flags together. Equivalent to x | y.

x - y

Subtracts two flags from each other.

x | y

Returns the union of two flags. Equivalent to x + y.

x & y

Returns the intersection of two flags.

~x

Returns the inverse of a flag.

hash(x)

Return the flag’s hash.

iter(x)

Returns an iterator of (name, value) pairs. This allows it to be, for example, constructed as a dict or a list of pairs. Note that aliases are not shown.

New in version 2.0.

value#

The raw value. You should query flags via the properties rather than using this raw value.

Type:

int

Parameters:

kwargs (bool) –

pinned[source]#

Returns True if the thread is pinned to the top of its parent forum channel.

Type:

bool

require_tag[source]#

Returns True if a tag is required to be specified when creating a thread in a ForumChannel.

New in version 2.2.

Type:

bool

class discord.SKUFlags(**kwargs)[source]#

Wraps up the Discord SKU flags.

x == y

Checks if two SKUFlags are equal.

x != y

Checks if two SKUFlags are not equal.

x + y

Adds two flags together. Equivalent to x | y.

x - y

Subtracts two flags from each other.

x | y

Returns the union of two flags. Equivalent to x + y.

x & y

Returns the intersection of two flags.

~x

Returns the inverse of a flag.

hash(x)

Return the flag’s hash.

iter(x)

Returns an iterator of (name, value) pairs. This allows it to be, for example, constructed as a dict or a list of pairs. Note that aliases are not shown.

New in version 2.5.

value#

The raw value. You should query flags via the properties rather than using this raw value.

Type:

int

Parameters:

kwargs (bool) –

available[source]#

Returns True if the SKU is available for purchase.

Type:

bool

guild_subscription[source]#

Returns True if the SKU is a guild subscription.

Type:

bool

user_subscription[source]#

Returns True if the SKU is a user subscription.

Type:

bool

Colour#

class discord.Colour(value)[source]#

Represents a Discord role colour. This class is similar to a (red, green, blue) tuple.

There is an alias for this called Color.

x == y

Checks if two colours are equal.

x != y

Checks if two colours are not equal.

hash(x)

Return the colour’s hash.

str(x)

Returns the hex format for the colour.

int(x)

Returns the raw colour value.

value#

The raw integer colour value.

Type:

int

Parameters:

value (int) –

property r#

Returns the red component of the colour.

property g#

Returns the green component of the colour.

property b#

Returns the blue component of the colour.

to_rgb()[source]#

Returns an (r, g, b) tuple representing the colour.

classmethod from_rgb(r, g, b)[source]#

Constructs a Colour from an RGB tuple.

classmethod from_hsv(h, s, v)[source]#

Constructs a Colour from an HSV tuple.

classmethod default()[source]#

A factory method that returns a Colour with a value of 0.

classmethod random(*, seed=None)[source]#

A factory method that returns a Colour with a random hue.

Note

The random algorithm works by choosing a colour with a random hue but with maxed out saturation and value.

New in version 1.6.

Parameters:

seed (Optional[Union[int, str, float, bytes, bytearray]]) –

The seed to initialize the RNG with. If None is passed the default RNG is used.

New in version 1.7.

classmethod teal()[source]#

A factory method that returns a Colour with a value of 0x1abc9c.

classmethod dark_teal()[source]#

A factory method that returns a Colour with a value of 0x11806a.

classmethod brand_green()[source]#

A factory method that returns a Colour with a value of 0x57F287.

New in version 2.0.

classmethod green()[source]#

A factory method that returns a Colour with a value of 0x2ecc71.

classmethod dark_green()[source]#

A factory method that returns a Colour with a value of 0x1f8b4c.

classmethod blue()[source]#

A factory method that returns a Colour with a value of 0x3498db.

classmethod dark_blue()[source]#

A factory method that returns a Colour with a value of 0x206694.

classmethod purple()[source]#

A factory method that returns a Colour with a value of 0x9b59b6.

classmethod dark_purple()[source]#

A factory method that returns a Colour with a value of 0x71368a.

classmethod magenta()[source]#

A factory method that returns a Colour with a value of 0xe91e63.

classmethod dark_magenta()[source]#

A factory method that returns a Colour with a value of 0xad1457.

classmethod gold()[source]#

A factory method that returns a Colour with a value of 0xf1c40f.

classmethod dark_gold()[source]#

A factory method that returns a Colour with a value of 0xc27c0e.

classmethod orange()[source]#

A factory method that returns a Colour with a value of 0xe67e22.

classmethod dark_orange()[source]#

A factory method that returns a Colour with a value of 0xa84300.

classmethod brand_red()[source]#

A factory method that returns a Colour with a value of 0xED4245.

New in version 2.0.

classmethod red()[source]#

A factory method that returns a Colour with a value of 0xe74c3c.

classmethod dark_red()[source]#

A factory method that returns a Colour with a value of 0x992d22.

classmethod lighter_grey()[source]#

A factory method that returns a Colour with a value of 0x95a5a6.

classmethod lighter_gray()#

A factory method that returns a Colour with a value of 0x95a5a6.

classmethod dark_grey()[source]#

A factory method that returns a Colour with a value of 0x607d8b.

classmethod dark_gray()#

A factory method that returns a Colour with a value of 0x607d8b.

classmethod light_grey()[source]#

A factory method that returns a Colour with a value of 0x979c9f.

classmethod light_gray()#

A factory method that returns a Colour with a value of 0x979c9f.

classmethod darker_grey()[source]#

A factory method that returns a Colour with a value of 0x546e7a.

classmethod darker_gray()#

A factory method that returns a Colour with a value of 0x546e7a.

classmethod og_blurple()[source]#

A factory method that returns a Colour with a value of 0x7289da.

classmethod blurple()[source]#

A factory method that returns a Colour with a value of 0x5865F2.

classmethod greyple()[source]#

A factory method that returns a Colour with a value of 0x99aab5.

classmethod dark_theme()[source]#

A factory method that returns a Colour with a value of 0x36393F. This will appear transparent on Discord’s dark theme.

New in version 1.5.

classmethod fuchsia()[source]#

A factory method that returns a Colour with a value of 0xEB459E.

New in version 2.0.

classmethod yellow()[source]#

A factory method that returns a Colour with a value of 0xFEE75C.

New in version 2.0.

classmethod nitro_pink()[source]#

A factory method that returns a Colour with a value of 0xf47fff.

New in version 2.0.

classmethod embed_background(theme='dark')[source]#

A factory method that returns a Colour corresponding to the embed colours on discord clients, with a value of:

  • 0x2B2D31 (dark)

  • 0xEEEFF1 (light)

  • 0x000000 (amoled).

New in version 2.0.

Parameters:

theme (str) – The theme colour to apply, must be one of “dark”, “light”, or “amoled”.

Activity#

class discord.Activity(**kwargs)[source]#

Represents an activity in Discord.

This could be an activity such as streaming, playing, listening or watching.

For memory optimisation purposes, some activities are offered in slimmed down versions:

application_id#

The application ID of the game.

Type:

Optional[int]

name#

The name of the activity.

Type:

Optional[str]

url#

A stream URL that the activity could be doing.

Type:

Optional[str]

type#

The type of activity currently being done.

Type:

ActivityType

state#

The user’s current party status or text used for a custom status.

Type:

Optional[str]

details#

The detail of the user’s current activity.

Type:

Optional[str]

timestamps#

A dictionary of timestamps. It contains the following optional keys:

  • start: Corresponds to when the user started doing the activity in milliseconds since Unix epoch.

  • end: Corresponds to when the user will finish doing the activity in milliseconds since Unix epoch.

Type:

Dict[str, int]

assets#

A dictionary representing the images and their hover text of an activity. It contains the following optional keys:

  • large_image: A string representing the ID for the large image asset.

  • large_text: A string representing the text when hovering over the large image asset.

  • small_image: A string representing the ID for the small image asset.

  • small_text: A string representing the text when hovering over the small image asset.

Type:

Dict[str, str]

party#

A dictionary representing the activity party. It contains the following optional keys:

  • id: A string representing the party ID.

  • size: A list of up to two integer elements denoting (current_size, maximum_size).

Type:

Dict[str, Union[str, List[int]]]

buttons#

A list of dictionaries representing custom buttons shown in a rich presence. Each dictionary contains the following keys:

  • label: A string representing the text shown on the button.

  • url: A string representing the URL opened upon clicking the button.

Note

Bots cannot access a user’s activity button URLs. Therefore, the type of this attribute will be List[str] when received through the gateway.

New in version 2.0.

Type:

Union[List[Dict[str, str]], List[str]]

emoji#

The emoji that belongs to this activity.

Type:

Optional[PartialEmoji]

property start#

When the user started doing this activity in UTC, if applicable.

property end#

When the user will stop doing this activity in UTC, if applicable.

property large_image_url#

Returns a URL pointing to the large image asset of this activity if applicable.

property small_image_url#

Returns a URL pointing to the small image asset of this activity if applicable.

property large_image_text#

Returns the large image asset hover text of this activity if applicable.

property small_image_text#

Returns the small image asset hover text of this activity if applicable.

Attributes
class discord.BaseActivity(**kwargs)[source]#

The base activity that all user-settable activities inherit from. A user-settable activity is one that can be used in Client.change_presence().

The following types currently count as user-settable:

Note that although these types are considered user-settable by the library, Discord typically ignores certain combinations of activity depending on what is currently set. This behaviour may change in the future so there are no guarantees on whether Discord will actually let you set these types.

New in version 1.3.

property created_at#

When the user started doing this activity in UTC.

New in version 1.3.

Attributes
class discord.Game(name, **extra)[source]#

A slimmed down version of Activity that represents a Discord game.

This is typically displayed via Playing on the official Discord client.

x == y

Checks if two games are equal.

x != y

Checks if two games are not equal.

hash(x)

Returns the game’s hash.

str(x)

Returns the game’s name.

Parameters:

name (str) – The game’s name.

name#

The game’s name.

Type:

str

property type#

Returns the game’s type. This is for compatibility with Activity.

It always returns ActivityType.playing.

property start#

When the user started playing this game in UTC, if applicable.

property end#

When the user will stop playing this game in UTC, if applicable.

class discord.Streaming(*, name, url, **extra)[source]#

A slimmed down version of Activity that represents a Discord streaming status.

This is typically displayed via Streaming on the official Discord client.

x == y

Checks if two streams are equal.

x != y

Checks if two streams are not equal.

hash(x)

Returns the stream’s hash.

str(x)

Returns the stream’s name.

platform#

Where the user is streaming from (ie. YouTube, Twitch).

New in version 1.3.

Type:

Optional[str]

name#

The stream’s name.

Type:

Optional[str]

details#

An alias for name

Type:

Optional[str]

game#

The game being streamed.

New in version 1.3.

Type:

Optional[str]

url#

The stream’s URL.

Type:

str

assets#

A dictionary comprised of similar keys than those in Activity.assets.

Type:

Dict[str, str]

Parameters:
  • name (str | None) –

  • url (str) –

  • extra (Any) –

property type#

Returns the game’s type. This is for compatibility with Activity.

It always returns ActivityType.streaming.

property twitch_name#

If provided, the twitch name of the user streaming.

This corresponds to the large_image key of the Streaming.assets dictionary if it starts with twitch:. Typically this is set by the Discord client.

Attributes
class discord.CustomActivity(name, *, emoji=None, **extra)[source]#

Represents a Custom activity from Discord.

x == y

Checks if two activities are equal.

x != y

Checks if two activities are not equal.

hash(x)

Returns the activity’s hash.

str(x)

Returns the custom status text.

New in version 1.3.

name#

The custom activity’s name.

Type:

Optional[str]

emoji#

The emoji to pass to the activity, if any.

Type:

Optional[PartialEmoji]

state#

The text used for the custom activity.

Type:

Optional[str]

Parameters:
property type#

Returns the activity’s type. This is for compatibility with Activity.

It always returns ActivityType.custom.

Permissions#

class discord.Permissions(permissions=0, **kwargs)[source]#

Wraps up the Discord permission value.

The properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools. This allows you to edit permissions.

Changed in version 1.3: You can now use keyword arguments to initialize Permissions similar to update().

x == y

Checks if two permissions are equal.

x != y

Checks if two permissions are not equal.

x <= y

Checks if a permission is a subset of another permission.

x >= y

Checks if a permission is a superset of another permission.

x < y

Checks if a permission is a strict subset of another permission.

x > y
x + y

Adds two permissions together. Equivalent to x | y.

x - y

Subtracts two permissions from each other.

x | y

Returns the union of two permissions. Equivalent to x + y.

x & y

Returns the intersection of two permissions.

~x

Returns the inverse of a permission.

Checks if a permission is a strict superset of another permission.

hash(x)

Return the permission’s hash.

iter(x)

Returns an iterator of (perm, value) pairs. This allows it to be, for example, constructed as a dict or a list of pairs. Note that aliases are not shown.

value#

The raw value. This value is a bit array field of a 53-bit integer representing the currently available permissions. You should query permissions via the properties rather than using this raw value.

Type:

int

Parameters:
  • permissions (int) –

  • kwargs (bool) –

is_subset(other)[source]#

Returns True if self has the same or fewer permissions as other.

Parameters:

other (Permissions) –

Return type:

bool

is_superset(other)[source]#

Returns True if self has the same or more permissions as other.

Parameters:

other (Permissions) –

Return type:

bool

is_strict_subset(other)[source]#

Returns True if the permissions on other are a strict subset of those on self.

Parameters:

other (Permissions) –

Return type:

bool

is_strict_superset(other)[source]#

Returns True if the permissions on other are a strict superset of those on self.

Parameters:

other (Permissions) –

Return type:

bool

classmethod none()[source]#

A factory method that creates a Permissions with all permissions set to False.

classmethod all()[source]#

A factory method that creates a Permissions with all permissions set to True.

classmethod all_channel()[source]#

A Permissions with all channel-specific permissions set to True and the guild-specific ones set to False. The guild-specific permissions are currently:

Changed in version 1.7: Added stream, priority_speaker and use_slash_commands permissions.

classmethod general()[source]#

A factory method that creates a Permissions with all “General” permissions from the official Discord UI set to True.

Changed in version 1.7: Permission read_messages is now included in the general permissions, but permissions administrator, create_instant_invite, kick_members, ban_members, change_nickname and manage_nicknames are no longer part of the general permissions.

classmethod membership()[source]#

A factory method that creates a Permissions with all “Membership” permissions from the official Discord UI set to True.

New in version 1.7.

classmethod text()[source]#

A factory method that creates a Permissions with all “Text” permissions from the official Discord UI set to True.

Changed in version 1.7: Permission read_messages is no longer part of the text permissions. Added use_slash_commands permission.

classmethod voice()[source]#

A factory method that creates a Permissions with all “Voice” permissions from the official Discord UI set to True.

classmethod stage()[source]#

A factory method that creates a Permissions with all “Stage Channel” permissions from the official Discord UI set to True.

New in version 1.7.

classmethod stage_moderator()[source]#

A factory method that creates a Permissions with all “Stage Moderator” permissions from the official Discord UI set to True.

New in version 1.7.

classmethod advanced()[source]#

A factory method that creates a Permissions with all “Advanced” permissions from the official Discord UI set to True.

New in version 1.7.

update(**kwargs)[source]#

Bulk updates this permission object.

Allows you to set multiple attributes by using keyword arguments. The names must be equivalent to the properties listed. Extraneous key/value pairs will be silently ignored.

Parameters:

**kwargs (bool) – A list of key/value pairs to bulk update permissions with.

Return type:

None

create_instant_invite#

Returns True if the user can create instant invites.

Type:

bool

kick_members#

Returns True if the user can kick users from the guild.

Type:

bool

ban_members#

Returns True if a user can ban users from the guild.

Type:

bool

administrator#

Returns True if a user is an administrator. This role overrides all other permissions.

This also bypasses all channel-specific overrides.

Type:

bool

manage_channels#

Returns True if a user can edit, delete, or create channels in the guild.

This also corresponds to the “Manage Channel” channel-specific override.

Type:

bool

manage_guild#

Returns True if a user can edit guild properties.

Type:

bool

add_reactions#

Returns True if a user can add reactions to messages.

Type:

bool

view_audit_log#

Returns True if a user can view the guild’s audit log.

Type:

bool

priority_speaker#

Returns True if a user can be more easily heard while talking.

Type:

bool

stream#

Returns True if a user can stream in a voice channel.

Type:

bool

view_channel#

Returns True if a user can view all or specific channels.

Type:

bool

read_messages[source]#

An alias for view_channel.

New in version 1.3.

Type:

bool

send_messages#

Returns True if a user can send messages from all or specific text channels.

Type:

bool

send_tts_messages#

Returns True if a user can send TTS messages from all or specific text channels.

Type:

bool

manage_messages#

Returns True if a user can delete or pin messages in a text channel.

Note

Note that there are currently no ways to edit other people’s messages.

Type:

bool

Returns True if a user’s messages will automatically be embedded by Discord.

Type:

bool

attach_files#

Returns True if a user can send files in their messages.

Type:

bool

read_message_history#

Returns True if a user can read a text channel’s previous messages.

Type:

bool

mention_everyone#

Returns True if a user’s @everyone or @here will mention everyone in the text channel.

Type:

bool

external_emojis#

Returns True if a user can use emojis from other guilds.

Type:

bool

use_external_emojis[source]#

An alias for external_emojis.

New in version 1.3.

Type:

bool

view_guild_insights#

Returns True if a user can view the guild’s insights.

New in version 1.3.

Type:

bool

connect#

Returns True if a user can connect to a voice channel.

Type:

bool

speak#

Returns True if a user can speak in a voice channel.

Type:

bool

mute_members#

Returns True if a user can mute other users.

Type:

bool

deafen_members#

Returns True if a user can deafen other users.

Type:

bool

move_members#

Returns True if a user can move users between other voice channels.

Type:

bool

use_voice_activation#

Returns True if a user can use voice activation in voice channels.

Type:

bool

change_nickname#

Returns True if a user can change their nickname in the guild.

Type:

bool

manage_nicknames#

Returns True if a user can change other user’s nickname in the guild.

Type:

bool

manage_roles#

Returns True if a user can create or edit roles less than their role’s position.

This also corresponds to the “Manage Permissions” channel-specific override.

Type:

bool

manage_permissions[source]#

An alias for manage_roles.

New in version 1.3.

Type:

bool

manage_webhooks#

Returns True if a user can create, edit, or delete webhooks.

Type:

bool

manage_emojis#

Returns True if a user can create, edit, or delete emojis.

Type:

bool

manage_emojis_and_stickers[source]#

An alias for manage_emojis.

New in version 2.0.

Type:

bool

use_slash_commands#

Returns True if a user can use slash commands.

New in version 1.7.

Type:

bool

use_application_commands[source]#

An alias for use_slash_commands.

New in version 2.0.

Type:

bool

request_to_speak#

Returns True if a user can request to speak in a stage channel.

New in version 1.7.

Type:

bool

manage_events#

Returns True if a user can manage guild events.

New in version 2.0.

Type:

bool

manage_threads#

Returns True if a user can manage threads.

New in version 2.0.

Type:

bool

create_public_threads#

Returns True if a user can create public threads.

New in version 2.0.

Type:

bool

create_private_threads#

Returns True if a user can create private threads.

New in version 2.0.

Type:

bool

external_stickers#

Returns True if a user can use stickers from other guilds.

New in version 2.0.

Type:

bool

use_external_stickers[source]#

An alias for external_stickers.

New in version 2.0.

Type:

bool

send_messages_in_threads#

Returns True if a user can send messages in threads.

New in version 2.0.

Type:

bool

start_embedded_activities#

Returns True if a user can launch an activity flagged ‘EMBEDDED’ in a voice channel.

New in version 2.0.

Type:

bool

moderate_members#

Returns True if a user can moderate members (timeout).

New in version 2.0.

Type:

bool

send_voice_messages#

Returns True if a member can send voice messages.

New in version 2.5.

Type:

bool

set_voice_channel_status#

Returns True if a member can set voice channel status.

New in version 2.5.

Type:

bool

class discord.PermissionOverwrite(**kwargs)[source]#

A type that is used to represent a channel specific permission.

Unlike a regular Permissions, the default value of a permission is equivalent to None and not False. Setting a value to False is explicitly denying that permission, while setting a value to True is explicitly allowing that permission.

The values supported by this are the same as Permissions with the added possibility of it being set to None.

x == y

Checks if two overwrites are equal.

x != y

Checks if two overwrites are not equal.

iter(x)

Returns an iterator of (perm, value) pairs. This allows it to be, for example, constructed as a dict or a list of pairs. Note that aliases are not shown.

Parameters:

**kwargs (bool | None) – Set the value of permissions by their name.

pair()[source]#

Returns the (allow, deny) pair from this overwrite.

classmethod from_pair(allow, deny)[source]#

Creates an overwrite from an allow/deny pair of Permissions.

is_empty()[source]#

Checks if the permission overwrite is currently empty.

An empty permission overwrite is one that has no overwrites set to True or False.

Returns:

Indicates if the overwrite is empty.

Return type:

bool

update(**kwargs)[source]#

Bulk updates this permission overwrite object.

Allows you to set multiple attributes by using keyword arguments. The names must be equivalent to the properties listed. Extraneous key/value pairs will be silently ignored.

Parameters:

**kwargs (bool) – A list of key/value pairs to bulk update with.

Return type:

None

Application Role Connections#

class discord.ApplicationRoleConnectionMetadata(*, type, key, name, description, name_localizations=..., description_localizations=...)[source]#

Represents role connection metadata for a Discord application.

New in version 2.4.

Parameters:
  • type (ApplicationRoleConnectionMetadataType) – The type of metadata value.

  • key (str) – The key for this metadata field. May only be the a-z, 0-9, or _ characters, with a maximum of 50 characters.

  • name (str) – The name for this metadata field. Maximum 100 characters.

  • description (str) – The description for this metadata field. Maximum 200 characters.

  • name_localizations (Optional[Dict[str, str]]) – The name localizations for this metadata field. The values of this should be "locale": "name". See here for a list of valid locales.

  • description_localizations (Optional[Dict[str, str]]) –

    The description localizations for this metadata field. The values of this should be "locale": "name". See here for a list of valid locales.