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 abc.Snowflake
, which is made with
dynamic attributes in mind.
Object
- class discord.Object(id, type=MISSING, *, state=MISSING)
Bases:
Hashable
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.
Embed
- clsEmbed.from_dict
- defadd_field
- defclear_fields
- defcopy
- definsert_field_at
- defremove_author
- defremove_field
- defset_author
- defset_field_at
- defset_footer
- defset_image
- defset_thumbnail
- defto_dict
- class discord.Embed(*, title=Embed.Empty, description=Embed.Empty, color=Embed.Empty, timestamp=Embed.Empty, url=Embed.Empty, type='rich', colour=Embed.Empty)
Bases:
object
Represents a Discord embed.
- len(x)
Returns the total size of the embed. Useful for checking if it’s within the 6000-character limit.
Certain properties return an
EmbedProxy
, a type that acts similar to a regulardict
except using dotted access, e.g.embed.author.icon_url
. If the attribute is invalid or empty, then a special sentinel value is returned,Embed.Empty
.For ease of use, all parameters that expect a
str
are implicitly cast tostr
for you.- 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:
- colour
The colour code of the embed. Aliased to
color
as well. This can be set during initialisation.
- Empty
A special sentinel value used by
EmbedProxy
and this class to denote that the value or attribute is empty.
- classmethod from_dict(data)
Converts a
dict
to aEmbed
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 an
EmbedProxy
denoting the footer contents.See
set_footer()
for possible values you can access.If the attribute has no value then
Empty
is returned.- Type:
Union[
EmbedProxy
,Empty
]
Sets the footer for the embed content.
This function returns the class instance to allow for fluent-style chaining.
- property image
Returns an
EmbedProxy
denoting the image contents.Possible attributes you can access are:
url
proxy_url
width
height
If the attribute has no value then
Empty
is returned.- Type:
Union[
EmbedProxy
,Empty
]
- set_image(*, url)
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
Empty
removes the image.- Parameters:
url (
str
) – The source URL for the image. Only HTTP(S) and discords attachment:// protocol is supported.
- property thumbnail
Returns an
EmbedProxy
denoting the thumbnail contents.Possible attributes you can access are:
url
proxy_url
width
height
If the attribute has no value then
Empty
is returned.- Type:
Union[
EmbedProxy
,Empty
]
- set_thumbnail(*, url)
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
Empty
removes the thumbnail.- Parameters:
url (
str
) – The source URL for the thumbnail. Only HTTP(S) and discords attachment:// protocol is supported.
- property video
Returns an
EmbedProxy
denoting the video contents.Possible attributes include:
url
for the video URL.height
for the video height.width
for the video width.
If the attribute has no value then
Empty
is returned.- Type:
Union[
EmbedProxy
,Empty
]
- property provider
Returns an
EmbedProxy
denoting the provider contents.The only attributes that might be accessed are
name
andurl
.If the attribute has no value then
Empty
is returned.- Type:
Union[
EmbedProxy
,Empty
]
- property author
Returns an
EmbedProxy
denoting the author contents.See
set_author()
for possible values you can access.If the attribute has no value then
Empty
is returned.- Type:
Union[
EmbedProxy
,Empty
]
- set_author(*, name, url=Embed.Empty, icon_url=Embed.Empty)
Sets the author for the embed content.
This function returns the class instance to allow for fluent-style chaining.
- remove_author()
Clears embed’s author information.
This function returns the class instance to allow for fluent-style chaining.
Added in version 1.4.
- property fields
Returns a
list
ofEmbedProxy
denoting the field contents.See
add_field()
for possible values you can access.If the attribute has no value then
Empty
is returned.- Type:
List[Union[
EmbedProxy
,Empty
]]
- add_field(*, name, value, inline=True)
Adds a field to the embed object.
This function returns the class instance to allow for fluent-style chaining.
- insert_field_at(index, *, name, value, inline=True)
Inserts a field before a specified index to the embed.
This function returns the class instance to allow for fluent-style chaining.
Added in version 1.2.
- remove_field(index)
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.
- set_field_at(index, *, name, value, inline=True)
Modifies a field to the embed object.
The index must point to a valid pre-existing field.
This function returns the class instance to allow for fluent-style chaining.
- Parameters:
- Raises:
IndexError – An invalid index was provided.
AllowedMentions
- class discord.AllowedMentions(*, everyone=True, users=True, roles=True, replied_user=True)
Bases:
object
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 viaabc.Messageable.send()
for more fine-grained control.- users
Controls the users being mentioned. If
True
(the default) then users are mentioned based on the message content. IfFalse
then users are not mentioned at all. If a list ofabc.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. IfFalse
then roles are not mentioned at all. If a list ofabc.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
.Added in version 1.6.
- Type:
- classmethod all()
A factory method that returns a
AllowedMentions
with all fields explicitly set toTrue
Added in version 1.5.
- classmethod none()
A factory method that returns a
AllowedMentions
with all fields set toFalse
Added in version 1.5.
MessageReference
- class discord.MessageReference(*, message_id, channel_id, guild_id=None, fail_if_not_exists=True)
Bases:
object
Represents a reference to a
Message
.Added 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
]
- 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.Added in version 1.7.
- Type:
- 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 typeDeletedReferencedMessage
.Currently, this is mainly the replied to message when a user replies to a message.
Added in version 1.6.
- Type:
Optional[Union[
Message
,DeletedReferencedMessage
]]
- classmethod from_message(message, *, fail_if_not_exists=True)
Creates a
MessageReference
from an existingMessage
.Added 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.Added in version 1.7.
- Returns:
A reference to the message.
- Return type:
- property cached_message
The cached message, if found in the internal message cache.
- Type:
Optional[
Message
]
PartialMessage
- asyncadd_reaction
- asyncclear_reaction
- asyncclear_reactions
- asynccreate_thread
- asyncdelete
- asyncedit
- asyncfetch
- asyncpin
- asyncpublish
- asyncremove_reaction
- asyncreply
- defto_reference
- asyncunpin
- class discord.PartialMessage(*, channel, id)
Bases:
Hashable
,Generic
[_MCH
]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
TextChannel.get_partial_message()
orDMChannel.get_partial_message()
.Note that this class is trimmed down and has no rich attributes.
Added 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
,ThreadChannel
,DMChannel
]
- guild
The guild associated with this partial message, if applicable.
- Type:
Optional[
Guild
]
- 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:
- Raises:
Forbidden – You do not have proper permissions to delete the message.
NotFound – The message was deleted already
HTTPException – Deleting the message failed.
- await publish()
This function is a coroutine.
Publishes this message to your announcement channel.
If the message is not your own then the
manage_messages
permission is needed.- Raises:
Forbidden – You do not have the proper permissions to publish this message.
HTTPException – Publishing the message failed.
- await pin(*, suppress_system_message=False, 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:
- 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.
TimeoutError – Waiting for the system message timed out.
- 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.
Added 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.
- 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, theadd_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.
- 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 themanage_messages
permission is needed.The
member
parameter must represent a member and meet theabc.Snowflake
abc.- Parameters:
emoji (Union[
Emoji
,Reaction
,PartialEmoji
,str
]) – The emoji to remove.member (
abc.Snowflake
) – The member for which to remove the reaction.
- 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.
- 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.Added 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.
- 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.
- await reply(content=None, tts=False, embed=None, embeds=None, components=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, mention_author=None, suppress_embeds=False, suppress_notifications=False)
This function is a coroutine.
A shortcut method to
abc.Messageable.send()
to reply to theMessage
.Added in version 1.6.
- 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 bothfile
andfiles
.
- Returns:
The message that was sent.
- Return type:
- await create_thread(name, auto_archive_duration=None, slowmode_delay=0, reason=None)
This function is a coroutine.
Creates a new thread in the channel of the message with this message as the
starter_message
.- Parameters:
name (
str
) – The name of the thread.auto_archive_duration (Optional[
AutoArchiveDuration
]) – Amount of time after that the thread will auto-hide from the channel listslowmode_delay (
int
) – Amount of seconds a user has to wait before sending another message (0-21600)reason (Optional[
str
]) – The reason for creating the thread. Shows up in the audit log.
- Raises:
TypeError – The channel of the message is not a text or news channel, or the message has already a thread, or
auto_archive_duration
is not a valid member ofAutoArchiveDuration
ValueError – The
name
is of invalid lengthForbidden – The bot is missing permissions to create threads in this channel
HTTPException – Creating the thread failed
- Returns:
The created thread on success
- Return type:
- to_reference(*, fail_if_not_exists=True)
Creates a
MessageReference
from the current message.Added 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.Added in version 1.7.
- Returns:
The reference to this message.
- Return type:
- await fetch()
This function is a coroutine.
Fetches the partial message to a full
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.
- Returns:
The full message.
- Return type:
- await edit(*, content=MISSING, embed=MISSING, embeds=MISSING, components=MISSING, attachments=MISSING, delete_after=None, allowed_mentions=MISSING, suppress_embeds=MISSING)
This function is a coroutine.
Edits the message.
The content must be able to be transformed into a string via
str(content)
.Changed in version 1.3: The
suppress
keyword-only parameter was added.Changed in version 2.0: The
components
andattachments
parameters were added.Changed in version 2.0: The
suppress
keyword-only parameter was renamed tosuppress_embeds
.Warning
Since API v10, the
attachments
(when passed) must contain all attachments that should be present after edit, including retained and new attachments.As this requires to know the current attachments consider either storing the attachments that were sent with a message or using a fetched version of the message to edit it.
- Parameters:
content (Optional[
str
]) – The new content to replace the message with. Could beNone
to remove the content.embed (Optional[
Embed
]) – The new embed to replace the original with. Could beNone
to remove all embeds.embeds (Optional[List[
Embed
]]) –A list containing up to 10 embeds to send. If
None
or empty, all embeds will be removed.If passed,
embed
does also count towards the limit of 10 embeds.components (List[Union[
ActionRow
, List[Union[Button
, Select]]]]) – A list of up to fiveActionRow`s or :class:`list
, each containing up to fiveButton
or one Select like object.attachments (List[Union[
Attachment
,File
]]) –A list containing previous attachments to keep as well as new files to upload.
When
None
or empty, all attachment will be removed.Note
New files will always appear under existing ones.
suppress_embeds (
bool
) – Whether to suppress embeds for the message. This removes all the embeds if set toTrue
. If set toFalse
this brings the embeds back if they were suppressed. Requiresmanage_messages
for messages that aren’t from the bot.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 withallowed_mentions
. The merging behaviour only overrides attributes that have been explicitly passed to the object, otherwise it uses the attributes set inallowed_mentions
. If no object is passed at all then the defaults given byallowed_mentions
are used instead.
- Raises:
NotFound – The message was not found.
HTTPException – Editing the message failed.
Forbidden – Tried to suppress the embeds a message without permissions or edited a message’s content or embed that isn’t yours.
- Returns:
The message that was edited.
- Return type:
Optional[
Message
]
Intents
- clsIntents.all
- clsIntents.default
- clsIntents.none
- class discord.Intents(**kwargs)
Bases:
BaseFlags
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 ofClient
.Added in version 1.5.
- x == y
Checks if two flags are equal.
- x != y
Checks if two flags are not equal.
- 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:
- classmethod all()
A factory method that creates a
Intents
with everything enabled.
- classmethod none()
A factory method that creates a
Intents
with everything disabled.
- classmethod default()
A factory method that creates a
Intents
with everything enabled exceptpresences
,members
andmessage_content
(privileged intents).
- guilds
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:
Guild
and all its attributes.
It is highly advisable to leave this intent enabled for your bot to function.
- Type:
- members
Whether guild member related events are enabled.
This corresponds to the following events:
on_member_update()
(nickname, roles)
This also corresponds to the following attributes and classes in terms of cache:
For more information go to the member intent documentation.
Note
Currently, this requires opting in explicitly via the developer portal as well. Bots in over 100 guilds will need to apply to Discord for verification.
- Type:
- bans
Whether guild ban 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:
- emojis
Whether guild emoji related events are enabled.
This corresponds to the following events:
This also corresponds to the following attributes and classes in terms of cache:
- Type:
- integrations
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:
- webhooks
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:
- invites
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:
- voice_states
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:
- Type:
- presences
Whether guild presence related events are enabled.
This corresponds to the following events:
on_member_update()
(activities, status)
This also corresponds to the following attributes and classes in terms of cache:
For more information go to the presence intent documentation.
Note
Currently, this requires opting in explicitly via the developer portal as well. Bots in over 100 guilds will need to apply to Discord for verification.
- Type:
- messages
Whether guild and direct message related events are enabled.
This is a shortcut to set or get both
guild_messages
anddm_messages
.This corresponds to the following events:
on_message()
(both guilds and DMs)on_message_edit()
(both guilds and DMs)on_message_delete()
(both guilds and DMs)on_raw_message_delete()
(both guilds and DMs)on_raw_message_edit()
(both guilds and DMs)
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:
on_reaction_add()
(both guilds and DMs)on_reaction_remove()
(both guilds and DMs)on_reaction_clear()
(both guilds and DMs)
- Type:
- guild_messages
Whether guild message related events are enabled.
See also
dm_messages
for DMs ormessages
for both.This corresponds to the following events:
on_message()
(only for guilds)on_message_edit()
(only for guilds)on_message_delete()
(only for guilds)on_raw_message_delete()
(only for guilds)on_raw_message_edit()
(only for guilds)
This also corresponds to the following attributes and classes in terms of cache:
Client.cached_messages
(only for guilds)
Note that due to an implicit relationship this also corresponds to the following events:
on_reaction_add()
(only for guilds)on_reaction_remove()
(only for guilds)on_reaction_clear()
(only for guilds)
- Type:
- dm_messages
Whether direct message related events are enabled.
See also
guild_messages
for guilds ormessages
for both.This corresponds to the following events:
on_message()
(only for DMs)on_message_edit()
(only for DMs)on_message_delete()
(only for DMs)on_raw_message_delete()
(only for DMs)on_raw_message_edit()
(only for DMs)
This also corresponds to the following attributes and classes in terms of cache:
Client.cached_messages
(only for DMs)
Note that due to an implicit relationship this also corresponds to the following events:
on_reaction_add()
(only for DMs)on_reaction_remove()
(only for DMs)on_reaction_clear()
(only for DMs)
- Type:
- reactions
Whether guild and direct message reaction related events are enabled.
This is a shortcut to set or get both
guild_reactions
anddm_reactions
.This corresponds to the following events:
on_reaction_add()
(both guilds and DMs)on_reaction_remove()
(both guilds and DMs)on_reaction_clear()
(both guilds and DMs)on_raw_reaction_add()
(both guilds and DMs)on_raw_reaction_remove()
(both guilds and DMs)on_raw_reaction_clear()
(both guilds and DMs)
This also corresponds to the following attributes and classes in terms of cache:
Message.reactions
(both guild and DM messages)
- Type:
- guild_reactions
Whether guild message reaction related events are enabled.
See also
dm_reactions
for DMs orreactions
for both.This corresponds to the following events:
on_reaction_add()
(only for guilds)on_reaction_remove()
(only for guilds)on_reaction_clear()
(only for guilds)on_raw_reaction_add()
(only for guilds)on_raw_reaction_remove()
(only for guilds)on_raw_reaction_clear()
(only for guilds)
This also corresponds to the following attributes and classes in terms of cache:
Message.reactions
(only for guild messages)
- Type:
- dm_reactions
Whether direct message reaction related events are enabled.
See also
guild_reactions
for guilds orreactions
for both.This corresponds to the following events:
on_reaction_add()
(only for DMs)on_reaction_remove()
(only for DMs)on_reaction_clear()
(only for DMs)on_raw_reaction_add()
(only for DMs)on_raw_reaction_remove()
(only for DMs)on_raw_reaction_clear()
(only for DMs)
This also corresponds to the following attributes and classes in terms of cache:
Message.reactions
(only for DM messages)
- Type:
- typing
Whether guild and direct message typing related events are enabled.
This is a shortcut to set or get both
guild_typing
anddm_typing
.This corresponds to the following events:
on_typing()
(both guilds and DMs)
This does not correspond to any attributes or classes in the library in terms of cache.
- Type:
- guild_typing
Whether guild and direct message typing related events are enabled.
See also
dm_typing
for DMs ortyping
for both.This corresponds to the following events:
on_typing()
(only for guilds)
This does not correspond to any attributes or classes in the library in terms of cache.
- Type:
- dm_typing
Whether guild and direct message typing related events are enabled.
See also
guild_typing
for guilds ortyping
for both.This corresponds to the following events:
on_typing()
(only for DMs)
This does not correspond to any attributes or classes in the library in terms of cache.
- Type:
- message_content
Whether to receive the content, embeds, attachments and components of a message.
Note
The bot will still receive these fields when the message is in a privat chat with the bot, or the bot is mentioned in the message.
This corresponds to the following events:
on_message()
(content, embeds, attachments, components)on_message_edit()
(content, embeds, attachments, components)on_raw_message_edit()
(cached_message)on_message_delete()
(content, embeds, attachments, components)on_raw_message_delete()
(cached_message)on_bulk_message_delete()
(content, embeds, attachments, components)on_raw_bulk_message_delete()
(cached_messages)on_auto_moderation_action()
(content, matched_content)
This also corresponds to the following attributes and classes:
For more information go to the message-content intent documentation .
Note
Currently, this requires opting in explicitly via the developer portal as well. Bots in over 100 guilds will need to apply to Discord for verification.
- Type:
- scheduled_events
Whether to receive events related to creating, updating and deleting scheduled events. Also, whether to receive events when a user is added or removed (interested).
This corresponds to the following events:
on_scheduled_event_user_add()
on_scheduled_event_user_remove()
- Type:
- auto_moderation_configurations
Whether to receive events related to creating, updating and deleting auto moderation rules.
This corresponds to the following events:
on_auto_moderation_rule_create()
on_auto_moderation_rule_update()
on_auto_moderation_rule_delete()
- Type:
MemberCacheFlags
- class discord.MemberCacheFlags(**kwargs)
Bases:
BaseFlags
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 inClient
.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 cleanup 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.
Added in version 1.5.
- x == y
Checks if two flags are equal.
- x != y
Checks if two flags are not equal.
- 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:
- classmethod all()
A factory method that creates a
MemberCacheFlags
with everything enabled.
- classmethod none()
A factory method that creates a
MemberCacheFlags
with everything disabled.
- online
Whether to cache members with a status.
For example, members that are part of the initial
GUILD_CREATE
or become online at a later point. This requiresIntents.presences
.Members that go offline are no longer cached.
- Type:
- voice
Whether to cache members that are in voice.
This requires
Intents.voice_states
.Members that leave voice are no longer cached.
- Type:
- joined
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:
- classmethod from_intents(intents)
A factory method that creates a
MemberCacheFlags
based on the currently selectedIntents
.- Parameters:
intents (
Intents
) – The intents to select from.- Returns:
The resulting member cache flags.
- Return type:
File
- class discord.File(fp, filename=None, description=None, *, spoiler=False, duration=None, waveform=None)
Bases:
object
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[
str
,io.BufferedIOBase
]
- filename
The filename to display when uploading to Discord. If this is not given then it defaults to
fp.name
or iffp
is a string then thefilename
will default to the string given.- Type:
Optional[
str
]
- description
The file description can be set to attached images to show a alternative text.
- Type:
Optional[
str
:]
ForumTag
- class discord.ForumTag
Bases:
Hashable
Represents a tag in a
ForumChannel
.Note
The
id
andguild
attributes are only available if the instance is not self created.- property emoji
The emoji that is set for this post, if any
- Type:
Optional[
PartialEmoji
]
Colour
- clsColour.blue
- clsColour.blurple
- clsColour.dark_blue
- clsColour.dark_gold
- clsColour.dark_gray
- clsColour.dark_green
- clsColour.dark_grey
- clsColour.dark_magenta
- clsColour.dark_orange
- clsColour.dark_purple
- clsColour.dark_red
- clsColour.dark_teal
- clsColour.dark_theme
- clsColour.darker_gray
- clsColour.darker_grey
- clsColour.default
- clsColour.from_hsv
- clsColour.from_rgb
- clsColour.gold
- clsColour.green
- clsColour.greyple
- clsColour.light_gray
- clsColour.light_grey
- clsColour.lighter_gray
- clsColour.lighter_grey
- clsColour.magenta
- clsColour.orange
- clsColour.purple
- clsColour.random
- clsColour.red
- clsColour.teal
- defto_rgb
- class discord.Colour(value)
Bases:
object
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.
- classmethod from_rgb(r, g, b)
Constructs a
Colour
from an RGB tuple.
- classmethod from_hsv(h, s, v)
Constructs a
Colour
from an HSV tuple.
- classmethod default()
A factory method that returns a
Colour
with a value of0
.
- classmethod random(*, seed=None)
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.
Added in version 1.6.
- classmethod teal()
A factory method that returns a
Colour
with a value of0x1abc9c
.
- classmethod dark_teal()
A factory method that returns a
Colour
with a value of0x11806a
.
- classmethod green()
A factory method that returns a
Colour
with a value of0x2ecc71
.
- classmethod dark_green()
A factory method that returns a
Colour
with a value of0x1f8b4c
.
- classmethod blue()
A factory method that returns a
Colour
with a value of0x3498db
.
- classmethod dark_blue()
A factory method that returns a
Colour
with a value of0x206694
.
- classmethod purple()
A factory method that returns a
Colour
with a value of0x9b59b6
.
- classmethod dark_purple()
A factory method that returns a
Colour
with a value of0x71368a
.
- classmethod magenta()
A factory method that returns a
Colour
with a value of0xe91e63
.
- classmethod dark_magenta()
A factory method that returns a
Colour
with a value of0xad1457
.
- classmethod gold()
A factory method that returns a
Colour
with a value of0xf1c40f
.
- classmethod dark_gold()
A factory method that returns a
Colour
with a value of0xc27c0e
.
- classmethod orange()
A factory method that returns a
Colour
with a value of0xe67e22
.
- classmethod dark_orange()
A factory method that returns a
Colour
with a value of0xa84300
.
- classmethod red()
A factory method that returns a
Colour
with a value of0xe74c3c
.
- classmethod dark_red()
A factory method that returns a
Colour
with a value of0x992d22
.
- classmethod lighter_grey()
A factory method that returns a
Colour
with a value of0x95a5a6
.
- classmethod lighter_gray()
A factory method that returns a
Colour
with a value of0x95a5a6
.
- classmethod dark_grey()
A factory method that returns a
Colour
with a value of0x607d8b
.
- classmethod dark_gray()
A factory method that returns a
Colour
with a value of0x607d8b
.
- classmethod light_grey()
A factory method that returns a
Colour
with a value of0x979c9f
.
- classmethod light_gray()
A factory method that returns a
Colour
with a value of0x979c9f
.
- classmethod darker_grey()
A factory method that returns a
Colour
with a value of0x546e7a
.
- classmethod darker_gray()
A factory method that returns a
Colour
with a value of0x546e7a
.
- classmethod blurple()
A factory method that returns a
Colour
with a value of0x7289da
.
- classmethod greyple()
A factory method that returns a
Colour
with a value of0x99aab5
.
- classmethod dark_theme()
A factory method that returns a
Colour
with a value of0x36393F
. This will appear transparent on Discord’s dark theme.Added in version 1.5.
BaseActivity
- class discord.BaseActivity(**kwargs)
Bases:
object
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.
Added in version 1.3.
- property created_at
When the user started doing this activity in UTC.
Added in version 1.3.
- Type:
Optional[
datetime.datetime
]
Activity
- class discord.Activity(**kwargs)
Bases:
BaseActivity
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:
- 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:
- 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:
- 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:
- emoji
The emoji that belongs to this activity.
- Type:
Optional[
PartialEmoji
]
- 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.Added in version 2.0.
- property start
When the user started doing this activity in UTC, if applicable.
- Type:
Optional[
datetime.datetime
]
- property end
When the user will stop doing this activity in UTC, if applicable.
- Type:
Optional[
datetime.datetime
]
- property large_image_url
Returns a URL pointing to the large image asset of this activity if applicable.
- Type:
Optional[
str
]
- property small_image_url
Returns a URL pointing to the small image asset of this activity if applicable.
- Type:
Optional[
str
]
- property large_image_text
Returns the large image asset hover text of this activity if applicable.
- Type:
Optional[
str
]
- property small_image_text
Returns the small image asset hover text of this activity if applicable.
- Type:
Optional[
str
]
Game
- class discord.Game(name, **extra)
Bases:
BaseActivity
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.start (Optional[
datetime.datetime
]) – A naive UTC timestamp representing when the game started. Keyword-only parameter. Ignored for bots.end (Optional[
datetime.datetime
]) – A naive UTC timestamp representing when the game ends. Keyword-only parameter. Ignored for bots.
- property type
Returns the game’s type. This is for compatibility with
Activity
.It always returns
ActivityType.playing
.- Type:
- property start
When the user started playing this game in UTC, if applicable.
- Type:
Optional[
datetime.datetime
]
- property end
When the user will stop playing this game in UTC, if applicable.
- Type:
Optional[
datetime.datetime
]
Streaming
- class discord.Streaming(*, name, url, **extra)
Bases:
BaseActivity
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.
- name
The stream’s name.
- Type:
Optional[
str
]
- game
The game being streamed.
Added in version 1.3.
- Type:
Optional[
str
]
- assets
A dictionary comprising similar keys than those in
Activity.assets
.- Type:
- property type
Returns the game’s type. This is for compatibility with
Activity
.It always returns
ActivityType.streaming
.- Type:
- property twitch_name
If provided, the twitch name of the user streaming.
This corresponds to the
large_image
key of theStreaming.assets
dictionary if it starts withtwitch:
. Typically set by the Discord client.- Type:
Optional[
str
]
CustomActivity
- class discord.CustomActivity(name, *, emoji=None, **extra)
Bases:
BaseActivity
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.
Added 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
]
- property type
Returns the activity’s type. This is for compatibility with
Activity
.It always returns
ActivityType.custom
.- Type:
Permissions
- add_reactions
- administrator
- attach_files
- ban_members
- change_nickname
- connect
- create_emojis
- create_events
- create_expressions
- create_instant_invite
- create_posts
- create_private_threads
- create_public_threads
- create_sounds
- create_stickers
- deafen_members
- embed_links
- external_emojis
- kick_members
- manage_channels
- manage_emojis
- manage_emojis_and_stickers
- manage_events
- manage_expressions
- manage_guild
- manage_messages
- manage_nicknames
- manage_permissions
- manage_roles
- manage_sounds
- manage_stickers
- manage_threads
- manage_webhooks
- mention_everyone
- moderate_members
- move_members
- mute_members
- priority_speaker
- read_message_history
- read_messages
- request_to_speak
- send_messages
- send_messages_in_posts
- send_messages_in_threads
- send_polls
- send_thread_messages
- send_tts_messages
- send_voice_messages
- set_voice_channel_status
- speak
- start_embedded_activities
- start_voice_activities
- stream
- timeout_members
- use_application_commands
- use_external_apps
- use_external_emojis
- use_external_sounds
- use_external_stickers
- use_slash_commands
- use_soundboard
- use_voice_activation
- value
- view_audit_log
- view_channel
- view_creator_monetization_analytics
- view_guild_insights
- clsPermissions.advanced
- clsPermissions.all
- clsPermissions.all_channel
- clsPermissions.events
- clsPermissions.general
- clsPermissions.membership
- clsPermissions.none
- clsPermissions.stage
- clsPermissions.stage_moderator
- clsPermissions.text
- clsPermissions.voice
- defis_strict_subset
- defis_strict_superset
- defis_subset
- defis_superset
- defupdate
- class discord.Permissions(permissions=0, **kwargs)
Bases:
BaseFlags
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 toupdate()
.- 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
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:
- is_strict_subset(other)
Returns
True
if the permissions on other are a strict subset of those on self.
- is_strict_superset(other)
Returns
True
if the permissions on other are a strict superset of those on self.
- classmethod none()
A factory method that creates a
Permissions
with all permissions set toFalse
.
- classmethod all()
A factory method that creates a
Permissions
with all permissions set toTrue
.
- classmethod all_channel()
A
Permissions
with all channel-specific permissions set toTrue
and the guild-specific ones set toFalse
. The guild-specific permissions are currently:Changed in version 1.7: Added
stream
,priority_speaker
anduse_slash_commands
permissions.Changed in version 2.0: Added
start_embedded_activities
,moderate_members
,manage_events
,create_private_threads
,create_puplic_threads
,manage_threads
,send_messages_in_threads
,request_to_speak
anduse_external_stickers
- classmethod general()
A factory method that creates a
Permissions
with all “General” permissions from the official Discord UI set toTrue
.Changed in version 1.7: Permission
read_messages
is now included in the general permissions, but permissionsadministrator
,create_instant_invite
,kick_members
,ban_members
,change_nickname
andmanage_nicknames
are no longer part of the general permissions.Changed in version 2.0: Added
moderate_members
,manage_expressions
andcreate_expressions
permission.
- classmethod membership()
A factory method that creates a
Permissions
with all “Membership” permissions from the official Discord UI set toTrue
.Added in version 1.7.
Changed in version 2.0: Added
moderate_members
permission.
- classmethod text()
A factory method that creates a
Permissions
with all “Text” permissions from the official Discord UI set toTrue
.Changed in version 1.7: Permission
read_messages
is no longer part of the text permissions. Addeduse_slash_commands
permission.Changed in version 2.0: Added
send_voice_messages
,manage_threads
,create_public_threads
,create_private_threads
,send_messages_in_threads
anduse_external_stickers
permission.
- classmethod voice()
A factory method that creates a
Permissions
with all “Voice” permissions from the official Discord UI set toTrue
.Changed in version 2.0: Added
start_embedded_activities
,use_soundboard
use_external_sounds
andset_voice_channel_status
permission.
- classmethod stage()
A factory method that creates a
Permissions
with all “Stage Channel” permissions from the official Discord UI set toTrue
.Added in version 1.7.
- classmethod stage_moderator()
A factory method that creates a
Permissions
with all “Stage Moderator” permissions from the official Discord UI set toTrue
.Added in version 1.7.
- classmethod events()
A factory method that creates a
Permissions
with all “Events” permissions from the official Discord UI set toTrue
.Added in version 2.0.
- classmethod advanced()
A factory method that creates a
Permissions
with all “Advanced” permissions from the official Discord UI set toTrue
.Added in version 1.7.
- update(**kwargs)
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 – A list of key/value pairs to bulk update permissions with.
- administrator
Returns
True
if a user is an administrator. This role overrides all other permissions.This also bypasses all channel-specific overrides.
- Type:
- 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:
- view_channel
An alias for
read_messages
.Added in version 1.3.
- Type:
- send_messages
Returns
True
if a user can send messages from all or specific text channels and create posts in forum channels.- Type:
- create_posts
An alias for
send_messages
.Added in version 2.0.
- Type:
- send_tts_messages
Returns
True
if a user can send TTS messages from all or specific text channels.- Type:
- 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:
- mention_everyone
Returns
True
if a user’s @everyone or @here will mention everyone in the text channel.- Type:
- use_external_emojis
An alias for
external_emojis
.Added in version 1.3.
- Type:
- view_guild_insights
Returns
True
if a user can view the guild’s insights.Added in version 1.3.
- Type:
- 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:
- manage_permissions
An alias for
manage_roles
.Added in version 1.3.
- Type:
- manage_expressions
Returns
True
if a user can create, edit, or delete emojis, stickers and sounds.- Type:
- manage_emojis
An aliase for
manage_expressions
- Type:
- manage_stickers
An aliase for
manage_expressions
- Type:
- manage_emojis_and_stickers
An aliase for
manage_expressions
- Type:
- manage_sounds
An aliase for
manage_expressions
- Type:
- create_expressions
Returns
True
if a user can create emojis, stickers or sounds in a server.Added in version 2.0.
- Type:
- create_emojis
An aliase for
create_expressions
- Type:
- create_stickers
An aliase for
create_expressions
- Type:
- create_sounds
An aliase for
create_expressions
- Type:
- use_application_commands
Returns
True
if a user can use application commands.Added in version 1.7.
- Type:
- use_slash_commands
An aliase for
use_application_commands
- Type:
- request_to_speak
Returns
True
if a user can request to speak in a stage channel.Added in version 1.7.
- Type:
- manage_events
Returns
True
if a user can create and manage Guild-Scheduled-Events.Added in version 2.0.
- Type:
- manage_threads
Returns
True
if a user can delete and archive threads and viewing all private threads.Added in version 2.0.
- Type:
- create_public_threads
Returns
True
if a user can create and participate in threads.Added in version 2.0.
- Type:
- create_private_threads
Returns
True
if a user can create and participate in private threads.Added in version 2.0.
- Type:
- use_external_stickers
Returns
True
if a user can use custom stickers from other servers.Added in version 2.0.
- Type:
- send_messages_in_threads
Returns
True
if a user can send messages in threads and forum posts.Added in version 2.0.
- Type:
- send_messages_in_posts
An alias for
send_messages_in_threads
.- Type:
- send_thread_messages
An alias for
send_messages_in_threads
.- Type:
- start_embedded_activities
Returns
True
if a user can start embedded activities in a voice channel (e.g. voice-activities).Added in version 2.0.
- Type:
- start_voice_activities
An alias for
start_embedded_activities
.- Type:
- moderate_members
Returns
True
if a user can moderate other members (like timeout or verify them).Added in version 2.0.
- Type:
- timeout_members
An alias for
moderate_members
.- Type:
- view_creator_monetization_analytics
Returns
True
if a user can view analytics for monetization of their content.Added in version 2.0.
- Type:
- use_soundboard
Returns
True
if a user can use the soundboard in a voice channel.Added in version 2.0.
- Type:
- use_external_sounds
Returns
True
if a user can use custom soundboard sounds from other servers.Added in version 2.0.
- Type:
- set_voice_channel_status
Returns
True
if a user can set the status of a voice channel.Added in version 2.0.
- Type:
PermissionOverwrite
- clsPermissionOverwrite.from_pair
- defis_empty
- defpair
- defupdate
- class discord.PermissionOverwrite(**kwargs)
Bases:
object
A type that is used to represent a channel specific permission.
Unlike a regular
Permissions
, the default value of a permission is equivalent toNone
and notFalse
. Setting a value toFalse
is explicitly denying that permission, while setting a value toTrue
is explicitly allowing that permission.The values supported by this are the same as
Permissions
with the added possibility of it being set toNone
.- x == y
Checks if two overwrites are equal.
- x != y
Checks if two overwrites are not equal.
- iter(x) - (for ... in 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.
- pair()
Tuple[
Permissions
,Permissions
]: Returns the (allow, deny) pair from this overwrite.
- classmethod from_pair(allow, deny)
Creates an overwrite from an allow/deny pair of
Permissions
.
- is_empty()
Checks if the permission overwrite is currently empty.
An empty permission overwrite is one that has no overwrites set to
True
orFalse
.- Returns:
Indicates if the overwrite is empty.
- Return type:
- update(**kwargs)
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 – A list of key/value pairs to bulk update with.
SystemChannelFlags
- class discord.SystemChannelFlags
Bases:
BaseFlags
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.
- 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:
Returns
True
if the system channel is used for Nitro boosting notifications.- Type:
- guild_reminder_notifications
Returns
True
if the system channel is used for server setup tips.- Type:
- join_notification_replies
Returns
True
if sticker reply buttons should show under member join messages.- Type:
- role_subscription_purchase_notifications
Returns
True
if the system channel is used for role subscription purchase and renewal notifications.- Type:
ChannelFlags
- class discord.ChannelFlags
Bases:
BaseFlags
Wraps up a Discord Channel flag value
- removed_from_guild_feed
Returns
True
if the channel is removed from the guild’s home feed/from highlights.- Type:
- removed_from_home
An alias to
removed_from_guild_feed
.- Type:
- removed_from_active_now
Returns
True
if the channel is removed from the active now section in the guild’s feed.- Type:
- require_tags
bool
: ReturnsTrue
if this channel is aForumChannel
that requires at least one tag when creating a post.
- clyde_ai
Returns
True
if clyde has access to this thread.Experimental Discord Feature - Clyde, Discord’s AI Chatbot
This is an experimental feature and may be removed at any time.
For more information, take a look at the support article
- Type:
- summaries_disabled
Returns
True
if AI summaries are disabled for this channel.Experimental Discord Feature - AI powered summaries
This is an experimental feature and may be removed at any time.
For more information, take a look at the support article
- Type:
- is_role_subscription_template_preview_channel
Returns
True
if the channel is part of a role subscription template preview.Experimental Discord Feature - Role Subscription Template
This is an experimental feature and may be removed at any time.
- Type:
MessageFlags
- class discord.MessageFlags
Bases:
BaseFlags
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.
- 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.
Added 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:
- source_message_deleted
Returns
True
if the source message for this crosspost has been deleted.- Type:
- urgent
Returns
True
if the source message is an urgent message.An urgent message is one sent by Discord Trust and Safety.
- Type:
- has_thread
Returns
True
if the source message is associated with a thread.This message has an associated thread, with the same id as the message.
- Type:
- ephemeral
Returns
True
if the message ist ephemeral (hidden).This message is only visible to the user who invoked the Interaction.
- Type:
- loading
Returns
True
if the message is an interaction response and the bot is “thinking”.This message is an interaction response and the bot is “thinking”
- Type:
- failed_to_mention_some_roles_in_thread
Returns
True
if the message failed to mention some roles and add their members to the thread.- Type:
- show_link_not_discord_warning
Returns
True
if the message should show a warning that the link may not be safe.Note
Although this gets set by Discord for some embeds, and we receive a
on_message_edit()
event, it is not officially documented by Discord. It’s in the client but not used anywhere.- Type:
- suppress_notifications
Returns
True
if the message is “silent”.The user(s) will still see a mention in the channel, but no push or desktop notification will be sent.
- Type:
PublicUserFlags
- defall
- class discord.PublicUserFlags
Bases:
BaseFlags
Wraps up the Discord User Public flags.
- x == y
Checks if two PublicUserFlags are equal.
- x != y
Checks if two PublicUserFlags are not equal.
- 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.
Added 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:
- early_verified_bot_developer
An alias for
verified_bot_developer
.Added in version 1.5.
- Type:
- bot_http_interactions
Returns
True
if a bot-user uses only HTTP interactions and is shown in the online member list- Type:
AutoModAction
- class discord.AutoModAction
Bases:
object
Represents an action which will execute whenever a rule is triggered.
- channel_id
The channel to which target user content should be logged.
Note
This field is only present if
type
issend_alert_message
- Type:
- timeout_duration
Duration in seconds (
int
) or a timerange (timedelta
) for which the target user should be timeouted.The maximum value is
2419200
seconds (4 weeks)Note
This field is only present if
type
istimeout_user
- custom_message
Additional explanation that will be shown to target users whenever their message is blocked. Max 150 characters
Note
This field might only be present if
type
isblock_message
- Type:
Optional[
str
]
- Parameters:
type (
AutoModActionType
) – The type of actionchannel_id (
int
) –The channel to which target user content should be logged.
Note
This field is only required if
type
issend_alert_message
timeout_duration (Union[
int
,datetime.timedelta
]) –Duration in seconds (
int
) or a timerange (timedelta
) for which the user should be timeouted.The maximum value is
2419200
seconds (4 weeks)Note
This field is only required if
type
istimeout_user
custom_message (Optional[
str
]) –Additional explanation that will be shown to target users whenever their message is blocked. Max 150 characters
Note
This field is only allowed if
type
isblock_message
- Raises:
TypeError – If the type is
send_alert_message
and nochannel_id
is provided, or if the type istimeout_user
and notimeout_duration
is provided.ValueError – If the
custom_message
is longer than 150 characters, or if thetimeout_duration
is longer than 4 weeks.
AutoModTriggerMetadata
- class discord.AutoModTriggerMetadata
Bases:
object
Additional data used to determine whether a rule should be triggered. Different fields are relevant based on the value of
AutoModRule.trigger_type
- Parameters:
keyword_filter (Optional[List[
str
]]) –Substrings which will be searched for in content
Note
This field is only present if
trigger_type
isAutoModTriggerType.keyword
presets (Optional[List[
AutoModKeywordPresetType
]]) –The internally pre-defined word sets which will be searched for in content
Note
This field is only present if
trigger_type
isAutoModTriggerType.keyword_preset
exempt_words (Optional[List[
str
]]) –Substrings which should be excluded from the blacklist.
Note
This field is only present if
trigger_type
isAutoModTriggerType.keyword_preset
total_mentions_limit (Optional[
int
]) –Total number of unique role and user mentions allowed per message (Maximum of 50)
Note
This field is only present if
trigger_type
isAutoModTriggerType.mention_spam
mention_raid_protection_enabled (Optional[
bool
]) –Whether to automatically detect mention raids
Note
This field is only present if
trigger_type
isAutoModTriggerType.mention_spam
Additional data used to determine whether a rule should be triggered. Different fields are relevant based on the value of
AutoModRule.trigger_type
- Parameters:
keyword_filter (Optional[List[
str
]]) –Substrings which will be searched for in content
Note
This field is only allowed if
trigger_type
iskeyword
regex_patterns (Optional[List[Union[
str
, :class`~re.Pattern`]]]) –Regular expression patterns which will be matched against content (Maximum of 10, each max. 260 characters long)
Warning
Only <Rust https://docs.rs/regex/latest/regex/>_ flowered RegEx patterns are currently supported by Discord. So things like lookarounds are not allowed as they are not supported in Rust.
Note
This field is only allowed if
trigger_type
iskeyword
presets (Optional[List[
AutoModKeywordPresetType
]]) –The internally pre-defined word sets which will be searched for in content
Note
This field is only required if
trigger_type
iskeyword_preset
exempt_words (Optional[List[
str
]]) –Substrings which should be excluded from the blacklist.
Note
This field is only allowed if
trigger_type
iskeyword_preset
keyword
total_mentions_limit (Optional[
int
]) –Total number of unique role and user mentions allowed per message (Maximum of 50)
Note
This field is only allowed if
trigger_type
isAutoModTriggerType.mention_spam
mention_raid_protection_enabled (Optional[
bool
]) –Whether to automatically detect mention raids
Note
This field is only allowed if
trigger_type
isAutoModTriggerType.mention_spam
- Raises:
TypeError – Both of keyword_filter and presets was passed
- regex_patterns
The compiled regex patterns for this rule, if any.
- Type:
List[
Pattern
]
- property prefix_keywords
Returns all keywords for words that must start with the keyword.
Note
This is equal to
for keyword in self.keyword_filter: if keyword[0] != '*' and keyword[-1] == '*': yield keyword
- Yields:
str
– A keyword
- property suffix_keywords
Returns all keywords for words that must end with the keyword.
Note
This is equal to
for keyword in self.keyword_filter: if keyword[0] == '*' and keyword[-1] != '*': yield keyword
- Yields:
str
– A keyword
- property anywhere_keywords
Returns all keywords which can appear anywhere in a word
Note
This is equal to
for keyword in self.keyword_filter: if keyword[0] == '*' and keyword[-1] == '*': yield keyword
- Yields:
str
– A keyword
- property whole_word_keywords
Returns all keywords that must occur as a whole in a word or phrase and must be surrounded by spaces.
Note
This is equal to
for keyword in self.keyword_filter: if keyword[0] != '*' and keyword[-1] != '*': yield keyword
- Yields:
str
– A keyword
WelcomeScreenChannel
- class discord.WelcomeScreenChannel
Bases:
object
Represents a channel shown in a welcome screen.
- emoji
The emoji that is shown on the left side of the welcome screen channel
- Type:
Optional[
PartialEmoji
]
Represents a channel shown in a welcome screen.
- Parameters:
channel (
Snowflake
) – The channel the welcome screen channel belongs todescription (
str
) – The description of the welcome screen channelemoji (Optional[Union[
PartialEmoji
,str
]) – The emoji that is shown on the left side of the welcome screen channel