Code Reference
Dyscord is a library to enable a reasonably 1:1 binding between python and the official API.
client
special
api
special
api_v9
API_V9
Version 9 of the discord API.
get_gateway_bot(token)
async
classmethod
Get URL of the gateway for bots.
get_gateway()
async
classmethod
Get URL of the gateway.
get_global_application_commands()
async
classmethod
Get all global application commands.
create_global_application_command(command_structure)
async
classmethod
Create or update a global application command.
get_global_application_command(command_id)
async
classmethod
Get a global application command.
edit_global_application_command(command_id, command_structure)
async
classmethod
Edit a global application command.
delete_global_application_command(command_id)
async
classmethod
Delete a global application command.
bulk_overwrite_global_application_commands(command_id)
async
classmethod
Unimplemented.
get_guild_application_commands(guild_id)
async
classmethod
Get all application commands from a specific guild.
create_guild_application_command(guild_id, command_structure)
async
classmethod
Create a guild appplication command.
get_guild_application_command(guild_id, command_id)
async
classmethod
Get a specific guild application command.
edit_guild_application_command(guild_id, command_id, command_structure)
async
classmethod
Edit a guild application command.
delete_guild_application_command(guild_id, command_id)
async
classmethod
Delete an application command.
bulk_overwrite_guild_application_command(guild_id, command_id, command_structure)
async
classmethod
TODO: Copy from api docs.
create_interaction_response(interaction_id, interaction_token, data_structure)
async
classmethod
TODO: Copy from api docs.
get_original_interaction_response(interaction_token)
async
classmethod
TODO: Copy from api docs.
edit_original_interaction_response(interaction_token, data_structure)
async
classmethod
Edit Original Interaction Response.
PATCH/webhooks/{application.id}/{interaction.token}/messages/@original
Edits the initial Interaction response. Functions the same as Edit Webhook Message.
delete_original_interaction_response(interaction_token)
async
classmethod
Delete Original Interaction Response.
DELETE/webhooks/{application.id}/{interaction.token}/messages/@original
Deletes the initial Interaction response. Returns 204 on success.
create_followup_message(interaction_token, data_structure)
async
classmethod
Create Followup Message.
POST/webhooks/{application.id}/{interaction.token}
Create a followup message for an Interaction. Functions the same as Execute Webhook, but wait is always true, and flags can be set to 64 in the body to send an ephemeral message. The thread_id query parameter is not required (and is furthermore ignored) when using this endpoint for interaction followups.
get_followup_message(interaction_token, message_id)
async
classmethod
Get Followup Message.
GET/webhooks/{application.id}/{interaction.token}/messages/{message.id}
Returns a followup message for an Interaction. Functions the same as Get Webhook Message. Does not support ephemeral followups.
edit_followup_message(interaction_token, message_id, data_structure)
async
classmethod
Edit Followup Message.
PATCH/webhooks/{application.id}/{interaction.token}/messages/{message.id}
Edits a followup message for an Interaction. Functions the same as Edit Webhook Message. Does not support ephemeral followups.
delete_followup_message(interaction_token, message_id)
async
classmethod
Delete Followup Message.
DELETE/webhooks/{application.id}/{interaction.token}/messages/{message.id}
Deletes a followup message for an Interaction. Returns 204 on success. Does not support ephemeral followups.
get_channel(channel_id)
async
classmethod
Get channel by ID.
create_message(channel_id, message_payload)
async
classmethod
TODO: Copy from api docs.
get_guild(guild_id)
async
classmethod
Get guilds.
TODO: Document this.
get_guild_roles(guild_id)
async
classmethod
Get Guild Roles.
GET/guilds/{guild.id}/roles
Returns a list of role objects for the guild.
get_current_user()
async
classmethod
Get Current User.
GET/users/@me
Returns the user object of the requester's account. For OAuth2, this requires the identify scope, which will return the object without an email, and optionally the email scope, which returns the object with an email.
get_user(user_id)
async
classmethod
Get User.
GET/users/{user.id}
Returns a user object for a given user ID.
create_dm(recipient_id)
async
classmethod
Create DM.
POST/users/@me/channels
Create a new DM channel with a user. Returns a DM channel object.
discord_client
DiscordClient
Client for interaction with Discord.
on_any(self, object, raw_event)
async
Called for every event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_event |
dict |
Raw dict from discord API. |
required |
on_channel_create(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_channel_delete(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_channel_pins_update(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_channel_update(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
__init__(self, token, application_id=None)
special
Instantiate a DiscordClient.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
token |
str |
Valid token to access discord. Only |
required |
application_id |
str |
The application id. Can be left to None if client will not use Interactions. |
None |
on_guild_ban_add(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
configure_intents(self, guilds=False, guild_members=False, guild_bans=False, guild_emoji_and_stickers=False, guild_integrations=False, guild_webhooks=False, guild_invites=False, guild_voice_states=False, guild_presences=False, guild_messages=False, guild_message_reactions=False, guild_message_typeing=False, direct_messages=False, direct_message_reactions=False, direct_messages_typeing=False)
Configure intents before connecting.
For more details, read the official docs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
guilds |
bool |
Receive events related to guilds the client is a part of. |
False |
guild_members |
bool |
Receive events related to guild members. |
False |
guild_bans |
bool |
Receive events related to guild bans. |
False |
guild_emoji_and_stickers |
bool |
Receive events related to guild emoji and stickers. |
False |
guild_integrations |
bool |
Receive events related to guild Interactions. |
False |
guild_webhooks |
bool |
Receive events related to guild Webhooks. |
False |
guild_invites |
bool |
Receive events related to guild invites |
False |
guild_voice_states |
bool |
Receive events related to guild voice states. |
False |
guild_presences |
bool |
Receive events related to guild presences. |
False |
guild_messages |
bool |
Receive events related to guild messages. |
False |
guild_message_reactions |
bool |
Receive events related to guild reactions. |
False |
guild_message_typeing |
bool |
Receive events related to guild members starting to type. |
False |
direct_messages |
bool |
Receive events related to direct messages. |
False |
direct_message_reactions |
bool |
Receive events related to direct message reactions. |
False |
direct_messages_typeing |
bool |
Receive events related to users typing in direct messages. |
False |
on_guild_ban_remove(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_guild_create(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_guild_delete(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_guild_emojis_update(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_guild_integrations_update(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_guild_member_add(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_guild_member_remove(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
set_all_intents(self)
Set all intents to True. For more information see the configure_intents() function.
on_guild_member_update(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
run(self, loop=None)
Start the async loop and run forever.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
loop |
asyncio.AbstractEventLoop |
If desired, use a given asyncio compatible loop. One will be created if not given. |
None |
on_guild_role_create(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_guild_role_delete(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_guild_role_update(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_guild_stickers_update(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_guild_update(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_integration_create(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_integration_delete(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_integration_update(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_invite_create(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_invite_delete(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_message_create(self, message, raw_message)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
message |
Message |
Python object representing the event. |
required |
raw_message |
dict |
Raw dict from discord API. |
required |
on_message_delete(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_message_delete_bulk(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_message_reaction_add(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_message_reaction_remove(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_message_reaction_remove_all(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_message_reaction_remove_emoji(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_message_update(self, message, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
message |
MessageUpdate |
Updated message. Note that many fields may be missing from this entity! |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_presence_update(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_ready(self, ready, raw_ready)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
ready |
Ready |
Python object representing the event. |
required |
raw_ready |
dict |
Raw dict from discord API. |
required |
on_resumed(self, resume, raw_resume)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
resume |
None |
Always None. |
required |
raw_resume |
dict |
Raw dict from discord API. |
required |
on_stage_instance_create(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_stage_instance_delete(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_stage_instance_update(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_thread_create(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_thread_delete(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_thread_list_sync(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_thread_member_update(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_thread_members_update(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_thread_update(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_typing_start(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_voice_state_update(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_webhooks_update(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_interaction_create(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
decorate_handler(event)
classmethod
Register a given function to a given event string.
This function should be used as a decorator around a function to map that function to a given event. The decorator takes one argument, a string which maps to the type of event we should map to. See the definition of DISCORD_EVENTS for names to map against.
The decorated mapped should by an async
function, although synchronous functions are allowed (and highly discouraged).
The arguments of the decorated decide which python objects are given to the function when the given event is called. The mapping is as follows:
- 1 Argument -> (discord_object)
- 2 Argument -> (discord_object, raw_dict)
- 3 Argument -> (discord_object, raw_dict, client)
The discord_object
will be a python representation of the event object.
The raw_dict
is a raw dictionary the API emitted.
The client
is the DiscordClient instance.
decorate_class(target_class)
classmethod
Register a given class and attempt to call any valid on_
By convention functions of the class should be async.
enumerations
DISCORD_EVENTS (Enum)
Enumeration of various discord events.
Attributes:
Name | Type | Description |
---|---|---|
CHANNEL_CREATE |
enum |
|
CHANNEL_DELETE |
enum |
|
CHANNEL_PINS_UPDATE |
enum |
|
CHANNEL_UPDATE |
enum |
|
GUILD_BAN_ADD |
enum |
|
GUILD_BAN_REMOVE |
enum |
|
GUILD_CREATE |
enum |
|
GUILD_DELETE |
enum |
|
GUILD_EMOJIS_UPDATE |
enum |
|
GUILD_INTEGRATIONS_UPDATE |
enum |
|
GUILD_MEMBER_ADD |
enum |
|
GUILD_MEMBER_REMOVE |
enum |
|
GUILD_MEMBER_UPDATE |
enum |
|
GUILD_ROLE_CREATE |
enum |
|
GUILD_ROLE_DELETE |
enum |
|
GUILD_ROLE_UPDATE |
enum |
|
GUILD_STICKERS_UPDATE |
enum |
|
GUILD_UPDATE |
enum |
|
INTEGRATION_CREATE |
enum |
|
INTEGRATION_DELETE |
enum |
|
INTEGRATION_UPDATE |
enum |
|
INVITE_CREATE |
enum |
|
INVITE_DELETE |
enum |
|
MESSAGE_CREATE |
enum |
|
MESSAGE_DELETE |
enum |
|
MESSAGE_DELETE_BULK |
enum |
|
MESSAGE_REACTION_ADD |
enum |
|
MESSAGE_REACTION_REMOVE |
enum |
|
MESSAGE_REACTION_REMOVE_ALL |
enum |
|
MESSAGE_REACTION_REMOVE_EMOJI |
enum |
|
MESSAGE_UPDATE |
enum |
|
PRESENCE_UPDATE |
enum |
|
READY |
enum |
|
RESUME |
enum |
|
STAGE_INSTANCE_CREATE |
enum |
|
STAGE_INSTANCE_DELETE |
enum |
|
STAGE_INSTANCE_UPDATE |
enum |
|
THREAD_CREATE |
enum |
|
THREAD_DELETE |
enum |
|
THREAD_LIST_SYNC |
enum |
|
THREAD_MEMBER_UPDATE |
enum |
|
THREAD_MEMBERS_UPDATE |
enum |
|
THREAD_UPDATE |
enum |
|
TYPING_START |
enum |
|
VOICE_STATE_UPDATE |
enum |
|
WEBHOOKS_UPDATE |
enum |
|
INTERACTION_CREATE |
enum |
INTENTS (IntFlag)
Intents of the user.
events
on_any(self, object, raw_event)
async
Called for every event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_event |
dict |
Raw dict from discord API. |
required |
on_channel_create(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_channel_delete(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_channel_pins_update(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_channel_update(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_guild_ban_add(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_guild_ban_remove(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_guild_create(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_guild_delete(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_guild_emojis_update(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_guild_integrations_update(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_guild_member_add(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_guild_member_remove(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_guild_member_update(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_guild_role_create(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_guild_role_delete(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_guild_role_update(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_guild_stickers_update(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_guild_update(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_integration_create(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_integration_delete(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_integration_update(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_invite_create(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_invite_delete(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_message_create(self, message, raw_message)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
message |
Message |
Python object representing the event. |
required |
raw_message |
dict |
Raw dict from discord API. |
required |
on_message_delete(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_message_delete_bulk(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_message_reaction_add(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_message_reaction_remove(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_message_reaction_remove_all(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_message_reaction_remove_emoji(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_message_update(self, message, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
message |
MessageUpdate |
Updated message. Note that many fields may be missing from this entity! |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_presence_update(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_ready(self, ready, raw_ready)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
ready |
Ready |
Python object representing the event. |
required |
raw_ready |
dict |
Raw dict from discord API. |
required |
on_resumed(self, resume, raw_resume)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
resume |
None |
Always None. |
required |
raw_resume |
dict |
Raw dict from discord API. |
required |
on_stage_instance_create(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_stage_instance_delete(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_stage_instance_update(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_thread_create(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_thread_delete(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_thread_list_sync(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_thread_member_update(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_thread_members_update(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_thread_update(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_typing_start(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_voice_state_update(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_webhooks_update(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
on_interaction_create(self, object, raw_object)
async
Empty placeholder for given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DiscordClient |
Client |
required |
object |
BaseDiscordObject |
Python object representing the event. |
required |
raw_object |
dict |
Raw dict from discord API. |
required |
command
special
Provide a alias namespace for common Commanding actions.
helper
special
command_handler
CallbackData
dataclass
Callback dataclass.
CommandHandler
Manage commands for the user.
decorate_global_callback()
classmethod
WIP Decorator to register against a target interaction.
decorate_guild_callback()
classmethod
WIP Decorator to register against a target interaction.
register_global_callback(command_name, callback_function, command_id=None)
classmethod
Register name of a command to a given callback function globally.
register_guild_callback(command_name, callback_function, guild=None, command_id=None)
classmethod
Register name of a command to a given callback function for guilds.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command_name |
str |
Name of the command to be registered. MUST match the name registered with Discord! |
required |
callback_function |
Callable |
Callback function. Must be a function which accepts either (Interaction) or (Interaction, DiscordClient) as arguments. |
required |
guild |
Snowflake|Guild |
Target guild to trigger against. Leave empty if all guilds will use this same named command. |
None |
command_id |
Snowflake |
If known, register the command_id now. Saves an API call later. |
None |
register_interaction_custom_id(custom_id, callback_function, unlimited=False)
classmethod
Register a callback for an interaction.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
custom_id |
str |
The custom id to trigger on. |
required |
callback_function |
Callable |
Function to call when interaction is triggered. |
required |
unlimited |
bool |
Allows more than one interaction to be called. The user is expected to deregister this interaction later. If no cleanup occurs, the handler is cleaned after 15 minutes. |
False |
unregister_interaction_custom_id(custom_id, not_exists_ok=False)
classmethod
Attempt to remove a custom_id from the interaction cache. Warn if already removed.
command_handler(interaction, raw_data, client)
async
classmethod
Handle incoming commands and dispatch them to the correct type handler.
handle_application_command(interaction, raw_data, client)
async
classmethod
Handle interactions against Messages and Users.
handle_message_component(interaction, raw_data, client)
async
classmethod
Handle slash-commands.
interactions
CAPTCHA
Try to test humans from bots.
Confirmation (InteractionResponseHelper)
Ask a user for a YES/NO/CANCEL response.
generate_response(self, type=None, ephemeral=True)
inherited
Generate a response from the interaction.
Exceptions:
Type | Description |
---|---|
RuntimeError |
When cleanup or auto_respond are set to true. |
generate_followup(self)
inherited
Generate a followup to the interaction.
__init__(self, target, question, timeout=datetime.timedelta(seconds=900), cleanup=False, auto_respond=False)
special
Ask the user to confirm, deny, or cancel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target |
Interaction, InteractionResponseHelper |
Target of this interaction. |
required |
question |
str |
Actual text of the question to prompt the user with. |
required |
timeout |
timedelta |
Time before the response helper gives up. |
datetime.timedelta(seconds=900) |
cleanup |
bool |
Should we delete this when an answer is received? Mutually exclusive with |
False |
auto_respond |
bool |
Should we give feedback to the user when an answer is received? Mutually exclusive with |
False |
ask(self)
async
Ask a question.
Returns:
Type | Description |
---|---|
bool |
Result from user. Will be |
InteractionResponseHelper (ABC)
Assistive classes to help with responding to an interaction.
__init__(self, target, question, timeout=datetime.timedelta(seconds=900), cleanup=False, auto_respond=False)
special
Constructor for abstract Interaction Response Helpers.
generate_response(self, type=None, ephemeral=True)
Generate a response from the interaction.
Exceptions:
Type | Description |
---|---|
RuntimeError |
When cleanup or auto_respond are set to true. |
generate_followup(self)
Generate a followup to the interaction.
Question (InteractionResponseHelper)
Ask a user a question, respond with the answer.
generate_response(self, type=None, ephemeral=True)
inherited
Generate a response from the interaction.
Exceptions:
Type | Description |
---|---|
RuntimeError |
When cleanup or auto_respond are set to true. |
generate_followup(self)
inherited
Generate a followup to the interaction.
__init__(self, target, question, answers, timeout=datetime.timedelta(seconds=900), cleanup=False, auto_respond=False)
special
Prompt user with a question to be answered by one of a list of specific answers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target |
Interaction|InteractionResponseHelper |
Object to be responded to. Commonly an interaction, but you can chain InteractionResponseHelpers together. |
required |
question |
str |
Actual text of the question to prompt the user with. |
required |
answers |
str |
List of valid answers the user can give. |
required |
timeout |
timedelta |
Time before the response helper gives up. |
datetime.timedelta(seconds=900) |
cleanup |
bool |
Should we delete this when an answer is received? Mutually exclusive with |
False |
auto_respond |
bool |
Should we give feedback to the user when an answer is received? Mutually exclusive with |
False |
ask(self)
async
Ask a question.
Returns:
Type | Description |
---|---|
bool |
Result from user. Will be |
objects
special
activity
Activity (BaseDiscordObject)
Activity.
from_dict(self, data)
inherited
Parse an object from a dictionary and return it.
to_dict(self)
inherited
Convert object to dictionary suitable for API or other generic useage.
validate(self)
inherited
Check for valid object type.
Exceptions:
Type | Description |
---|---|
NotImplementedError |
Always. |
ActivityEmoji (BaseDiscordObject)
ActivityEmoji.
from_dict(self, data)
inherited
Parse an object from a dictionary and return it.
to_dict(self)
inherited
Convert object to dictionary suitable for API or other generic useage.
validate(self)
inherited
Check for valid object type.
Exceptions:
Type | Description |
---|---|
NotImplementedError |
Always. |
Assets (BaseDiscordObject)
Assets.
from_dict(self, data)
inherited
Parse an object from a dictionary and return it.
to_dict(self)
inherited
Convert object to dictionary suitable for API or other generic useage.
validate(self)
inherited
Check for valid object type.
Exceptions:
Type | Description |
---|---|
NotImplementedError |
Always. |
Buttons (BaseDiscordObject)
Buttons.
from_dict(self, data)
inherited
Parse an object from a dictionary and return it.
to_dict(self)
inherited
Convert object to dictionary suitable for API or other generic useage.
validate(self)
inherited
Check for valid object type.
Exceptions:
Type | Description |
---|---|
NotImplementedError |
Always. |
Party (BaseDiscordObject)
Party.
from_dict(self, data)
inherited
Parse an object from a dictionary and return it.
to_dict(self)
inherited
Convert object to dictionary suitable for API or other generic useage.
validate(self)
inherited
Check for valid object type.
Exceptions:
Type | Description |
---|---|
NotImplementedError |
Always. |
Secrets (BaseDiscordObject)
Secrets.
from_dict(self, data)
inherited
Parse an object from a dictionary and return it.
to_dict(self)
inherited
Convert object to dictionary suitable for API or other generic useage.
validate(self)
inherited
Check for valid object type.
Exceptions:
Type | Description |
---|---|
NotImplementedError |
Always. |
TimeStamps (BaseDiscordObject)
TimeStamps.
from_dict(self, data)
inherited
Parse an object from a dictionary and return it.
to_dict(self)
inherited
Convert object to dictionary suitable for API or other generic useage.
validate(self)
inherited
Check for valid object type.
Exceptions:
Type | Description |
---|---|
NotImplementedError |
Always. |
base_object
BaseDiscordObject (ABC)
Abstract base of all common discord objects. All subclasses map directly to an actual API object.
__init__(self, data=None)
special
Base generic init function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
dict |
Discord compliant dict for the given object. |
None |
from_dict(self, data)
Parse an object from a dictionary and return it.
to_dict(self)
Convert object to dictionary suitable for API or other generic useage.
validate(self)
Check for valid object type.
Exceptions:
Type | Description |
---|---|
NotImplementedError |
Always. |
channel
CategoryChannel (Channel)
Not a text channel, used for grouping servers in discord's GUI.
CHANNEL_TYPES (IntEnum)
inherited
Types of channels.
from_dict(self, data, parent_guild=None)
inherited
Parse a Channel from an API compliant dict.
Channel (ABC)
Abstract base class for Channels.
CHANNEL_TYPES (IntEnum)
Types of channels.
__str__(self)
special
Return string representation.
__repr__(self)
special
Return string representation.
from_dict(self, data, parent_guild=None)
Parse a Channel from an API compliant dict.
get_channel(channel_id)
async
classmethod
Invoke cache or API to get a channel of given channel_id.
ChannelImporter
Dynamic Channel identifier and parser.
from_dict(data, parent_guild=None)
classmethod
Parse a Channel from an API compliant dict, then return the appropriate subclass object.
DMChannel (Channel)
Direct Message with a specific user.
CHANNEL_TYPES (IntEnum)
inherited
Types of channels.
from_dict(self, data, parent_guild=None)
inherited
Parse a Channel from an API compliant dict.
GroupDMChannel (Channel)
DM with several users.
CHANNEL_TYPES (IntEnum)
inherited
Types of channels.
from_dict(self, data, parent_guild=None)
inherited
Parse a Channel from an API compliant dict.
GuildPrivateThread (Channel)
Private thread.
CHANNEL_TYPES (IntEnum)
inherited
Types of channels.
from_dict(self, data, parent_guild=None)
inherited
Parse a Channel from an API compliant dict.
GuildPublicThread (Channel)
Public thread.
CHANNEL_TYPES (IntEnum)
inherited
Types of channels.
from_dict(self, data, parent_guild=None)
inherited
Parse a Channel from an API compliant dict.
NewsChannel (Channel)
News channel.
CHANNEL_TYPES (IntEnum)
inherited
Types of channels.
from_dict(self, data, parent_guild=None)
inherited
Parse a Channel from an API compliant dict.
StoreChannel (Channel)
Channel to sell things in.
CHANNEL_TYPES (IntEnum)
inherited
Types of channels.
from_dict(self, data, parent_guild=None)
inherited
Parse a Channel from an API compliant dict.
TextChannel (Channel)
Text channel. May be public or private depending on privacy settings.
CHANNEL_TYPES (IntEnum)
inherited
Types of channels.
from_dict(self, data, parent_guild=None)
Parse a TextChannel from an API compliant dict.
send_message(self, message)
async
Send message to this channel. Will also accept a string.
VoiceChannel (Channel)
Voice channel.
CHANNEL_TYPES (IntEnum)
inherited
Types of channels.
from_dict(self, data, parent_guild=None)
inherited
Parse a Channel from an API compliant dict.
embed
Embed (BaseDiscordObject)
Rich context holder for a message.
EMBED_TYPES (Enum)
Types of Embeds.
from_dict(self, data)
inherited
Parse an object from a dictionary and return it.
__str__(self)
special
Return string representation.
to_dict(self)
Convert object to dictionary suitable for API or other generic useage.
generate(self, title=None, type=None, description=None, url=None, timestamp=None, color=None)
Generate various elements of an Embed.
validate(self)
Validate object is prepared for dispatch to discord.
add_footer(self, text, icon_url=None, proxy_icon_url=None)
Add footer to the Embed.
add_image(self, url, proxy_url=None, height=None, width=None)
Add image to the Embed.
add_thumbnail(self, url, proxy_url=None, height=None, width=None)
Add thumbnail to the Embed.
add_video(self, url, proxy_url=None, height=None, width=None)
Add video to the Embed.
add_provider(self, name=None, url=None)
Add provider to the Embed.
add_author(self, name, url=None, icon_url=None, proxy_icon_url=None)
Add author to the Embed.
add_field(self, name, value, inline=False)
Add a generic field to the Embed.
EmbedAdder (ABC)
Allow other objects to start adding components to themselves with a common set of helper functions.
Caution: This is an abstract class, and is not intended for direct instantiation.
add_embeds(self)
Add embeds to the object.
EmbedAuthor (BaseDiscordObject)
Author of the content from the Embed.
from_dict(self, data)
inherited
Parse an object from a dictionary and return it.
to_dict(self)
Convert object to dictionary suitable for API or other generic useage.
validate(self)
Validate object is prepared for dispatch to discord.
EmbedField (BaseDiscordObject)
Single field of an Embed.
from_dict(self, data)
inherited
Parse an object from a dictionary and return it.
to_dict(self)
Convert object to dictionary suitable for API or other generic useage.
validate(self)
Validate object is prepared for dispatch to discord.
EmbedFooter (BaseDiscordObject)
Footer details for the Embed.
from_dict(self, data)
inherited
Parse an object from a dictionary and return it.
to_dict(self)
Convert object to dictionary suitable for API or other generic useage.
validate(self)
Validate object is prepared for dispatch to discord.
EmbedImage (BaseDiscordObject)
Image to embed.
from_dict(self, data)
inherited
Parse an object from a dictionary and return it.
to_dict(self)
Convert object to dictionary suitable for API or other generic useage.
validate(self)
Validate object is prepared for dispatch to discord.
EmbedProvider (BaseDiscordObject)
Provider of the content from the Embed.
from_dict(self, data)
inherited
Parse an object from a dictionary and return it.
to_dict(self)
Convert object to dictionary suitable for API or other generic useage.
validate(self)
Validate object is prepared for dispatch to discord.
EmbedThumbnail (BaseDiscordObject)
Thumbnail to embed.
from_dict(self, data)
inherited
Parse an object from a dictionary and return it.
to_dict(self)
Convert object to dictionary suitable for API or other generic useage.
validate(self)
Validate object is prepared for dispatch to discord.
EmbedVideo (BaseDiscordObject)
Video to embed.
from_dict(self, data)
inherited
Parse an object from a dictionary and return it.
to_dict(self)
Convert object to dictionary suitable for API or other generic useage.
validate(self)
Validate object is prepared for dispatch to discord.
emoji
Emoji (BaseDiscordObject)
Emojis.
__init__(self, name=None, unicode=None)
special
Initalize Emoji.
TODO: Document parameters.
__str__(self)
special
Return string representation.
from_dict(self, data)
inherited
Parse an object from a dictionary and return it.
to_dict(self)
inherited
Convert object to dictionary suitable for API or other generic useage.
validate(self)
inherited
Check for valid object type.
Exceptions:
Type | Description |
---|---|
NotImplementedError |
Always. |
enumerations
ACTIVITY_FLAGS (IntFlag)
Flags for activities.
ACTIVITY_TYPE (IntEnum)
Enumeration of Activity types.
CHANNEL_TYPES (IntEnum)
Types of channels.
EMBED_TYPES (Enum)
Types of Embeds.
MESSAGE_TYPE (IntEnum)
Types of messages.
events
special
Collection of events which are less likely to be directly implemented by the end user.
guild_member_update
GuildMemberUpdate (BaseDiscordObject)
GuildMemberUpdate.
Attributes:
Name | Type | Description |
---|---|---|
roles |
[Snowflake] |
DEPRECATED: This will be replaced with a |
guild_id |
Snowflake |
The ID of the guild. |
user |
User |
A partial user object. |
nick |
str |
Nickname of the |
avatar |
str |
Members guild avatar hash. |
joined_at |
datetime |
When the user joined the guild. |
premium_since |
datetime |
When the user started boosting the guild. |
deaf |
bool |
Whether the user is deafened in voice channels. |
mute |
bool |
Whether the user is muted in voice channels. |
pending |
bool |
Whether the user has not yet passed the guild's Membership Screening requirements. |
from_dict(self, data)
inherited
Parse an object from a dictionary and return it.
to_dict(self)
inherited
Convert object to dictionary suitable for API or other generic useage.
validate(self)
inherited
Check for valid object type.
Exceptions:
Type | Description |
---|---|
NotImplementedError |
Always. |
typing_start
TypingStart (BaseDiscordObject)
Event given when a user starts to type.
Attributes:
Name | Type | Description |
---|---|---|
channel_id |
Snowflake |
ID of the typing event. |
guild_id |
Snowflake |
Guild ID of the typing event. |
user_id |
Snowflake |
user_id of the user which started to type. |
timestamp |
datetime |
Datetime the user started typing. |
member |
Member |
Member that started typing. |
from_dict(self, data)
Parse a TypingStart from an API compliant dict.
to_dict(self)
inherited
Convert object to dictionary suitable for API or other generic useage.
validate(self)
inherited
Check for valid object type.
Exceptions:
Type | Description |
---|---|
NotImplementedError |
Always. |
voice_state
VoiceState (BaseDiscordObject)
VoiceState.
from_dict(self, data)
inherited
Parse an object from a dictionary and return it.
to_dict(self)
inherited
Convert object to dictionary suitable for API or other generic useage.
validate(self)
inherited
Check for valid object type.
Exceptions:
Type | Description |
---|---|
NotImplementedError |
Always. |
guild
Guild (BaseDiscordObject)
Commonly know as a server.
FeatureFlags (Flag)
Features of guild.
TODO: Move this to enumerations.
NSFWLevels (IntEnum)
NSFW level allowed in guild.
TODO: Move this to enumerations.
PremiumTiers (IntEnum)
Premium tier currently unlocked by guild.
TODO: Move this to enumerations.
VerificationLevels (IntEnum)
Level of verification required by the guild.
TODO: Move this to enumerations.
to_dict(self)
inherited
Convert object to dictionary suitable for API or other generic useage.
validate(self)
inherited
Check for valid object type.
Exceptions:
Type | Description |
---|---|
NotImplementedError |
Always. |
__str__(self)
special
Return string representation.
__repr__(self)
special
Return string representation.
from_dict(self, data)
Parse a Guild from an API compliant dict.
interactions
special
Interactions with the discord API.
For more information, see Discord API.
command
Commands that can be registered with the API.
ChoiceAdderBase (ABC)
Allow other objects to start adding components to themselves with a common set of helper functions.
Caution: This is an abstract class, and is not intended for direct instantiation.
add_choice(self, name, value)
Add a choice to the object.
add_choices(self)
Add a choice to the object.
Command (BaseDiscordObject)
Command root used to generate new commands.
Attributes:
Name | Type | Description |
---|---|---|
id |
Snowflake |
Unique ID of the command. |
type |
Optional[COMMAND_TYPE] |
Type of the command. |
application_id |
Optional[dyscord.objects.snowflake.Snowflake] |
(Snowflake): Unique id of the parent application. |
guild_id |
Snowflake |
Guild ID of the command. |
name |
str |
(str): Name of the command. |
COMMAND_TYPE |
COMMAND_TYPE |
Helper pointer to the COMMAND_TYPE enumeration. |
COMMAND_OPTION |
COMMAND_OPTION |
Helper pointer to the COMMAND_OPTION enumeration. |
COMMAND_OPTION (IntEnum)
Valid types or groupings of command options.
COMMAND_TYPE (IntEnum)
Type of command.
Attributes:
Name | Type | Description |
---|---|---|
CHAT_INPUT |
int |
Slash commands; a text-based command that shows up when a user types. |
USER |
int |
A UI-based command that shows up when you right click or tap on a user. |
MESSAGE |
int |
A UI-based command that shows up when you right click or tap on a message. |
__str__(self)
special
Return string representation.
generate(self, name, description, type, options=None, default_permission=True)
Helper function to generate a new command bound for registration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str |
Name of the command, will be referenced when registering the command with discord as well as locally. |
required |
description |
str |
Human readable description. For USER and MESSAGE types, this must be a zero length string. |
required |
type |
COMMAND_TYPE |
Either CHAT_INPUT for a slash command, or USER/MESSAGE for direct object interaction. |
required |
options |
[CommandOptionsBase] |
DEPRECATED[Removed by 0.6.0] List of valid Command Options. Will be copied. |
None |
default_permission |
bool |
Whether the command is enabled by default when the app is added to a guild. |
True |
add_option_sub_command(self, name, description)
Add SubCommand to the command.
add_option_sub_command_group(self, name, description)
Add SubCommandGroup to the command.
add_option_typed(self, type, name, description, required=True, choices=None, autocomplete=None, channel_types=None)
Add option to the command.
clear_options(self)
Remove all options.
register_to_guild(self, guild)
async
Register a Command to a specific guild discord scope.
Note that discord will limit you to 200 of these calls per bot per guild per day.
register_globally(self)
async
Register a Command to the global discord scope.
Note that discord will limit you to 200 of these calls per bot per day.
from_dict(self, data)
Parse a Command from an API compliant dict.
to_dict(self)
Convert object to dictionary suitable for API or other generic useage.
validate(self)
Validate object is prepared for dispatch to discord.
total_characters(self)
Get the total characters in the name, description, and value.
CommandOptionChoiceStructure (BaseDiscordObject)
Specific option for a command.
__init__(self)
special
Initalize a CommandOptionChoiceStructure.
from_dict(self, data)
Parse a CommandOptionChoiceStructure from an API compliant dict.
to_dict(self)
Convert object to dictionary suitable for API or other generic useage.
validate(self)
Validate object is prepared for dispatch to discord.
total_characters(self)
Get the total characters in the name, description, and value.
CommandOptionSubCommand (CommandOptionsBase)
Commands which live under a Command, or a Sub Command Group.
COMMAND_OPTION (IntEnum)
Valid types or groupings of command options.
add_option_typed(self, type, name, description, required=True, choices=None, autocomplete=None, channel_types=None)
Add option to the command.
from_dict(self, data)
inherited
Parse a CommandOptionsBase from an API compliant dict.
to_dict(self)
inherited
Convert object to dictionary suitable for API or other generic useage.
validate(self)
inherited
Validate object is prepared for dispatch to discord.
total_characters(self)
inherited
Get the total characters in the name, description, and value.
CommandOptionSubCommandGroup (CommandOptionsBase)
Intermediate object to group SubCommands together.
COMMAND_OPTION (IntEnum)
inherited
Valid types or groupings of command options.
add_option_sub_command(self, name, description)
Add SubCommand to the command.
from_dict(self, data)
inherited
Parse a CommandOptionsBase from an API compliant dict.
to_dict(self)
inherited
Convert object to dictionary suitable for API or other generic useage.
validate(self)
inherited
Validate object is prepared for dispatch to discord.
total_characters(self)
inherited
Get the total characters in the name, description, and value.
CommandOptions (CommandOptionsBase, ChoiceAdderBase)
Options for a Command.
COMMAND_OPTION (IntEnum)
inherited
Valid types or groupings of command options.
add_choices(self)
inherited
Add a choice to the object.
from_dict(self, data)
inherited
Parse a CommandOptionsBase from an API compliant dict.
to_dict(self)
inherited
Convert object to dictionary suitable for API or other generic useage.
total_characters(self)
inherited
Get the total characters in the name, description, and value.
add_choice(self, name, value)
Append a choice to the given set of options and return it. Will start a list if needed.
validate(self)
Validate object is prepared for dispatch to discord.
CommandOptionsBase (BaseDiscordObject, ABC)
Abstract base for options.
Attributes:
Name | Type | Description |
---|---|---|
type |
COMMAND_OPTION |
Type of the option. |
name |
str |
Name of the option. |
description |
str |
Human description of the option. |
required |
bool |
If the option is required. |
autocomplete |
bool |
If auto complete is requested for this option, default is no. |
choices |
[CommandOptionChoiceStructure] |
Array of choices for this option. |
options |
[CommandOptions] |
Array of options if this is a Subcommand or SubCommandGroup. |
channel_types |
Optional[List[dyscord.objects.enumerations.CHANNEL_TYPES]] |
([CHANNEL_TYPES]): Array of channels types to filter against if type supports channel mentions. |
COMMAND_OPTION (IntEnum)
Valid types or groupings of command options.
from_dict(self, data)
Parse a CommandOptionsBase from an API compliant dict.
to_dict(self)
Convert object to dictionary suitable for API or other generic useage.
validate(self)
Validate object is prepared for dispatch to discord.
total_characters(self)
Get the total characters in the name, description, and value.
components
Components that can be attached to messages.
ActionRow (Component)
Intermediate Component that holds Button or SelectMenu objects.
BUTTON_STYLES (IntEnum)
Styles of Button objects.
from_dict(self, data)
inherited
Parse an object from a dictionary and return it.
add_button(self, style, custom_id=None, label=None, emoji=None, url=None, disabled=None, callback=None, unlimited_callbacks=False)
Append a Button item to the ActionRow, and return it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
style |
BUTTON_STYLES |
Style of button to be used. |
required |
custom_id |
str |
Unique string to be returned by the API when item is selected. Default is UUID4. |
None |
label |
str |
Actual text user will see. |
None |
emoji |
Emoji |
Emoji rather than label to display. |
None |
url |
Optional[str] |
(str): URL for BUTTON_STYLES.LINK buttons. |
None |
disabled |
bool |
Item will display, but is not interactable. |
None |
callback |
Callable |
Callback function when user selects an item. Should be |
None |
unlimited_callbacks |
bool |
Request callbacks even if custom_id has already been called. |
False |
Returns:
Type | Description |
---|---|
Button |
Button |
add_select_menu(self, custom_id=None, placeholder=None, min_values=None, max_values=None, disabled=None, callback=None, unlimited_callbacks=False)
Append a SelectMenu item to the ActionRow, and return it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
custom_id |
str |
Unique string to be returned by the API when item is selected. Default is UUID4. |
None |
placeholder |
str |
Text to appear in the box before user selection begins. |
None |
min_values |
int |
Min number of items user must select. Default is 1. |
None |
max_values |
int |
Max number of items user can select. Default is 1. |
None |
disabled |
bool |
Item will display, but is not interactable. |
None |
callback |
Callable |
Callback function when user selects an item. Should be |
None |
unlimited_callbacks |
bool |
Request callbacks even if custom_id has already been called. |
False |
Returns:
Type | Description |
---|---|
SelectMenu |
SelectMenu |
to_dict(self)
Convert object to dictionary suitable for API or other generic useage.
validate(self)
Validate object is prepared for dispatch to discord.
Button (Component)
Selectable button or link for user interaction.
BUTTON_STYLES (IntEnum)
Styles of Button objects.
from_dict(self, data)
inherited
Parse an object from a dictionary and return it.
to_dict(self)
Convert object to dictionary suitable for API or other generic useage.
validate(self)
Validate object is prepared for dispatch to discord.
Component (BaseDiscordObject, ABC)
Base class for Components.
from_dict(self, data)
inherited
Parse an object from a dictionary and return it.
to_dict(self)
inherited
Convert object to dictionary suitable for API or other generic useage.
validate(self)
inherited
Check for valid object type.
Exceptions:
Type | Description |
---|---|
NotImplementedError |
Always. |
ComponentAdder (ABC)
Allow other objects to start adding components to themselves with a common set of helper functions.
Caution: This is an abstract class, and is not intended for direct instantiation.
add_components(self)
Start adding components by starting an ACTION_ROW.
SelectMenu (Component)
A drop down menu for user interaction.
COMMAND_OPTION (IntEnum)
Valid types or groupings of command options.
from_dict(self, data)
inherited
Parse an object from a dictionary and return it.
add_option_typed(self, type, name, description, required=True, choices=None, autocomplete=None, channel_types=None)
Add option to the command.
to_dict(self)
Convert object to dictionary suitable for API or other generic useage.
validate(self)
Validate object is prepared for dispatch to discord.
enumerations
BUTTON_STYLES (IntEnum)
Styles of Button objects.
COMMAND_OPTION (IntEnum)
Valid types or groupings of command options.
COMMAND_TYPE (IntEnum)
Type of command.
Attributes:
Name | Type | Description |
---|---|---|
CHAT_INPUT |
int |
Slash commands; a text-based command that shows up when a user types. |
USER |
int |
A UI-based command that shows up when you right click or tap on a user. |
MESSAGE |
int |
A UI-based command that shows up when you right click or tap on a message. |
COMPONENT_TYPES (IntEnum)
Types of Components.
INTERACTION_CALLBACK_FLAGS (IntFlag)
Flags for callback methods.
INTERACTION_RESPONSE_TYPES (IntEnum)
Types of interaction responses.
Attributes:
Name | Type | Description |
---|---|---|
PONG |
ACK a Ping. |
|
CHANNEL_MESSAGE_WITH_SOURCE |
Respond to an interaction with a message. |
|
DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE |
ACK an interaction and edit a response later, the user sees a loading state. |
|
DEFERRED_UPDATE_MESSAGE |
Only for components (Not slash commands), ACK an interaction and edit the original message later; the user does not see a loading state. |
|
UPDATE_MESSAGE |
Only for components (Not slash commands), edit the message the component was attached to. |
|
APPLICATION_COMMAND_AUTOCOMPLETE_RESULT |
Respond to an autocomplete interaction with suggested choices. |
INTERACTION_TYPES (IntEnum)
Types of interactions.
Attributes:
Name | Type | Description |
---|---|---|
PING |
Used by server to get online status of webhook based applications. Handled by Dyscord in background. |
|
APPLICATION_COMMAND |
Command was a |
|
MESSAGE_COMPONENT |
Command was an interaction directly with a |
|
APPLICATION_COMMAND_AUTOCOMPLETE |
User it attempting to complete an interaction as is asking for suggestions. |
interaction
Interaction (BaseDiscordObject)
Response given from the server after an user activated an interaction of some type.
Attributes:
Name | Type | Description |
---|---|---|
id |
Snowflake |
ID of the specific interaction. |
application_id |
Snowflake |
ID of the application that registered the Interaction. |
type |
INTERACTION_TYPES |
The type of interaction. |
data |
InteractionData |
Data generated by the interaction. |
guild_id |
Snowflake|None |
ID of the guild the command was generated from. This still exists for commands registered to the Global space! |
channel_id |
Snowflake|None |
ID of the channel the command was generated from. |
member |
Member|None |
Member that activated the command. |
user |
User|None |
User that activated the command. |
token |
str |
Unique one time use token used in an InteractionResponse. |
version |
int |
Unique version number generated by discord when the command is registered. |
message |
Message|None |
For components, the message they were attached to |
can_respond
property
readonly
Determine if you can respond to this interaction.
can_followup
property
readonly
Determine if you can followup to this interaction.
INTERACTION_RESPONSE_TYPES (IntEnum)
Types of interaction responses.
Attributes:
Name | Type | Description |
---|---|---|
PONG |
ACK a Ping. |
|
CHANNEL_MESSAGE_WITH_SOURCE |
Respond to an interaction with a message. |
|
DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE |
ACK an interaction and edit a response later, the user sees a loading state. |
|
DEFERRED_UPDATE_MESSAGE |
Only for components (Not slash commands), ACK an interaction and edit the original message later; the user does not see a loading state. |
|
UPDATE_MESSAGE |
Only for components (Not slash commands), edit the message the component was attached to. |
|
APPLICATION_COMMAND_AUTOCOMPLETE_RESULT |
Respond to an autocomplete interaction with suggested choices. |
INTERACTION_TYPES (IntEnum)
Types of interactions.
Attributes:
Name | Type | Description |
---|---|---|
PING |
Used by server to get online status of webhook based applications. Handled by Dyscord in background. |
|
APPLICATION_COMMAND |
Command was a |
|
MESSAGE_COMPONENT |
Command was an interaction directly with a |
|
APPLICATION_COMMAND_AUTOCOMPLETE |
User it attempting to complete an interaction as is asking for suggestions. |
to_dict(self)
inherited
Convert object to dictionary suitable for API or other generic useage.
__init__(self)
special
Simple initialization.
validate(self)
inherited
Check for valid object type.
Exceptions:
Type | Description |
---|---|
NotImplementedError |
Always. |
from_dict(self, data)
Import data from dict and populate object with it.
generate_response(self, type=<INTERACTION_RESPONSE_TYPES.CHANNEL_MESSAGE_WITH_SOURCE: 4>, ephemeral=False)
Produce a InteractionResponse object to follow up against the Interaction.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
type |
INTERACTION_RESPONSE_TYPES |
Type of response to give. |
<INTERACTION_RESPONSE_TYPES.CHANNEL_MESSAGE_WITH_SOURCE: 4> |
ephemeral |
bool |
Only user should see the response. |
False |
generate_followup(self, content=None, tts=None)
Produce a InteractionFollowup object to follow up against the Interaction.
InteractionCallback (BaseDiscordObject, ComponentAdder, EmbedAdder, ChoiceAdderBase)
InteractionCallback.
INTERACTION_CALLBACK_FLAGS (IntFlag)
Flags for callback methods.
add_components(self)
inherited
Start adding components by starting an ACTION_ROW.
from_dict(self, data)
inherited
Parse an object from a dictionary and return it.
add_choice(self, name, value)
inherited
Add a choice to the object.
add_choices(self)
inherited
Add a choice to the object.
to_dict(self)
Convert object to dictionary suitable for API or other generic useage.
generate(self, tts=None, content=None, ephemeral=None)
Customize common attributes of a callback.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tts |
bool |
Send message as text to speech. |
None |
content |
str |
Text contents of the message to send. |
None |
ephemeral |
bool |
Only show message to the target user. Not meaningful if message is a followup. |
None |
validate(self)
Validated object.
add_embeds(self)
inherited
Add embeds to the object.
InteractionData (BaseDiscordObject)
Handle data from an Interaction.
to_dict(self)
inherited
Convert object to dictionary suitable for API or other generic useage.
validate(self)
inherited
Check for valid object type.
Exceptions:
Type | Description |
---|---|
NotImplementedError |
Always. |
from_dict(self, data, guild_id=None)
Import data from dict and populate object with it.
InteractionDataOptionStructure (BaseDiscordObject)
InteractionDataOptionStructure.
to_dict(self)
inherited
Convert object to dictionary suitable for API or other generic useage.
validate(self)
inherited
Check for valid object type.
Exceptions:
Type | Description |
---|---|
NotImplementedError |
Always. |
__getitem__(self, key)
special
Return item from the options dict.
get(self, key, default=None)
Return item from the options dict, or None if it doesn't exist.
__contains__(self, item)
special
Determine if item is in the options dict.
from_dict(self, data, guild_id=None, resolved=None)
Import data from dict and populate object with it.
InteractionFollowup (BaseDiscordObject)
Manage a followup message to an interaction.
from_dict(self, data)
inherited
Parse an object from a dictionary and return it.
__init__(self)
special
Initialize InteractionFollowup.
to_dict(self)
Convert object to dictionary suitable for API or other generic useage.
send(self)
async
Send followup.
edit_original_response(self)
async
Edit the initial response to the original interaction.
delete_initial_response(self)
async
Delete the initial response to the original interaction.
edit_followup_message(self, message=None)
async
Apply modifications to the given message object.
delete_followup_message(self, message=None)
async
Delete the given followup message.
If a message was just send using the send() method of this object, and no message argument is given, then attempt to delete the last followup message.
generate(self, content=None, tts=None)
Customize common attributes of a callback.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tts |
bool |
Send message as text to speech. |
None |
content |
str |
Text contents of the message to send. |
None |
!!! note
You may be tempted to grab the resulting InteractionCallback
and adjust the ephemeral
flag. Followup messages do not support this!
add_components(self)
Add components objects to the data attribute.
add_embeds(self)
Add embed objects to the data attribute.
validate(self)
Validated object.
InteractionResponse (BaseDiscordObject)
Manage a response message to an interaction.
INTERACTION_RESPONSE_TYPES (IntEnum)
Types of interaction responses.
Attributes:
Name | Type | Description |
---|---|---|
PONG |
ACK a Ping. |
|
CHANNEL_MESSAGE_WITH_SOURCE |
Respond to an interaction with a message. |
|
DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE |
ACK an interaction and edit a response later, the user sees a loading state. |
|
DEFERRED_UPDATE_MESSAGE |
Only for components (Not slash commands), ACK an interaction and edit the original message later; the user does not see a loading state. |
|
UPDATE_MESSAGE |
Only for components (Not slash commands), edit the message the component was attached to. |
|
APPLICATION_COMMAND_AUTOCOMPLETE_RESULT |
Respond to an autocomplete interaction with suggested choices. |
from_dict(self, data)
inherited
Parse an object from a dictionary and return it.
__init__(self)
special
Initialize InteractionResponse.
to_dict(self)
Convert object to dictionary suitable for API or other generic useage.
send(self)
async
Send response.
generate(self, content=None, tts=None, ephemeral=None)
Passthrough to data generate function.
add_components(self)
Add component objects to the data attribute.
add_embeds(self)
Add embed objects to the data attribute.
add_choices(self)
Add choice.
add_choice(self, name, value)
Add choice.
validate(self)
Validated object.
message
Message (BaseDiscordObject, ComponentAdder, EmbedAdder)
Message containing infomation about it's content, origin, authors, etc.
Attributes:
Name | Type | Description |
---|---|---|
id |
Snowflake |
Unique ID of the message. |
channel_id |
Snowflake |
Unique ID of the channel the message came from. |
guild_id |
Snowflake|None |
Unique ID of the channel the message came from. Defaults to None. |
guild |
Guild|None |
Actual guild object item is from. This will autopopulate from the API if it is not present. |
author |
User |
The author of the message. |
member |
Member |
If the message was in a guild, this will be the Member object of the author. |
content |
str |
The actual content of the message. |
timestamp |
datetime |
Date and time the message was posted. |
edited_timestamp |
datetime|None |
If the message has been edited, this is the date and time it was. |
tts |
bool |
Text to speech flag. |
mention_everyone |
bool |
Message had an @everyone in it. |
mentions |
[User] |
List of mentioned User. |
mention_roles |
[Role] |
List of mentioned Role. |
mention_channels |
[Channel] |
List of mentioned Channel. Note that each channel will be the correct type. |
embeds |
[Embed] |
List of rich Embed objects. |
nonce |
str|None |
Nonce used to send the message. |
pinned |
bool |
True if message is pinned in the channel. |
webhook_id |
Snowflake|None |
ID of the webhook used to send this message. |
type |
MESSAGE_TYPE |
Enumeration of the type of message. |
application_id |
Snowflake|None |
ID of the application that send the message. |
message_reference |
MessageReference|None |
data showing the source of a crosspost, channel follow add, pin, or reply message |
flags |
int |
Bitfield of message flags. |
referenced_message |
Message|None |
Message object refereed to in message_reference. |
thread |
Channel |
Thread the message is a part of. |
components |
[Component] |
List of components in the message if it is an interaction. |
channel
property
readonly
Attempt to grab channel from the API.
guild
property
readonly
Attempt to grab guild from the API.
MESSAGE_TYPE (IntEnum)
Types of messages.
formatter
Helper formatting functions.
These mostly implement the functions found in the Discord API docs.
Examples:
When generating a string for a message, the formatter class provides a quick shortcut to get and use the various formatters.
message = Message()
f'The time is {message.formatter.timestamp()}!'
TIMESTAMP_FLAGS (Enum)
Types of timestamp displays.
Attributes:
Name | Type | Description |
---|---|---|
SHORT_TIME |
enum |
16:20 |
LONG_TIME |
enum |
16:20:30 |
SHORT_DATE |
enum |
20/04/2021 |
SHORT_DATE_TIME |
enum |
20 April 2021 16:20 |
LONG_DATE |
enum |
20 April 2021 |
LONG_DATE_TIME |
enum |
Tuesday, 20 April 2021 16:20 |
RELATIVE_TIME |
enum |
2 months ago |
DEFAULT |
enum |
20 April 2021 16:20 |
timestamp(timestamp=None, flag=<TIMESTAMP_FLAGS.SHORT_DATE_TIME: 'f'>)
classmethod
Return valid timestamp string. Discord will display this in a useful way.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
timestamp |
datetime |
The timestamp to parse, can be omitted to use |
None |
flag |
TIMESTAMP_FLAGS|str |
Flag to use when parsing the timestamp on the client. |
<TIMESTAMP_FLAGS.SHORT_DATE_TIME: 'f'> |
Returns:
Type | Description |
---|---|
str |
Valid string to use as part of a discord message to reference to a point in time. |
user(user)
classmethod
Return valid mention string for the user's name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user |
Snowflake|User|Member |
User or User's ID to mention. |
required |
Returns:
Type | Description |
---|---|
str |
Valid string to use as part of a discord message to reference a User by name. |
user_nickname(user)
classmethod
Return valid mention string for the user's nickname.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user |
Snowflake|User|Member |
User or User's ID to mention. |
required |
Returns:
Type | Description |
---|---|
str |
Valid string to use as part of a discord message to reference a User by nickname. |
channel(channel)
classmethod
Return valid mention string for the channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
channel |
Snowflake|Channel |
Channel or channel ID to mention. Any subclass of Channel is accepted. |
required |
Returns:
Type | Description |
---|---|
str |
Valid string to use as part of a discord message to reference a Channel. |
role(role)
classmethod
Return valid mention string for the role.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
role |
Snowflake|Role |
Role or role's ID to mention. |
required |
Returns:
Type | Description |
---|---|
str |
Valid string to use as part of a discord message to reference a Role. |
add_components(self)
inherited
Start adding components by starting an ACTION_ROW.
to_dict(self)
inherited
Convert object to dictionary suitable for API or other generic useage.
__init__(self, content=None)
special
Init.
from_dict(self, data)
Parse a Message from an API compliant dict.
to_sendable_dict(self)
Sending a message only allows a subset of attributes. Ignore anything else about this message when producing that dict.
validate(self)
Validate object is prepared for dispatch to discord.
add_embeds(self)
inherited
Add embeds to the object.
MessageReference (BaseDiscordObject)
Slim data holding class.
Attributes:
Name | Type | Description |
---|---|---|
message_id |
Snowflake|None |
ID of the originating message. |
channel_id |
Optional[dyscord.objects.snowflake.Snowflake] |
(Snowflake|None): ID of the originating message's channel. |
guild_id |
Optional[dyscord.objects.snowflake.Snowflake] |
(Snowflake|None): ID of the originating message's guild. |
fail_if_not_exists |
bool|None |
When sending, whether to error if the referenced message doesn't exist instead of sending as a normal (non-reply) message, default true |
to_dict(self)
inherited
Convert object to dictionary suitable for API or other generic useage.
validate(self)
inherited
Check for valid object type.
Exceptions:
Type | Description |
---|---|
NotImplementedError |
Always. |
from_dict(self, data)
Parse a MessageReference from an API compliant dict.
MessageUpdate (Message)
Duplicate of the Message class, but most fields are now annotated as optional.
channel
inherited
property
readonly
Attempt to grab channel from the API.
guild
inherited
property
readonly
Attempt to grab guild from the API.
MESSAGE_TYPE (IntEnum)
inherited
Types of messages.
formatter
inherited
Helper formatting functions.
These mostly implement the functions found in the Discord API docs.
Examples:
When generating a string for a message, the formatter class provides a quick shortcut to get and use the various formatters.
message = Message()
f'The time is {message.formatter.timestamp()}!'
TIMESTAMP_FLAGS (Enum)
Types of timestamp displays.
Attributes:
Name | Type | Description |
---|---|---|
SHORT_TIME |
enum |
16:20 |
LONG_TIME |
enum |
16:20:30 |
SHORT_DATE |
enum |
20/04/2021 |
SHORT_DATE_TIME |
enum |
20 April 2021 16:20 |
LONG_DATE |
enum |
20 April 2021 |
LONG_DATE_TIME |
enum |
Tuesday, 20 April 2021 16:20 |
RELATIVE_TIME |
enum |
2 months ago |
DEFAULT |
enum |
20 April 2021 16:20 |
timestamp(timestamp=None, flag=<TIMESTAMP_FLAGS.SHORT_DATE_TIME: 'f'>)
classmethod
Return valid timestamp string. Discord will display this in a useful way.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
timestamp |
datetime |
The timestamp to parse, can be omitted to use |
None |
flag |
TIMESTAMP_FLAGS|str |
Flag to use when parsing the timestamp on the client. |
<TIMESTAMP_FLAGS.SHORT_DATE_TIME: 'f'> |
Returns:
Type | Description |
---|---|
str |
Valid string to use as part of a discord message to reference to a point in time. |
user(user)
classmethod
Return valid mention string for the user's name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user |
Snowflake|User|Member |
User or User's ID to mention. |
required |
Returns:
Type | Description |
---|---|
str |
Valid string to use as part of a discord message to reference a User by name. |
user_nickname(user)
classmethod
Return valid mention string for the user's nickname.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user |
Snowflake|User|Member |
User or User's ID to mention. |
required |
Returns:
Type | Description |
---|---|
str |
Valid string to use as part of a discord message to reference a User by nickname. |
channel(channel)
classmethod
Return valid mention string for the channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
channel |
Snowflake|Channel |
Channel or channel ID to mention. Any subclass of Channel is accepted. |
required |
Returns:
Type | Description |
---|---|
str |
Valid string to use as part of a discord message to reference a Channel. |
role(role)
classmethod
Return valid mention string for the role.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
role |
Snowflake|Role |
Role or role's ID to mention. |
required |
Returns:
Type | Description |
---|---|
str |
Valid string to use as part of a discord message to reference a Role. |
add_components(self)
inherited
Start adding components by starting an ACTION_ROW.
to_dict(self)
inherited
Convert object to dictionary suitable for API or other generic useage.
from_dict(self, data)
inherited
Parse a Message from an API compliant dict.
to_sendable_dict(self)
inherited
Sending a message only allows a subset of attributes. Ignore anything else about this message when producing that dict.
validate(self)
inherited
Validate object is prepared for dispatch to discord.
add_embeds(self)
inherited
Add embeds to the object.
permissions
Permissions
Permissions for users and roles.
PermissionFlags (IntFlag)
Various flags that can be set.
__init__(self, data=None)
special
Init.
set(self, flag)
Set a specific flag.
clear(self, flag)
Clear a specific flag.
parse_str(self, data)
Parse a string as a permission.
__and__(self, other)
special
Logically AND two Permissions together.
__rand__(self, other)
special
See and().
__eq__(self, other)
special
Determine if two permission objects are equivalent.
presence
ClientStatus (BaseDiscordObject)
ClientStatus.
from_dict(self, data)
inherited
Parse an object from a dictionary and return it.
to_dict(self)
inherited
Convert object to dictionary suitable for API or other generic useage.
validate(self)
inherited
Check for valid object type.
Exceptions:
Type | Description |
---|---|
NotImplementedError |
Always. |
Presence (BaseDiscordObject)
Presence.
from_dict(self, data)
inherited
Parse an object from a dictionary and return it.
to_dict(self)
inherited
Convert object to dictionary suitable for API or other generic useage.
validate(self)
inherited
Check for valid object type.
Exceptions:
Type | Description |
---|---|
NotImplementedError |
Always. |
ready
Ready (BaseDiscordObject)
Event sent from servers when Discord is ready and connected.
__init__(self)
special
We don't have an ID for these objects, so do not call the super.
__hash__(self)
special
Hash.
to_dict(self)
inherited
Convert object to dictionary suitable for API or other generic useage.
__eq__(self, other)
special
Determine if other object came form the same application.
from_dict(self, data)
Parse a Ready from an API compliant dict.
validate(self)
inherited
Check for valid object type.
Exceptions:
Type | Description |
---|---|
NotImplementedError |
Always. |
role
Role (BaseDiscordObject)
Roles represent a set of permissions attached to a group of users.
from_dict(self, data)
Parse a Role from an API compliant dict.
to_dict(self)
inherited
Convert object to dictionary suitable for API or other generic useage.
validate(self)
inherited
Check for valid object type.
Exceptions:
Type | Description |
---|---|
NotImplementedError |
Always. |
RoleTags (BaseDiscordObject)
RoleTags.
to_dict(self)
inherited
Convert object to dictionary suitable for API or other generic useage.
from_dict(self, data)
Parse a RoleRags from an API compliant dict.
validate(self)
inherited
Check for valid object type.
Exceptions:
Type | Description |
---|---|
NotImplementedError |
Always. |
snowflake
Snowflake
Discord specific UUID like object. Generally interchangable with a string contained the same sequence of characters.
timestamp
property
readonly
The timestamp of the Snowflake.
worker_id
property
readonly
The worker ID that generated the Snowflake.
process_id
property
readonly
The process ID of the Snowflake.
increment
property
readonly
The increment sequence count of the Snowflake.
__init__(self, identifier=None)
special
Initialize the Snowflake.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier |
int, str, Snowflake |
Identifier to base off of. |
None |
__str__(self)
special
Return string representation.
__repr__(self)
special
Return string representation.
__eq__(self, other)
special
Determine if other is equivalent to this Snowflake..
__hash__(self)
special
Hash.
generate(self)
Generate a fake Snowflake locally.
user
Member (User)
User within a guild.
mention
inherited
property
readonly
Generate a valid name mention for use in Discord.
mention_nickname
inherited
property
readonly
Generate a valid nickname mention for use in Discord.
PremiumType (IntFlag)
inherited
Type of Premium subscription the User has.
UserFlag (IntFlag)
inherited
Flags on a User.
to_dict(self)
inherited
Convert object to dictionary suitable for API or other generic useage.
validate(self)
inherited
Check for valid object type.
Exceptions:
Type | Description |
---|---|
NotImplementedError |
Always. |
from_dict(self, data)
Parse a Member from an API compliant dict.
update_from_user(self, user)
Update Member properties from associated user.
User (BaseDiscordObject)
Discord User.
Attributes:
Name | Type | Description |
---|---|---|
id |
Snowflake |
Unique ID of User. Is a Snowflake. |
username |
str |
Global name of the User. |
discriminator |
int |
Random set of 4 numbers to discriminate user from others. |
avatar |
str |
TODO: Look this up. |
bot |
bool |
User is a bot or not. |
mention
property
readonly
Generate a valid name mention for use in Discord.
mention_nickname
property
readonly
Generate a valid nickname mention for use in Discord.
PremiumType (IntFlag)
Type of Premium subscription the User has.
UserFlag (IntFlag)
Flags on a User.
to_dict(self)
inherited
Convert object to dictionary suitable for API or other generic useage.
__str__(self)
special
Return a discord compatible mention string.
validate(self)
inherited
Check for valid object type.
Exceptions:
Type | Description |
---|---|
NotImplementedError |
Always. |
__repr__(self)
special
Return a discord compatible mention string.
__eq__(self, other)
special
Determine if other User and self are the same User.
from_dict(self, data)
Parse a User from an API compliant dict.
utilities
special
borg
Borg design module.
Borg
Borg design pattern base class.
__init__(self)
special
To be called by child-classes.
cache
Cache values for discord to use. NOT CURRENTLY USED.
Cache (Borg)
Generic cache of objects we have been told about from the API.
__init__(self)
special
Create a access to the cache, follows the Borg design pattern.
get(self, identifier)
Return a given object with an given identifier if we know about it.
add(self, object)
Given some generic object, insert it into the cache.
clear(self)
Remove all current elements within the cache.
log
Log
Generalized logging class for easy import.
Attributes:
Name | Type | Description |
---|---|---|
trace |
5 |
|
verbose |
7 |
|
debug |
10 |
|
info |
20 |
|
notice |
25 |
|
warning |
30 |
|
suppressed |
31 |
|
error |
40 |
|
critical |
50 |
|
alert |
70 |
|
emergency |
100 |
|
exception |
? |
__getattr__(self, name)
special
Map in the logging class attributes.