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, type=...)[исходный код]¶
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.
- type¶
The model this object’s ID is based off.
- Type:
type[
abc.Snowflake]
- class discord.SelectOption(*, label, value=..., description=None, emoji=None, default=False)[исходный код]¶
Represents a
discord.SelectMenu’s option.These can be created by users.
Добавлено в версии 2.0.
- label¶
The label of the option. This is displayed to users. Can only be up to 100 characters.
- Type:
- 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:
- description¶
An additional description of the option, if any. Can only be up to 100 characters.
- Type:
Optional[
str]
- Параметры:
label (
str)value (
str)emoji (
str|GuildEmoji|AppEmoji|PartialEmoji|None)default (
bool)
- property emoji: str | GuildEmoji | AppEmoji | PartialEmoji | None¶
The emoji of the option, if available.
- class discord.SelectDefaultValue(object=..., /, *, id=..., type=...)[исходный код]¶
Represents a
discord.SelectMenus default value.This is only applicable to selects of type other than
ComponentType.string_select.Добавлено в версии 2.7.
- Параметры:
object (
Snowflake) –The model type this select default value is based of.
Below, is a table defining the model instance type and the default value type it will be mapped:
Model Type
Default Value Type
depending on
discord.Object.type, it will be mapped to any aboveIf you pass a model that is not defined in the table,
TypeErrorwill be raised.Примечание
The
discord.abc.GuildChannelprotocol includesdiscord.TextChannel,discord.VoiceChannel,discord.StageChannel,discord.ForumChannel,discord.Thread,discord.MediaChannel. This list is not exhaustive, and is bound to change based of the new channel types Discord adds.id (
int) – The ID of the default value. This cannot be used withobject.type (
SelectDefaultValueType) – The default value type. This cannot be used withobject.
- Исключение:
TypeError – You did not provide any parameter, you provided all parameters, or you provided
idbut nottype.
- class discord.MediaGalleryItem(url, *, description=None, spoiler=False)[исходный код]¶
Represents an item used in the
MediaGallerycomponent.This is used as an underlying component for other media-based components such as
Thumbnail,FileComponent, andMediaGalleryItem.Добавлено в версии 2.7.
- url¶
The URL of this gallery item. This can either be an arbitrary URL or an
attachment://URL to work with local files.- Type:
- class discord.UnfurledMediaItem(url)[исходный код]¶
Represents an Unfurled Media Item used in Components V2.
This is used as an underlying component for other media-based components such as
Thumbnail,FileComponent, andMediaGalleryItem.Добавлено в версии 2.7.
- url¶
The URL of this media item. This can either be an arbitrary URL or an
attachment://URL to work with local files.- Type:
- Параметры:
url (
str)
- class discord.RadioGroupOption(*, label, value=..., description=None, default=False)[исходный код]¶
Represents a
discord.RadioGroup’s option.These can be created by users.
Добавлено в версии 2.8.
- label¶
The label of the option. This is displayed to users. Can only be up to 100 characters.
- Type:
- 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:
- 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. Only 1 option should be set to default within a
discord.RadioGroup.- Type:
- class discord.CheckboxGroupOption(*, label, value=..., description=None, default=False)[исходный код]¶
Represents a
discord.CheckboxGroup’s option.These can be created by users.
Добавлено в версии 2.8.
- label¶
The label of the option. This is displayed to users. Can only be up to 100 characters.
- Type:
- 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:
- auto_moderation_configuration
- auto_moderation_execution
- bans
- dm_messages
- dm_polls
- dm_reactions
- dm_typing
- emojis
- emojis_and_stickers
- guild_messages
- guild_polls
- guild_reactions
- guild_typing
- guilds
- integrations
- invites
- members
- message_content
- messages
- moderation
- polls
- presences
- reactions
- scheduled_events
- typing
- value
- voice_states
- webhooks
- clsIntents.all
- clsIntents.default
- clsIntents.none
- class discord.Intents(**kwargs)[исходный код]¶
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
intentskeyword argument ofClient.Добавлено в версии 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:
- Параметры:
kwargs (
bool)
- classmethod all()[исходный код]¶
A factory method that creates a
Intentswith everything enabled.- Тип результата:
- classmethod none()[исходный код]¶
A factory method that creates a
Intentswith everything disabled.- Тип результата:
- classmethod default()[исходный код]¶
A factory method that creates a
Intentswith everything enabled exceptpresences,members, andmessage_content.- Тип результата:
- 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:
Guildand 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:
This also corresponds to the following attributes and classes in terms of cache:
For more information go to the member intent documentation.
Примечание
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:
- bans[исходный код]¶
Alias of
moderation.Изменено в версии 2.5: Changed to an alias.
- Type:
- moderation[исходный код]¶
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:
- emojis[исходный код]¶
Alias of
emojis_and_stickers.Изменено в версии 2.0: Changed to an alias.
- Type:
- emojis_and_stickers[исходный код]¶
Whether guild emoji and sticker related events are enabled.
Добавлено в версии 2.0.
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:
Примечание
This intent is required to connect to voice.
- Type:
- presences[исходный код]¶
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.
Примечание
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:
- messages[исходный код]¶
Whether guild and direct message related events are enabled.
This is a shortcut to set or get both
guild_messagesanddm_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)
Примечание
message_contentis required to receive the actual content of guild messages.- Type:
- guild_messages[исходный код]¶
Whether guild message related events are enabled.
See also
dm_messagesfor DMs ormessagesfor 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)Client.get_message()(only for guilds)Client.polls(only for guilds)Client.get_poll()(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)
Without the
message_contentintent enabled, the following fields are either an empty string or empty array:For more information go to the message content intent documentation.
- Type:
- dm_messages[исходный код]¶
Whether direct message related events are enabled.
See also
guild_messagesfor guilds ormessagesfor 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)Client.get_message()(only for DMs)Client.polls(only for DMs)Client.get_poll()(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_reactionsanddm_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_reactionsfor DMs orreactionsfor 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_reactionsfor guilds orreactionsfor 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_typinganddm_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_typingfor DMs ortypingfor 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_typingfor guilds ortypingfor 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 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.
Добавлено в версии 2.0.
Примечание
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:
- scheduled_events[исходный код]¶
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:
- auto_moderation_configuration[исходный код]¶
Whether guild auto moderation configuration events are enabled.
This corresponds to the following events:
- Type:
- auto_moderation_execution[исходный код]¶
Whether guild auto moderation execution events are enabled.
This corresponds to the following events:
- Type:
- guild_polls[исходный код]¶
Whether poll-related events in guilds are enabled.
See also
dm_pollsfor DMs orpollsfor both.This corresponds to the following events:
on_poll_vote_add()(only for guilds)on_poll_vote_remove()(only for guilds)on_raw_poll_vote_add()(only for guilds)on_raw_poll_vote_remove()(only for guilds)
This also corresponds to the following attributes and classes in terms of cache:
PollAnswer.count(only for guild polls)PollResults.answer_counts(only for guild polls)
- Type:
- dm_polls[исходный код]¶
Whether poll-related events in direct messages are enabled.
See also
guild_pollsfor guilds orpollsfor both.This corresponds to the following events:
on_poll_vote_add()(only for DMs)on_poll_vote_remove()(only for DMs)on_raw_poll_vote_add()(only for DMs)on_raw_poll_vote_remove()(only for DMs)
This also corresponds to the following attributes and classes in terms of cache:
PollAnswer.count(only for DM polls)PollResults.answer_counts(only for DM polls)
- Type:
- polls[исходный код]¶
Whether poll-related events in guilds and direct messages are enabled.
This is a shortcut to set or get both
guild_pollsanddm_polls.This corresponds to the following events:
on_poll_vote_add()(both guilds and DMs)on_poll_vote_remove()(both guilds and DMs)on_raw_poll_vote_add()(both guilds and DMs)on_raw_poll_vote_remove()(both guilds and DMs)
This also corresponds to the following attributes and classes in terms of cache:
PollAnswer.count(both guild and DM polls)PollResults.answer_counts(both guild and DM polls)
- Type:
- asyncconnect
- asyncdisconnect
- defis_closed
- defis_ws_ratelimited
- asyncreconnect
- class discord.ShardInfo(parent, shard_count)[исходный код]¶
A class that gives information and control over a specific shard.
You can retrieve this object via
AutoShardedClient.get_shard()orAutoShardedClient.shards.Добавлено в версии 1.4.
- shard_count¶
The shard count for this cluster. If this is
Nonethen the bot has not started yet.- Type:
Optional[
int]
- is_closed()[исходный код]¶
Whether the shard connection is currently closed.
- Тип результата:
- await disconnect()[исходный код]¶
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.
- Тип результата:
- await reconnect()[исходный код]¶
This function is a coroutine.
Disconnects and then connects the shard again.
- Тип результата:
- await connect()[исходный код]¶
This function is a coroutine.
Connects a shard. If the shard is already connected this does nothing.
- Тип результата:
- property latency: float¶
Measures latency between a HEARTBEAT and a HEARTBEAT_ACK in seconds for this shard. If no heartbeat has been received yet this returns
float('inf').
- is_ws_ratelimited()[исходный код]¶
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.
Добавлено в версии 1.6.
- Тип результата:
Message¶
- class discord.AllowedMentions(*, everyone=True, users=True, roles=True, replied_user=True)[исходный код]¶
A class that represents what mentions are allowed in a message.
This class can be set during
Clientinitialisation 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. IfFalsethen users are not mentioned at all. If a list ofabc.Snowflakeis 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. IfFalsethen roles are not mentioned at all. If a list ofabc.Snowflakeis 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.Добавлено в версии 1.6.
- Type:
- Параметры:
- classmethod all()[исходный код]¶
A factory method that returns a
AllowedMentionswith all fields explicitly set toTrueДобавлено в версии 1.5.
- Тип результата:
TypeVar(A, bound= AllowedMentions)
- classmethod none()[исходный код]¶
A factory method that returns a
AllowedMentionswith all fields set toFalseДобавлено в версии 1.5.
- Тип результата:
TypeVar(A, bound= AllowedMentions)
- class discord.MessageReference(*, message_id, channel_id, guild_id=None, fail_if_not_exists=True, type=('default', 0))[исходный код]¶
Represents a reference to a
Message.Добавлено в версии 1.5.
Изменено в версии 1.6: This class can now be constructed by users.
- type¶
The type of message reference. If this is not provided, assume the default behavior (i.e., reply).
Добавлено в версии 2.7.
- Type:
Optional[
MessageReferenceType]
- fail_if_not_exists¶
Whether replying to the referenced message should raise
HTTPExceptionif the message no longer exists or Discord could not fetch the message.Добавлено в версии 1.7.
- Type:
- resolved¶
The message that this reference resolved to. If this is
Nonethen 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.
Добавлено в версии 1.6.
- Type:
Optional[Union[
Message,DeletedReferencedMessage]]
- Параметры:
- classmethod from_message(message, *, fail_if_not_exists=True, type=('default', 0))[исходный код]¶
Creates a
MessageReferencefrom an existingMessage.Добавлено в версии 1.6.
- Параметры:
message (
Message) – The message to be converted into a reference.fail_if_not_exists (
bool) –Whether replying to the referenced message should raise
HTTPExceptionif the message no longer exists or Discord could not fetch the message.Добавлено в версии 1.7.
type (
MessageReferenceType) –The type of reference to create. Defaults to
MessageReferenceType.default(reply).Добавлено в версии 2.7.
- Результат:
A reference to the message.
- Тип результата:
TypeVar(MR, bound= MessageReference)
- class discord.MessageCall(state, data)[исходный код]¶
Represents information about a call in a private channel.
Добавлено в версии 2.6.
- Параметры:
state (
ConnectionState)data (
MessageCall)
- asyncadd_reaction
- asyncclear_reaction
- asyncclear_reactions
- asyncdelete
- asyncedit
- asyncend_poll
- asyncfetch
- asyncforward_to
- asyncpin
- asyncpublish
- asyncremove_reaction
- asyncreply
- defto_reference
- asyncunpin
- class discord.PartialMessage(*, channel, id)[исходный код]¶
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.
Добавлено в версии 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,PartialMessageable]
- Параметры:
channel (
TextChannel|VoiceChannel|StageChannel|Thread|DMChannel|PartialMessageable)id (
int)
- 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_messagespermission.Изменено в версии 1.1: Added the new
delaykeyword-only parameter.- Параметры:
- Исключение:
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.
You must have the
send_messagespermission to do this.If the message is not your own then the
manage_messagespermission is also needed.- Исключение:
Forbidden – You do not have the proper permissions to publish this message.
HTTPException – Publishing the message failed.
- Тип результата:
- await pin(*, reason=None)¶
This function is a coroutine.
Pins the message.
You must have the
pin_messagespermission to do this in a non-private channel context.- Параметры:
The reason for pinning the message. Shows up on the audit log.
Добавлено в версии 1.4.
- Исключение:
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.
- Тип результата:
- await unpin(*, reason=None)¶
This function is a coroutine.
Unpins the message.
You must have the
pin_messagespermission to do this in a non-private channel context.- Параметры:
The reason for unpinning the message. Shows up on the audit log.
Добавлено в версии 1.4.
- Исключение:
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, a custom
GuildEmoji, or anAppEmoji.You must have the
read_message_historypermission to use this. If nobody else has reacted to the message using this emoji, theadd_reactionspermission is required.- Параметры:
emoji (
GuildEmoji|AppEmoji|PartialEmoji|str) – The emoji to react with.- Исключение:
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, a custom
GuildEmoji, or anAppEmoji.If the reaction is not your own (i.e.
memberparameter is not you) then themanage_messagespermission is needed.The
memberparameter must represent a member and meet theabc.Snowflakeabc.- Параметры:
emoji (
GuildEmoji|AppEmoji|PartialEmoji|str|Reaction) – The emoji to remove.member (
Snowflake) – The member for which to remove the reaction.
- Исключение:
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, a custom
GuildEmoji, or anAppEmoji.You need the
manage_messagespermission to use this.Добавлено в версии 1.3.
- Параметры:
emoji (
GuildEmoji|AppEmoji|PartialEmoji|str|Reaction) – The emoji to clear.- Исключение:
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_messagespermission to use this.- Исключение:
HTTPException – Removing the reactions failed.
Forbidden – You do not have the proper permissions to remove all the reactions.
- Тип результата:
- await reply(content=None, **kwargs)¶
This function is a coroutine.
A shortcut method to
abc.Messageable.send()to reply to theMessage.Добавлено в версии 1.6.
- Результат:
The message that was sent.
- Тип результата:
- Исключение:
HTTPException – Sending the message failed.
Forbidden – You do not have the proper permissions to send the message.
InvalidArgument – The
fileslist is not of the appropriate size, or you specified bothfileandfiles.
- Параметры:
- await forward_to(channel, **kwargs)¶
This function is a coroutine.
A shortcut method to
abc.Messageable.send()to forward theMessageto a channel.Добавлено в версии 2.7.
- Параметры:
channel (
TextChannel|VoiceChannel|StageChannel|Thread|DMChannel|PartialMessageable|GroupChannel) – The channel to forward this to.- Результат:
The message that was sent.
- Тип результата:
- Исключение:
HTTPException – Sending the message failed.
Forbidden – You do not have the proper permissions to send the message.
InvalidArgument – The
fileslist is not of the appropriate size, or you specified bothfileandfiles.
- to_reference(*, fail_if_not_exists=True, type=None)¶
Creates a
MessageReferencefrom the current message.Добавлено в версии 1.6.
- Параметры:
fail_if_not_exists (
bool) –Whether replying using the message reference should raise
HTTPExceptionif the message no longer exists or Discord could not fetch the message.Добавлено в версии 1.7.
type (
MessageReferenceType) –The type of message reference. Defaults to a reply.
Добавлено в версии 2.7.
- Результат:
The reference to this message.
- Тип результата:
- guild¶
The guild that the partial message belongs to, if applicable.
- await fetch()[исходный код]¶
This function is a coroutine.
Fetches the partial message to a full
Message.- Результат:
The full message.
- Тип результата:
- Исключение:
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)[исходный код]¶
This function is a coroutine.
Edits the message.
Изменено в версии 1.7:
discord.Messageis returned instead ofNoneif an edit took place.- Параметры:
content (Optional[
str]) – The new content to replace the message with. Could beNoneto remove the content.embed (Optional[
Embed]) – The new embed to replace the original with. Could beNoneto remove the embed.embeds (Optional[List[
Embed]]) –A list of embeds to upload. Must be a maximum of 10.
Добавлено в версии 2.0.
suppress (
bool) – Whether to suppress embeds for the message. This removes all the embeds if set toTrue. If set toFalsethis brings the embeds back if they were suppressed. Using this parameter requiresmanage_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 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_mentionsare used instead.view (Optional[
BaseView]) –The updated view to update this message with. If
Noneis passed then the view is removed.Добавлено в версии 2.0.
fields (
Any)
- Результат:
The message that was edited.
- Тип результата:
- Исключение:
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.
- await end_poll()[исходный код]¶
This function is a coroutine.
Immediately ends the poll associated with this message. Only doable by the poll’s owner.
Добавлено в версии 2.6.
- Результат:
The updated message.
- Тип результата:
- Исключение:
Forbidden – You do not have permissions to end this poll.
HTTPException – Ending this poll failed.
- class discord.File(fp, filename=None, *, description=None, spoiler=False)[исходный код]¶
A parameter object used for
abc.Messageable.send()for sending file objects.Примечание
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.
Примечание
If the file-like object passed is opened via
openthen 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.nameor iffpis a string then thefilenamewill default to the string given.- Type:
Optional[
str]
Embed¶
- clsEmbed.from_dict
- defadd_field
- defappend_field
- defclear_fields
- defcopy
- definsert_field_at
- defremove_author
- defremove_field
- defremove_footer
- defremove_image
- defremove_thumbnail
- defset_author
- defset_field_at
- defset_footer
- defset_image
- defset_thumbnail
- defto_dict
- 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)[исходный код]¶
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.
Добавлено в версии 2.0.
For ease of use, all parameters that expect a
strare implicitly cast tostrfor you.- title¶
The title of the embed. This can be set during initialisation. Must be 256 characters or fewer.
- Type:
- 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:
- description¶
The description of the embed. This can be set during initialisation. Must be 4096 characters or fewer.
- Type:
- 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:
- colour¶
The colour code of the embed. Aliased to
coloras well. This can be set during initialisation.
- Параметры:
type (
Literal['rich','image','video','gifv','article','link','auto_moderation_message','poll_result'])fields (
list[EmbedField] |None)author (
EmbedAuthor|None)footer (
EmbedFooter|None)image (
str|EmbedMedia|None)thumbnail (
str|EmbedMedia|None)
- classmethod from_dict(data)[исходный код]¶
Converts a
dictto aEmbedprovided it is in the format that Discord expects it to be in.You can find out about this format in the official Discord documentation.
- copy()[исходный код]¶
Creates a shallow copy of the
Embedobject.
Returns an
EmbedFooterdenoting 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.
Clears embed’s footer information.
This function returns the class instance to allow for fluent-style chaining.
Добавлено в версии 2.0.
- property image: EmbedMedia | None¶
Returns an
EmbedMediadenoting the image contents.Attributes you can access are:
urlproxy_urlwidthheight
If the image is not set then None is returned.
- set_image(*, url)[исходный код]¶
Sets the image for the embed content.
This function returns the class instance to allow for fluent-style chaining.
Изменено в версии 1.4: Passing None removes the image.
- remove_image()[исходный код]¶
Removes the embed’s image.
This function returns the class instance to allow for fluent-style chaining.
Добавлено в версии 2.0.
- property thumbnail: EmbedMedia | None¶
Returns an
EmbedMediadenoting the thumbnail contents.Attributes you can access are:
urlproxy_urlwidthheight
If the thumbnail is not set then None is returned.
- set_thumbnail(*, url)[исходный код]¶
Sets the thumbnail for the embed content.
This function returns the class instance to allow for fluent-style chaining.
Изменено в версии 1.4: Passing None removes the thumbnail.
- remove_thumbnail()[исходный код]¶
Removes the embed’s thumbnail.
This function returns the class instance to allow for fluent-style chaining.
Добавлено в версии 2.0.
- property video: EmbedMedia | None¶
Returns an
EmbedMediadenoting the video contents.Attributes include:
urlfor the video URL.heightfor the video height.widthfor the video width.
If the video is not set then None is returned.
- property provider: EmbedProvider | None¶
Returns an
EmbedProviderdenoting the provider contents.The only attributes that might be accessed are
nameandurl.If the provider is not set then None is returned.
- property author: EmbedAuthor | None¶
Returns an
EmbedAuthordenoting 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)[исходный код]¶
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.
Добавлено в версии 1.4.
- property fields: list[EmbedField]¶
Returns a
listofEmbedFieldobjects denoting the field contents.See
add_field()for possible values you can access.If the attribute has no value then
Noneis returned.
- append_field(field)[исходный код]¶
Appends an
EmbedFieldobject to the embed.Добавлено в версии 2.0.
- Параметры:
field (
EmbedField) – The field to add.- Тип результата:
- 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. There must be 25 fields or fewer.
- 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. There must be 25 fields or fewer.
Добавлено в версии 1.2.
- Параметры:
- Тип результата:
TypeVar(E, bound= Embed)
- clear_fields()[исходный код]¶
Removes all fields from this embed.
- Тип результата:
- 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.
Примечание
When deleting a field by index, the index of the other fields shift to fill the gap just like a regular list.
- 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. There must be 25 fields or fewer.
This function returns the class instance to allow for fluent-style chaining.
- Параметры:
- Исключение:
IndexError – An invalid index was provided.
- Тип результата:
TypeVar(E, bound= Embed)
- to_dict()[исходный код]¶
Converts this embed object into a dict.
- Результат:
A dictionary of
strembed keys bound to the respective value.- Тип результата:
Embed
- clsEmbedField.from_dict
- defto_dict
- class discord.EmbedField(name, value, inline=False)[исходный код]¶
Represents a field on the
Embedobject.Добавлено в версии 2.0.
- classmethod from_dict(data)[исходный код]¶
Converts a
dictto aEmbedFieldprovided it is in the format that Discord expects it to be in.You can find out about this format in the official Discord documentation.
- class discord.EmbedAuthor(name, url=None, icon_url=None)[исходный код]¶
Represents the author on the
Embedobject.Добавлено в версии 2.5.
- proxy_icon_url¶
The proxied URL of the author icon image. This can’t be set directly, it is set by Discord.
- Type:
Represents the footer on the
Embedobject.Добавлено в версии 2.5.
The text inside the footer.
- Type:
The URL of the footer icon image.
- Type:
The proxied URL of the footer icon image. This can’t be set directly, it is set by Discord.
- Type:
- class discord.EmbedMedia(url)[исходный код]¶
Represents a media on the
Embedobject. This includes thumbnails, images, and videos.Добавлено в версии 2.5.
- Параметры:
url (
str)
Poll¶
- defadd_answer
- asyncend
- defget_answer
- defhas_ended
- deftotal_votes
- class discord.Poll(question, *, answers=None, duration=24, allow_multiselect=False, layout_type=('default', 1))[исходный код]¶
Represents a Poll. Polls are sent in regular messages, and you must have
send_pollsto send them.Добавлено в версии 2.6.
- question¶
The poll’s question media, or a
strrepresenting the question text. Question text can be up to 300 characters.
- answers¶
A list of the poll’s answers. A maximum of 10 answers can be set.
- Type:
Optional[List[
PollAnswer]]
- duration¶
The number of hours until this poll expires. Users must specify this when creating a poll, but existing polls return
expiryinstead. Defaults to 24.- Type:
- layout_type¶
The poll’s layout type. Only one exists at the moment.
- Type:
- results¶
The results of this poll recieved from Discord. If
None, this should be considered «unknown» rather than «no» results.- Type:
Optional[
PollResults]
- Параметры:
- property expiry: datetime | None[исходный код]¶
An aware datetime object that specifies the date and time in UTC when the poll will end.
- has_ended()[исходный код]¶
Checks if this poll has completely ended. Shortcut for
PollResults.is_finalized, if available.
- total_votes()[исходный код]¶
Shortcut for
PollResults.total_votes()This may not be precise ifis_finalizedisFalse.
- get_answer(id)[исходный код]¶
Get a poll answer by ID.
- Параметры:
id (
int) – The ID to search for.- Результат:
The returned answer or
Noneif not found.- Тип результата:
- add_answer(text, *, emoji=None)[исходный код]¶
Add an answer to this poll.
This function returns the class instance to allow for fluent-style chaining.
- Параметры:
text (
str) – The answer text. Maximum 55 characters.emoji (
GuildEmoji|AppEmoji|PartialEmoji|str|None) – The answer’s emoji.
- Исключение:
ValueError – The poll already has 10 answers or
textexceeds the character length.RuntimeError – You cannot add an answer to an existing poll.
- Тип результата:
Примеры
Regular usage
poll = Poll( question=PollMedia("What's your favorite color?"), answers=[PollAnswer("Red", "❤")] duration=24, allow_multiselect=False ) poll.add_answer(text="Green", emoji="💚") poll.add_answer(text="Blue", emoji="💙")
Chaining style
poll = Poll("What's your favorite color?").add_answer("Red", emoji="❤").add_answer("Green").add_answer("Blue")
- await end()[исходный код]¶
Immediately ends this poll, if attached to a message. Only doable by the poll’s owner. Shortcut to
Message.end_poll()- Результат:
The updated message.
- Тип результата:
- Исключение:
Forbidden – You do not have permissions to end this poll.
HTTPException – Ending this poll failed.
RuntimeError – This poll wasn’t recieved from a message.
- class discord.PollMedia(text, emoji=None)[исходный код]¶
Represents a poll media object that supports both questions and answers.
Добавлено в версии 2.6.
- text¶
The question/answer text. May have up to 300 characters for questions and 55 characters for answers.
- Type:
- emoji¶
The answer’s emoji.
- Type:
Optional[Union[
GuildEmoji,AppEmoji,PartialEmoji,str]]
- Параметры:
text (
str)emoji (
GuildEmoji|AppEmoji|PartialEmoji|str|None)
- class discord.PollAnswer(text, emoji=None)[исходный код]¶
Represents a poll answer object.
Добавлено в версии 2.6.
- id¶
The answer’s ID. It currently starts at
1for the first answer, then goes up sequentially. It may not be reliable to depend on this.- Type:
- Параметры:
text (
str)emoji (
GuildEmoji|AppEmoji|PartialEmoji|str|None)
- property text: str¶
The answer’s text. Shortcut for
PollMedia.text.
- property emoji: GuildEmoji | AppEmoji | PartialEmoji | None¶
The answer’s emoji. Shortcut for
PollMedia.emoji.
- voters(*, limit=None, after=None)[исходный код]¶
Returns an
AsyncIteratorrepresenting the users that have voted with this answer. Only works if this poll was recieved from Discord.The
afterparameter must represent a member and meet theabc.Snowflakeabc.- Параметры:
- Yields:
Union[
User,Member] – The member (if retrievable) or the user that has voted with this answer. The case where it can be aMemberis in a guild message context. Sometimes it can be aUserif the member has left the guild.- Исключение:
HTTPException – Getting the voters for the answer failed.
RuntimeError – This poll wasn’t recieved from a message.
- Тип результата:
VoteIterator
Примеры
Usage
async for user in answer.users(): print(f'{user} voted **{answer.text}**!')
Flattening into a list:
users = await answer.users().flatten() # users is now a list of User... winner = random.choice(users) await channel.send(f'{winner} has won the raffle.')
- class discord.PollAnswerCount(data)[исходный код]¶
Represents a poll answer count object.
Добавлено в версии 2.6.
- id¶
The answer’s ID. It currently starts at
1for the first answer, then goes up sequentially. It may not be reliable to depend on this.- Type:
- Параметры:
data (
PollAnswerCount)
- deftotal_votes
- class discord.PollResults(data)[исходный код]¶
Represents a poll results object.
Добавлено в версии 2.6.
- is_finalized¶
Whether the poll has ended and all answer counts have been precisely tallied.
- Type:
- answer_counts¶
A list of counts for each answer. If an answer isn’t included, it has no votes.
- Type:
List[
PollAnswerCount]
- Параметры:
data (
PollResults)
- total_votes()[исходный код]¶
Get the total number of votes across all answers. This may not be accurate if
is_finalizedisFalse.- Результат:
The total number of votes on this poll.
- Тип результата:
Flags¶
- class discord.MemberCacheFlags(**kwargs)[исходный код]¶
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_flagsparameter inClient.Due to a quirk in how Discord works, in order to ensure proper cleanup of cache resources it is recommended to have
Intents.membersenabled. 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.
Добавлено в версии 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:
- Параметры:
kwargs (
bool)
- classmethod all()[исходный код]¶
A factory method that creates a
MemberCacheFlagswith everything enabled.- Тип результата:
- classmethod none()[исходный код]¶
A factory method that creates a
MemberCacheFlagswith everything disabled.- Тип результата:
- 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:
- interaction[исходный код]¶
Whether to cache members obtained through interactions.
This includes members received through
discord.Interactionanddiscord.Option.- Type:
- classmethod from_intents(intents)[исходный код]¶
A factory method that creates a
MemberCacheFlagsbased on the currently selectedIntents.- Параметры:
intents (
Intents) – The intents to select from.- Результат:
The resulting member cache flags.
- Тип результата:
- active
- app_commands_badge
- application_auto_moderation_rule_create_badge
- embedded
- gateway_guild_members
- gateway_guild_members_limited
- gateway_message_content
- gateway_message_content_limited
- gateway_presence
- gateway_presence_limited
- group_dm_create
- managed_emoji
- rpc_has_connected
- value
- verification_pending_guild_limit
- class discord.ApplicationFlags(**kwargs)[исходный код]¶
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.
Добавлено в версии 2.0.
- value¶
The raw value. You should query flags via the properties rather than using this raw value.
- Type:
- Параметры:
kwargs (
bool)
- managed_emoji[исходный код]¶
Returns
Trueif the application is a managed emoji.- Type:
- group_dm_create[исходный код]¶
Returns
Trueif the application can create group DMs.- Type:
- application_auto_moderation_rule_create_badge[исходный код]¶
Returns
Trueif the application uses the Auto Moderation API.Добавлено в версии 2.5.
- Type:
- rpc_has_connected[исходный код]¶
Returns
Trueif the application has connected to RPC.- Type:
- gateway_presence[исходный код]¶
Returns
Trueif the application is verified and is allowed to receive presence information over the gateway.- Type:
- gateway_presence_limited[исходный код]¶
Returns
Trueif the application is allowed to receive limited presence information over the gateway.- Type:
- gateway_guild_members[исходный код]¶
Returns
Trueif the application is verified and is allowed to receive guild members information over the gateway.- Type:
- gateway_guild_members_limited[исходный код]¶
Returns
Trueif the application is allowed to receive limited guild members information over the gateway.- Type:
- verification_pending_guild_limit[исходный код]¶
Returns
Trueif the application is currently pending verification and has hit the guild limit.- Type:
- embedded[исходный код]¶
Returns
Trueif the application is embedded within the Discord client.- Type:
- gateway_message_content[исходный код]¶
Returns
Trueif the application is allowed to read message contents in guilds.- Type:
- gateway_message_content_limited[исходный код]¶
Returns
Trueif the application is currently pending verification and has hit the guild limit.- Type:
- app_commands_badge[исходный код]¶
Returns
Trueif the application has registered at least one global application command, and by extension has the badge.Добавлено в версии 2.1.
- Type:
- active[исходный код]¶
Returns
Trueif the app is considered active. Applications are considered active if they have had any command executions in the past 30 days.Добавлено в версии 2.3.
- Type:
- class discord.SystemChannelFlags(**kwargs)[исходный код]¶
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:
- Параметры:
kwargs (
bool)
- join_notifications[исходный код]¶
Returns
Trueif the system channel is used for member join notifications.- Type:
Returns
Trueif the system channel is used for «Nitro boosting» notifications.- Type:
- guild_reminder_notifications[исходный код]¶
Returns
Trueif the system channel is used for server setup helpful tips notifications.Добавлено в версии 2.0.
- Type:
- join_notification_replies[исходный код]¶
Returns
Trueif the system channel is allowing member join sticker replies.Добавлено в версии 2.0.
- Type:
- class discord.MessageFlags(**kwargs)[исходный код]¶
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.
Добавлено в версии 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:
- Параметры:
kwargs (
bool)
- crossposted[исходный код]¶
Returns
Trueif the message is the original crossposted message.- Type:
- is_crossposted[исходный код]¶
Returns
Trueif the message was crossposted from another channel.- Type:
- suppress_embeds[исходный код]¶
Returns
Trueif the message’s embeds have been suppressed.- Type:
- source_message_deleted[исходный код]¶
Returns
Trueif the source message for this crosspost has been deleted.- Type:
- urgent[исходный код]¶
Returns
Trueif the source message is an urgent message.An urgent message is one sent by Discord Trust and Safety.
- Type:
- has_thread[исходный код]¶
Returns
Trueif the source message is associated with a thread.Добавлено в версии 2.0.
- Type:
- ephemeral[исходный код]¶
Returns
Trueif the source message is ephemeral.Добавлено в версии 2.0.
- Type:
- loading[исходный код]¶
Returns
Trueif the source message is deferred.The user sees a „thinking“ state.
Добавлено в версии 2.0.
- Type:
- failed_to_mention_some_roles_in_thread[исходный код]¶
Returns
Trueif some roles are failed to mention in a thread.Добавлено в версии 2.0.
- Type:
- suppress_notifications[исходный код]¶
Returns
Trueif the source message does not trigger push and desktop notifications.Users will still receive mentions.
Добавлено в версии 2.4.
- Type:
- is_voice_message[исходный код]¶
Returns
Trueif this message is a voice message.Добавлено в версии 2.5.
- Type:
- is_components_v2[исходный код]¶
Returns
Trueif this message has v2 components. This flag disables sending content, embed, and embeds.Добавлено в версии 2.7.
- Type:
- has_snapshot[исходный код]¶
Returns
Trueif this message has a snapshot from message forwarding.Добавлено в версии 2.7.
- Type:
- class discord.AttachmentFlags(**kwargs)[исходный код]¶
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.
Добавлено в версии 2.5.
- value¶
The raw value. You should query flags via the properties rather than using this raw value.
- Type:
- Параметры:
kwargs (
bool)
- is_clip[исходный код]¶
Returns
Trueif the attachment is a clip.- Type:
- is_thumbnail[исходный код]¶
Returns
Trueif the attachment is a thumbnail.- Type:
- is_remix[исходный код]¶
Returns
Trueif the attachment has been remixed.- Type:
- active_developer
- bot_http_interactions
- bug_hunter
- bug_hunter_level_2
- discord_certified_moderator
- early_supporter
- early_verified_bot_developer
- hypesquad
- hypesquad_balance
- hypesquad_bravery
- hypesquad_brilliance
- partner
- premium_promo_dismissed
- staff
- system
- team_user
- value
- verified_bot
- verified_bot_developer
- defall
- class discord.PublicUserFlags(**kwargs)[исходный код]¶
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.
Добавлено в версии 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:
- Параметры:
kwargs (
bool)
- staff[исходный код]¶
Returns
Trueif the user is a Discord Employee.- Type:
- partner[исходный код]¶
Returns
Trueif the user is a Discord Partner.- Type:
- hypesquad[исходный код]¶
Returns
Trueif the user is a HypeSquad Events member.- Type:
- bug_hunter[исходный код]¶
Returns
Trueif the user is a Bug Hunter- Type:
Returns
Trueif the user is marked as dismissed Nitro promotion- Type:
- hypesquad_bravery[исходный код]¶
Returns
Trueif the user is a HypeSquad Bravery member.- Type:
- hypesquad_brilliance[исходный код]¶
Returns
Trueif the user is a HypeSquad Brilliance member.- Type:
- hypesquad_balance[исходный код]¶
Returns
Trueif the user is a HypeSquad Balance member.- Type:
- early_supporter[исходный код]¶
Returns
Trueif the user is an Early Supporter.- Type:
- team_user[исходный код]¶
Returns
Trueif the user is a Team User.- Type:
- system[исходный код]¶
Returns
Trueif the user is a system user (i.e. represents Discord officially).- Type:
- bug_hunter_level_2[исходный код]¶
Returns
Trueif the user is a Bug Hunter Level 2- Type:
- verified_bot[исходный код]¶
Returns
Trueif the user is a Verified Bot.- Type:
- verified_bot_developer[исходный код]¶
Returns
Trueif the user is an Early Verified Bot Developer.- Type:
- early_verified_bot_developer[исходный код]¶
An alias for
verified_bot_developer.Добавлено в версии 1.5.
- Type:
- discord_certified_moderator[исходный код]¶
Returns
Trueif the user is a Discord Certified Moderator.Добавлено в версии 2.0.
- Type:
- bot_http_interactions[исходный код]¶
Returns
Trueif the bot has set an interactions endpoint url.Добавлено в версии 2.0.
- Type:
- active_developer[исходный код]¶
Returns
Trueif the user is an Active Developer.Добавлено в версии 2.3.
- Type:
- all()[исходный код]¶
List[
UserFlags]: Returns all public flags the user has.- Тип результата:
list[UserFlags]
- class discord.ChannelFlags(**kwargs)[исходный код]¶
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.
Добавлено в версии 2.0.
- value¶
The raw value. You should query flags via the properties rather than using this raw value.
- Type:
- Параметры:
kwargs (
bool)
- pinned[исходный код]¶
Returns
Trueif the thread is pinned to the top of its parent forum channel.- Type:
- require_tag[исходный код]¶
Returns
Trueif a tag is required to be specified when creating a thread in aForumChannel.Добавлено в версии 2.2.
- Type:
- hide_media_download_options[исходный код]¶
Returns
Trueif the embedded media download options are hidden for the media channel posts.Добавлено в версии 2.7.
- Type:
- class discord.SKUFlags(**kwargs)[исходный код]¶
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.
Добавлено в версии 2.5.
- value¶
The raw value. You should query flags via the properties rather than using this raw value.
- Type:
- Параметры:
kwargs (
bool)
- available[исходный код]¶
Returns
Trueif the SKU is available for purchase.- Type:
- guild_subscription[исходный код]¶
Returns
Trueif the SKU is a guild subscription.- Type:
- user_subscription[исходный код]¶
Returns
Trueif the SKU is a user subscription.- Type:
- class discord.MemberFlags(**kwargs)[исходный код]¶
Wraps up the Discord Member flags.
- x == y
Checks if two MemberFlags are equal.
- x != y
Checks if two MemberFlags 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.
Добавлено в версии 2.6.
- value¶
The raw value. You should query flags via the properties rather than using this raw value.
- Type:
- Параметры:
kwargs (
bool)
- did_rejoin[исходный код]¶
Returns
Trueif the member left and rejoined the guild.- Type:
- completed_onboarding[исходный код]¶
Returns
Trueif the member has completed onboarding.- Type:
- bypasses_verification[исходный код]¶
Returns
Trueif the member is exempt from verification requirements.Примечание
This can be edited through
edit().- Type:
- started_onboarding[исходный код]¶
Returns
Trueif the member has started onboarding.- Type:
- class discord.RoleFlags(**kwargs)[исходный код]¶
Wraps up the Discord Role flags.
- x == y
Checks if two RoleFlags are equal.
- x != y
Checks if two RoleFlags 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.
Добавлено в версии 2.6.
- 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:
- Параметры:
kwargs (
bool)
- in_prompt[исходный код]¶
Returns
Trueif the role is selectable in one of the guild’sOnboardingPrompt.- Type:
Colour¶
- clsColour.ash_theme
- clsColour.blue
- clsColour.blurple
- clsColour.brand_green
- clsColour.brand_red
- 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.embed_background
- clsColour.from_hsv
- clsColour.from_rgb
- clsColour.fuchsia
- clsColour.gold
- clsColour.green
- clsColour.greyple
- clsColour.light_gray
- clsColour.light_grey
- clsColour.light_theme
- clsColour.lighter_gray
- clsColour.lighter_grey
- clsColour.magenta
- clsColour.nitro_pink
- clsColour.og_blurple
- clsColour.onyx_theme
- clsColour.orange
- clsColour.purple
- clsColour.random
- clsColour.red
- clsColour.teal
- clsColour.yellow
- defto_rgb
- class discord.Colour(value)[исходный код]¶
Represents a 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 (
int)
- to_rgb()[исходный код]¶
Returns an (r, g, b) tuple representing the colour.
- classmethod from_rgb(r, g, b)[исходный код]¶
Constructs a
Colourfrom an RGB tuple.
- classmethod from_hsv(h, s, v)[исходный код]¶
Constructs a
Colourfrom an HSV tuple.
- classmethod default()[исходный код]¶
A factory method that returns a
Colourwith a value of0.- Тип результата:
Self
- classmethod random(*, seed=None)[исходный код]¶
A factory method that returns a
Colourwith a random hue.Примечание
The random algorithm works by choosing a colour with a random hue but with maxed out saturation and value.
Добавлено в версии 1.6.
- classmethod teal()[исходный код]¶
A factory method that returns a
Colourwith a value of0x1abc9c.- Тип результата:
Self
- classmethod dark_teal()[исходный код]¶
A factory method that returns a
Colourwith a value of0x11806a.- Тип результата:
Self
- classmethod brand_green()[исходный код]¶
A factory method that returns a
Colourwith a value of0x57F287.Добавлено в версии 2.0.
- Тип результата:
Self
- classmethod green()[исходный код]¶
A factory method that returns a
Colourwith a value of0x2ecc71.- Тип результата:
Self
- classmethod dark_green()[исходный код]¶
A factory method that returns a
Colourwith a value of0x1f8b4c.- Тип результата:
Self
- classmethod blue()[исходный код]¶
A factory method that returns a
Colourwith a value of0x3498db.- Тип результата:
Self
- classmethod dark_blue()[исходный код]¶
A factory method that returns a
Colourwith a value of0x206694.- Тип результата:
Self
- classmethod purple()[исходный код]¶
A factory method that returns a
Colourwith a value of0x9b59b6.- Тип результата:
Self
- classmethod dark_purple()[исходный код]¶
A factory method that returns a
Colourwith a value of0x71368a.- Тип результата:
Self
- classmethod magenta()[исходный код]¶
A factory method that returns a
Colourwith a value of0xe91e63.- Тип результата:
Self
- classmethod dark_magenta()[исходный код]¶
A factory method that returns a
Colourwith a value of0xad1457.- Тип результата:
Self
- classmethod gold()[исходный код]¶
A factory method that returns a
Colourwith a value of0xf1c40f.- Тип результата:
Self
- classmethod dark_gold()[исходный код]¶
A factory method that returns a
Colourwith a value of0xc27c0e.- Тип результата:
Self
- classmethod orange()[исходный код]¶
A factory method that returns a
Colourwith a value of0xe67e22.- Тип результата:
Self
- classmethod dark_orange()[исходный код]¶
A factory method that returns a
Colourwith a value of0xa84300.- Тип результата:
Self
- classmethod brand_red()[исходный код]¶
A factory method that returns a
Colourwith a value of0xED4245.Добавлено в версии 2.0.
- Тип результата:
Self
- classmethod red()[исходный код]¶
A factory method that returns a
Colourwith a value of0xe74c3c.- Тип результата:
Self
- classmethod dark_red()[исходный код]¶
A factory method that returns a
Colourwith a value of0x992d22.- Тип результата:
Self
- classmethod lighter_grey()[исходный код]¶
A factory method that returns a
Colourwith a value of0x95a5a6.- Тип результата:
Self
- classmethod lighter_gray()¶
A factory method that returns a
Colourwith a value of0x95a5a6.- Тип результата:
Self
- classmethod dark_grey()[исходный код]¶
A factory method that returns a
Colourwith a value of0x607d8b.- Тип результата:
Self
- classmethod dark_gray()¶
A factory method that returns a
Colourwith a value of0x607d8b.- Тип результата:
Self
- classmethod light_grey()[исходный код]¶
A factory method that returns a
Colourwith a value of0x979c9f.- Тип результата:
Self
- classmethod light_gray()¶
A factory method that returns a
Colourwith a value of0x979c9f.- Тип результата:
Self
- classmethod darker_grey()[исходный код]¶
A factory method that returns a
Colourwith a value of0x546e7a.- Тип результата:
Self
- classmethod darker_gray()¶
A factory method that returns a
Colourwith a value of0x546e7a.- Тип результата:
Self
- classmethod og_blurple()[исходный код]¶
A factory method that returns a
Colourwith a value of0x7289da.- Тип результата:
Self
- classmethod blurple()[исходный код]¶
A factory method that returns a
Colourwith a value of0x5865F2.- Тип результата:
Self
- classmethod greyple()[исходный код]¶
A factory method that returns a
Colourwith a value of0x99aab5.- Тип результата:
Self
- classmethod light_theme()[исходный код]¶
A factory method that returns a
Colourwith a value of0xfbfbfb. This will appear transparent on Discord’s light theme.Добавлено в версии 2.8.
- Тип результата:
Self
- classmethod ash_theme()[исходный код]¶
A factory method that returns a
Colourwith a value of0x323339. This will appear transparent on Discord’s ash theme.Добавлено в версии 2.8.
- Тип результата:
Self
- classmethod dark_theme()[исходный код]¶
A factory method that returns a
Colourwith a value of0x1a1a1e. This will appear transparent on Discord’s dark theme.Добавлено в версии 1.5.
Изменено в версии 2.8: Updated to match Discord’s new theme colour.
- Тип результата:
Self
- classmethod onyx_theme()[исходный код]¶
A factory method that returns a
Colourwith a value of0x070709. This will appear transparent on Discord’s onyx theme.Добавлено в версии 2.8.
- Тип результата:
Self
- classmethod fuchsia()[исходный код]¶
A factory method that returns a
Colourwith a value of0xEB459E.Добавлено в версии 2.0.
- Тип результата:
Self
- classmethod yellow()[исходный код]¶
A factory method that returns a
Colourwith a value of0xFEE75C.Добавлено в версии 2.0.
- Тип результата:
Self
- classmethod nitro_pink()[исходный код]¶
A factory method that returns a
Colourwith a value of0xf47fff.Добавлено в версии 2.0.
- Тип результата:
Self
- classmethod embed_background(cls, theme='dark')[исходный код]¶
A factory method that returns a
Colourcorresponding to the embed colours on discord clients, with a value of:0x2B2D31(dark)0xEEEFF1(light)0x000000(amoled).
Добавлено в версии 2.0.
- Параметры:
theme (
str) – The theme colour to apply, must be one of «dark», «light», or «amoled».- Тип результата:
Self
Activity¶
- class discord.Activity(**kwargs)[исходный код]¶
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:
- type¶
The type of activity currently being done.
- Type:
- 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.
- 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.
- 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).
- 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.
Примечание
Bots cannot access a user’s activity button URLs. Therefore, the type of this attribute will be List[
str] when received through the gateway.Добавлено в версии 2.0.
- emoji¶
The emoji that belongs to this activity.
- Type:
Optional[
PartialEmoji]
- property large_image_url: str | None¶
Returns a URL pointing to the large image asset of this activity if applicable.
- property small_image_url: str | None¶
Returns a URL pointing to the small image asset of this activity if applicable.
- class discord.BaseActivity(**kwargs)[исходный код]¶
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.
Добавлено в версии 1.3.
- class discord.Game(name, **extra)[исходный код]¶
A slimmed down version of
Activitythat 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.
- Параметры:
name (
str) – The game’s name.
- property type: ActivityType¶
Returns the game’s type. This is for compatibility with
Activity.It always returns
ActivityType.playing.
- class discord.Streaming(*, name, url, **extra)[исходный код]¶
A slimmed down version of
Activitythat 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).
Добавлено в версии 1.3.
- Type:
Optional[
str]
- assets¶
A dictionary comprised of similar keys than those in
Activity.assets.
- property type: ActivityType¶
Returns the game’s type. This is for compatibility with
Activity.It always returns
ActivityType.streaming.
- property twitch_name: str | None¶
If provided, the twitch name of the user streaming.
This corresponds to the
large_imagekey of theStreaming.assetsdictionary if it starts withtwitch:. Typically this is set by the Discord client.
- class discord.CustomActivity(name, *, emoji=None, **extra)[исходный код]¶
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.
Добавлено в версии 1.3.
- emoji¶
The emoji to pass to the activity, if any.
- Type:
Optional[
PartialEmoji]
- Параметры:
emoji (
PartialEmoji|None)extra (
Any)
- property type: ActivityType¶
Returns the activity’s type. This is for compatibility with
Activity.It always returns
ActivityType.custom.
Permissions¶
- add_reactions
- administrator
- attach_files
- ban_members
- bypass_slowmode
- change_nickname
- connect
- create_instant_invite
- create_private_threads
- create_public_threads
- deafen_members
- embed_links
- external_emojis
- external_stickers
- kick_members
- manage_channels
- manage_emojis
- manage_emojis_and_stickers
- manage_events
- manage_guild
- manage_messages
- manage_nicknames
- manage_permissions
- manage_roles
- manage_threads
- manage_webhooks
- mention_everyone
- moderate_members
- move_members
- mute_members
- pin_messages
- priority_speaker
- read_message_history
- read_messages
- request_to_speak
- send_messages
- send_messages_in_threads
- send_polls
- send_tts_messages
- send_voice_messages
- set_voice_channel_status
- speak
- start_embedded_activities
- stream
- 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.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)[исходный код]¶
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.
Изменено в версии 1.3: You can now use keyword arguments to initialize
Permissionssimilar 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
- 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:
- is_subset(other)[исходный код]¶
Returns
Trueif self has the same or fewer permissions as other.- Параметры:
other (
Permissions)- Тип результата:
- is_superset(other)[исходный код]¶
Returns
Trueif self has the same or more permissions as other.- Параметры:
other (
Permissions)- Тип результата:
- is_strict_subset(other)[исходный код]¶
Returns
Trueif the permissions on other are a strict subset of those on self.- Параметры:
other (
Permissions)- Тип результата:
- is_strict_superset(other)[исходный код]¶
Returns
Trueif the permissions on other are a strict superset of those on self.- Параметры:
other (
Permissions)- Тип результата:
- classmethod none()[исходный код]¶
A factory method that creates a
Permissionswith all permissions set toFalse.- Тип результата:
TypeVar(P, bound= Permissions)
- classmethod all()[исходный код]¶
A factory method that creates a
Permissionswith all permissions set toTrue.- Тип результата:
TypeVar(P, bound= Permissions)
- classmethod all_channel()[исходный код]¶
A
Permissionswith all channel-specific permissions set toTrueand the guild-specific ones set toFalse. The guild-specific permissions are currently:Изменено в версии 1.7: Added
stream,priority_speakeranduse_slash_commandspermissions.Изменено в версии 2.0: Added
create_public_threads,create_private_threads,manage_threads,use_external_stickers,send_messages_in_threadsandrequest_to_speakpermissions.- Тип результата:
TypeVar(P, bound= Permissions)
- classmethod general()[исходный код]¶
A factory method that creates a
Permissionswith all «General» permissions from the official Discord UI set toTrue.Изменено в версии 1.7: Permission
read_messagesis now included in the general permissions, but permissionsadministrator,create_instant_invite,kick_members,ban_members,change_nicknameandmanage_nicknamesare no longer part of the general permissions.Изменено в версии 2.7: Added
view_creator_monetization_analyticspermission.- Тип результата:
TypeVar(P, bound= Permissions)
- classmethod membership()[исходный код]¶
A factory method that creates a
Permissionswith all «Membership» permissions from the official Discord UI set toTrue.Добавлено в версии 1.7.
- Тип результата:
TypeVar(P, bound= Permissions)
- classmethod text()[исходный код]¶
A factory method that creates a
Permissionswith all «Text» permissions from the official Discord UI set toTrue.Изменено в версии 1.7: Permission
read_messagesis no longer part of the text permissions. Addeduse_slash_commandspermission.Изменено в версии 2.0: Added
create_public_threads,create_private_threads,manage_threads,send_messages_in_threadsanduse_external_stickerspermissions.- Тип результата:
TypeVar(P, bound= Permissions)
- classmethod voice()[исходный код]¶
A factory method that creates a
Permissionswith all «Voice» permissions from the official Discord UI set toTrue.- Тип результата:
TypeVar(P, bound= Permissions)
- classmethod stage()[исходный код]¶
A factory method that creates a
Permissionswith all «Stage Channel» permissions from the official Discord UI set toTrue.Добавлено в версии 1.7.
- Тип результата:
TypeVar(P, bound= Permissions)
- classmethod stage_moderator()[исходный код]¶
A factory method that creates a
Permissionswith all «Stage Moderator» permissions from the official Discord UI set toTrue.Добавлено в версии 1.7.
- Тип результата:
TypeVar(P, bound= Permissions)
- classmethod advanced()[исходный код]¶
A factory method that creates a
Permissionswith all «Advanced» permissions from the official Discord UI set toTrue.Добавлено в версии 1.7.
- Тип результата:
TypeVar(P, bound= Permissions)
- 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.
- administrator¶
Returns
Trueif a user is an administrator. This role overrides all other permissions.This also bypasses all channel-specific overrides.
- Type:
- manage_channels¶
Returns
Trueif a user can edit, delete, or create channels in the guild.This also corresponds to the «Manage Channel» channel-specific override.
- Type:
- read_messages[исходный код]¶
An alias for
view_channel.Добавлено в версии 1.3.
- Type:
- send_messages¶
Returns
Trueif a user can send messages from all or specific text channels.- Type:
- send_tts_messages¶
Returns
Trueif a user can send TTS messages from all or specific text channels.- Type:
- manage_messages¶
Returns
Trueif a user can delete messages in a text channel.Предупреждение
Starting from January 12th 2026, this will no longer grant the ability to pin/unpin messages. Use
pin_messagesinstead.- Type:
- embed_links¶
Returns
Trueif a user’s messages will automatically be embedded by Discord.- Type:
- read_message_history¶
Returns
Trueif a user can read a text channel’s previous messages.- Type:
- mention_everyone¶
Returns
Trueif a user’s@everyone,@hereor role mentions will mention in the text channel.- Type:
- use_external_emojis[исходный код]¶
An alias for
external_emojis.Добавлено в версии 1.3.
- Type:
- view_guild_insights¶
Returns
Trueif a user can view the guild’s insights.Добавлено в версии 1.3.
- Type:
- manage_roles¶
Returns
Trueif 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.Добавлено в версии 1.3.
- Type:
- manage_emojis_and_stickers[исходный код]¶
An alias for
manage_emojis.Добавлено в версии 2.0.
- Type:
- use_slash_commands¶
Returns
Trueif a user can use slash commands.Добавлено в версии 1.7.
- Type:
- use_application_commands[исходный код]¶
An alias for
use_slash_commands.Добавлено в версии 2.0.
- Type:
- request_to_speak¶
Returns
Trueif a user can request to speak in a stage channel.Добавлено в версии 1.7.
- Type:
- create_public_threads¶
Returns
Trueif a user can create public threads.Добавлено в версии 2.0.
- Type:
- create_private_threads¶
Returns
Trueif a user can create private threads.Добавлено в версии 2.0.
- Type:
- external_stickers¶
Returns
Trueif a user can use stickers from other guilds.Добавлено в версии 2.0.
- Type:
- use_external_stickers[исходный код]¶
An alias for
external_stickers.Добавлено в версии 2.0.
- Type:
- send_messages_in_threads¶
Returns
Trueif a user can send messages in threads.Добавлено в версии 2.0.
- Type:
- start_embedded_activities¶
Returns
Trueif a user can launch an activity flagged „EMBEDDED“ in a voice channel.Добавлено в версии 2.0.
- Type:
- moderate_members¶
Returns
Trueif a user can moderate members (timeout).Добавлено в версии 2.0.
- Type:
- view_creator_monetization_analytics¶
Returns
Trueif a user can view creator monetization (role subscription) analytics.Добавлено в версии 2.7.
- Type:
- use_soundboard¶
Returns
Trueif a user can use the soundboard in a voice channel.Добавлено в версии 2.7.
- Type:
- use_external_sounds¶
Returns
Trueif a user can use external soundboard sounds in a voice channel.Добавлено в версии 2.7.
- Type:
- send_voice_messages¶
Returns
Trueif a member can send voice messages.Добавлено в версии 2.5.
- Type:
- set_voice_channel_status¶
Returns
Trueif a member can set voice channel status.Добавлено в версии 2.5.
- Type:
- use_external_apps¶
Returns
Trueif a member’s user-installed apps can show public responses. Users will still be able to use user-installed apps, but responses will be ephemeral.This only applies to apps that are also not installed to the guild.
Добавлено в версии 2.6.
- Type:
- clsPermissionOverwrite.from_pair
- defis_empty
- defpair
- defupdate
- class discord.PermissionOverwrite(**kwargs)[исходный код]¶
A type that is used to represent a channel specific permission.
Unlike a regular
Permissions, the default value of a permission is equivalent toNoneand notFalse. Setting a value toFalseis explicitly denying that permission, while setting a value toTrueis explicitly allowing that permission.The values supported by this are the same as
Permissionswith 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)
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()[исходный код]¶
Returns the (allow, deny) pair from this overwrite.
- Тип результата:
- classmethod from_pair(allow, deny)[исходный код]¶
Creates an overwrite from an allow/deny pair of
Permissions.- Параметры:
allow (
Permissions)deny (
Permissions)
- Тип результата:
TypeVar(PO, bound= PermissionOverwrite)
- is_empty()[исходный код]¶
Checks if the permission overwrite is currently empty.
An empty permission overwrite is one that has no overwrites set to
TrueorFalse.- Результат:
Indicates if the overwrite is empty.
- Тип результата:
- 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.
Application Role Connections¶
- class discord.ApplicationRoleConnectionMetadata(*, type, key, name, description, name_localizations=..., description_localizations=...)[исходный код]¶
Represents role connection metadata for a Discord application.
Добавлено в версии 2.4.
- Параметры:
type (
ApplicationRoleConnectionMetadataType) – The type of metadata value.key (
str) – The key for this metadata field. May only be thea-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 (
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 (
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.