- Quickstart
- API Reference
- Frequently Asked Questions
- discord.py is dead! Will this library die too?
- Are you going to/will/consider fork(ing) discord.py?
- Will discord.py be able to work with this library?
- Where should we go with discord.py being gone?
- Why are you not supporting cooldowns?
- Will we not be able to create message commands?
- My question is not answered on here!
HTTP Client¶
- class interactions.api.http.Route(method: str, path: str, **kwargs)
A class representing how an HTTP route is structured.
- Variables
- property bucket: str
Returns the route’s bucket.
- Returns
str
- class interactions.api.http.Padlock(lock: asyncio.locks.Lock)
A class representing ratelimited sessions as a “locked” event.
- Variables
lock (asyncio.Lock) – The lock coroutine event.
keep_open (bool) – Whether the lock should stay open or not.
- click() None
Re-closes the lock after the instiantiation and invocation ends.
- class interactions.api.http.Request(token: str)
A class representing how HTTP requests are sent/read.
- Variables
token (str) – The current application token.
loop (asyncio.AbstractEventLoop) – The current coroutine event loop.
ratelimits (dict) – The current ratelimits from the Discord API.
headers (dict) – The current headers for an HTTP request.
session (asyncio.ClientSession) – The current session for making requests.
lock (asyncio.Event) – The ratelimit lock event.
- check_session() None
Ensures that we have a valid connection session.
- async request(route: interactions.api.http.Route, **kwargs) Optional[Any]
Sends a request to the Discord API.
- Parameters
route (interactions.api.http.Route) – The HTTP route to request.
**kwargs (dict) – Optional keyword-only arguments to pass as information in the request.
- Returns
None
- async close() None
Closes the current session.
- class interactions.api.http.HTTPClient(token: str)
A WIP class that represents the http Client that handles all major endpoints to Discord API.
- async get_gateway() str
This calls the Gateway endpoint and returns a v9 gateway link with JSON encoding.
- async get_bot_gateway() Tuple[int, str]
This calls the BOT Gateway endpoint. :return: A tuple denoting (shard, gateway_url), url from API v9 and JSON encoding
- async login() Optional[dict]
This ‘logins’ to the gateway, which makes it available to use any other endpoint.
- async logout() None
This ‘log outs’ the session.
- async get_current_bot_information() dict
Returns the bot user application object without flags.
- async get_current_authorisation_information() dict
Returns info about the current authorization of the bot user
- async get_voice_regions() List[interactions.api.models.voice.VoiceRegion]
Gets a list from the API a list of voice regions. :return: An array of Voice Region objects.
- async get_self() dict
An alias to get_user, but only gets the current bot user.
:return A partial User object of the current bot user in the form of a dictionary.
- async get_user(user_id: Optional[int] = None) dict
Gets a user object for a given user ID. :param user_id: A user snowflake ID. If omitted, this defaults to the current bot user. :return A partial User object in the form of a dictionary.
- async modify_self(payload: dict) dict
Modify the bot user account settings. :param payload: The data to send.
- async modify_self_nick_in_guild(guild_id: int, nickname: Optional[str])
Changes a nickname of the current bot user in a guild.
- Parameters
guild_id – Guild snowflake ID.
nickname – The new nickname, if any.
- Returns
Nothing needed to be yielded.
- async create_dm(recipient_id: int) dict
Creates a new DM channel with a user. :param recipient_id: User snowflake ID. :return: Returns a dictionary representing a DM Channel object.
- async send_message(channel_id: int, content: str, tts: bool = False, embed: Optional[interactions.api.models.message.Embed] = None, nonce: Optional[Union[int, str]] = None, allowed_mentions=None, message_reference: Optional[interactions.api.models.message.Message] = None)
A higher level implementation of
create_message()
that handles the payload dict internally. Does not integrate components into the function, and is a port from v3.0.0
- async create_message(payload: dict, channel_id: int) dict
Send a message to the specified channel.
- Parameters
payload – Dictionary contents of a message. (i.e. message payload)
channel_id – Channel snowflake ID.
- Return dict
Dictionary representing a message (?)
- async get_message(channel_id: int, message_id: int) Optional[dict]
Get a specific message in the channel. :param channel_id: the channel this message belongs to :param message_id: the id of the message :return: message if it exists.
- async delete_message(channel_id: int, message_id: int, reason: Optional[str] = None) None
Deletes a message from a specified channel :param channel_id: Channel snowflake ID. :param message_id: Message snowflake ID. :param reason: Optional reason to show up in the audit log. Defaults to None.
- async delete_messages(channel_id: int, message_ids: List[int], reason: Optional[str] = None) None
Deletes messages from a specified channel :param channel_id: Channel snowflake ID. :param message_ids: An array of message snowflake IDs. :param reason: Optional reason to show up in the audit log. Defaults to None.
- async edit_message(channel_id: int, message_id: int, payload: dict) dict
Edits a message that already exists.
- Parameters
channel_id – Channel snowflake ID.
message_id – Message snowflake ID.
payload (dict) – Any new data that needs to be changed.
- Returns
A message object with edited attributes.
- async pin_message(channel_id: int, message_id: int) None
Pin a message to a channel. :param channel_id: Channel ID snowflake. :param message_id: Message ID snowflake.
- async unpin_message(channel_id: int, message_id: int) None
Unpin a message to a channel :param channel_id: Channel ID snowflake. :param message_id: Message ID snowflake.
- async publish_message(channel_id: int, message_id: int) dict
Publishes (API calls it crossposts) a message in a News channel to any that is followed by.
- Parameters
channel_id – Channel the message is in
message_id – The id of the message to publish
- Returns
message object
- async get_self_guilds() list
Gets all guild objects associated with the current bot user.
:return a list of partial guild objects the current bot user is a part of.
- async get_guild(guild_id: int)
Requests an individual guild from the API. :param guild_id: The guild snowflake ID associated. :return: The guild object associated, if any.
- async get_guild_preview(guild_id: int) interactions.api.models.guild.GuildPreview
Get a guild’s preview. :param guild_id: Guild ID snowflake. :return: Guild Preview object associated with the snowflake
- async modify_guild(guild_id: int, payload: dict, reason: Optional[str] = None) None
Modifies a guild’s attributes.
- ..note::
This only sends the payload. You will have to check it when a higher-level function calls this.
- Parameters
guild_id – Guild ID snowflake.
payload – The parameters to change.
reason – Reason to send to the audit log, if given.
- async leave_guild(guild_id: int) None
Leaves a guild.
- Parameters
guild_id – The guild snowflake ID associated.
- Returns
None
- async get_guild_widget(guild_id: int) dict
Returns the widget for the guild. :param guild_id: Guild ID snowflake. :return: Guild Widget contents as a dict: {“enabled”:bool, “channel_id”: str}
- async get_guild_widget_settings(guild_id: int) dict
Get guild widget settings.
- Parameters
guild_id – Guild ID snowflake.
- Returns
Guild Widget contents as a dict: {“enabled”:bool, “channel_id”: str}
- async get_guild_widget_image(guild_id: int, style: Optional[str] = None) str
Get a url representing a png image widget for the guild. ..note:
See _<https://discord.com/developers/docs/resources/guild#get-guild-widget-image> for list of styles.
- Parameters
guild_id – Guild ID snowflake.
style – The style of widget required, if given.
- Returns
A url pointing to this image
- async modify_guild_widget(guild_id: int, payload: dict) dict
Modify a guild widget.
- Parameters
guild_id – Guild ID snowflake.
payload – Payload containing new widget attributes.
- Returns
Updated widget attributes.
- async get_guild_invites(guild_id: int) List[interactions.api.models.guild.Invite]
Retrieves a list of invite objects with their own metadata. :param guild_id: Guild ID snowflake. :return: A list of invite objects
- async get_guild_welcome_screen(guild_id: int) interactions.api.models.guild.WelcomeScreen
Retrieves from the API a welcome screen associated with the guild :param guild_id: Guild ID snowflake. :return: Welcome Screen object
- async modify_guild_welcome_screen(guild_id: int, enabled: bool, welcome_channels: List[int], description: str) interactions.api.models.guild.WelcomeScreen
Modify the guild’s welcome screen.
- Parameters
guild_id – Guild ID snowflake.
enabled – Whether the welcome screen is enabled or not.
welcome_channels – The new channels (by their ID) linked in the welcome screen and their display options
description – The new server description to show in the welcome screen
- Returns
Updated Welcome screen object.
- async get_guild_integrations(guild_id: int) List[dict]
Gets a list of integration objects associated with the Guild from the API. :param guild_id: Guild ID snowflake. :return: An array of integration objects
- async delete_guild_integration(guild_id: int, integration_id: int) None
Deletes an integration from the guild. :param guild_id: Guild ID snowflake. :param integration_id: Integration ID snowflake.
- async modify_current_user_voice_state(guild_id: int, channel_id: int, suppress: Optional[bool] = None, request_to_speak_timestamp: Optional[str] = None) None
Update the current user voice state.
- Parameters
guild_id – Guild ID snowflake.
channel_id – Voice channel ID snowflake.
suppress – Toggle the user’s suppress state, if given.
request_to_speak_timestamp – Sets the user’s request to speak, if given.
- async modify_user_voice_state(guild_id: int, user_id: int, channel_id: int, suppress: Optional[bool] = None) None
Modify the voice state of a user.
- Parameters
guild_id – Guild ID snowflake.
user_id – User ID snowflake.
channel_id – Voice channel ID snowflake.
suppress – Toggles the user’s suppress state, if given.
- async create_guild_from_guild_template(template_code: str, name: str, icon: Optional[str] = None) interactions.api.models.guild.Guild
Create a a new guild based on a template.
- ..note::
This endpoint can only be used by bots in less than 10 guilds.
- Parameters
template_code – The code of the template to use.
name – The name of the guild (2-100 characters)
icon – Guild icon URI, if given.
- Returns
The newly created guild object.
- async get_guild_templates(guild_id: int) List[interactions.api.models.guild.GuildTemplate]
Returns an array of guild templates.
- Parameters
guild_id – Guild ID snowflake.
- Returns
An array of guild templates
- async create_guild_template(guild_id: int, name: str, description: Optional[str] = None) interactions.api.models.guild.GuildTemplate
Create a guild template for the guild.
- Parameters
guild_id – Guild ID snowflake.
name – The name of the template
description – The description of the template, if given.
- Returns
The created guild template
- async sync_guild_template(guild_id: int, template_code: str) interactions.api.models.guild.GuildTemplate
Sync the template to the guild’s current state.
- Parameters
guild_id – Guild ID snowflake.
template_code – The code for the template to sync
- Returns
The updated guild template.
- async modify_guild_template(guild_id: int, template_code: str, name: Optional[str] = None, description: Optional[str] = None) interactions.api.models.guild.GuildTemplate
Modify a guild template.
- Parameters
guild_id – Guild ID snowflake.
template_code – Template ID.
name – The name of the template
description – The description of the template
- Returns
The updated guild template
- async delete_guild_template(guild_id: int, template_code: str) interactions.api.models.guild.GuildTemplate
Delete the guild template.
- Parameters
guild_id – Guild ID snowflake.
template_code – Template ID.
- Returns
The deleted template object
- async get_all_channels(guild_id: int) List[dict]
Requests from the API to get all channels in the guild.
- Parameters
guild_id – Guild Snowflake ID
- Returns
A list of channels.
- async get_all_roles(guild_id: int) List[interactions.api.models.role.Role]
Gets all roles from a Guild. :param guild_id: Guild ID snowflake :return: An array of Role objects.
- async create_guild_role(guild_id: int, data: dict, reason: Optional[str] = None) interactions.api.models.role.Role
Create a new role for the guild. :param guild_id: Guild ID snowflake. :param data: A dict containing metadata for the role. :param reason: The reason for this action, if given. :return: Role object
- async modify_guild_role_position(guild_id: int, role_id: int, position: int, reason: Optional[str] = None) List[interactions.api.models.role.Role]
Modify the position of a role in the guild. :param guild_id: Guild ID snowflake. :param role_id: Role ID snowflake. :param position: The new position of the associated role. :param reason: The reason for this action, if given. :return: List of guild roles with updated hierarchy.
- async modify_guild_role(guild_id: int, role_id: int, data: dict, reason: Optional[str] = None) interactions.api.models.role.Role
Modify a given role for the guild. :param guild_id: Guild ID snowflake. :param role_id: Role ID snowflake. :param data: A dict containing updated metadata for the role. :param reason: The reason for this action, if given. :return: Updated role object.
- async delete_guild_role(guild_id: int, role_id: int, reason: Optional[str] = None) None
Delete a guild role. :param guild_id: Guild ID snowflake. :param role_id: Role ID snowflake. :param reason: The reason for this action, if any.
- async create_guild_kick(guild_id: int, user_id: int, reason: Optional[str] = None) None
Kicks a person from the guild.
- Parameters
guild_id – Guild ID snowflake
user_id – User ID snowflake
reason – Optional Reason argument.
- async create_guild_ban(guild_id: int, user_id: int, delete_message_days: Optional[int] = 0, reason: Optional[str] = None) None
Bans a person from the guild, and optionally deletes previous messages sent by them. :param guild_id: Guild ID snowflake :param user_id: User ID snowflake :param delete_message_days: Number of days to delete messages, from 0 to 7. Defaults to 0 :param reason: Optional reason to ban.
- async remove_guild_ban(guild_id: int, user_id: int, reason: Optional[str] = None) None
Unbans someone using the API. :param guild_id: Guild ID snowflake :param user_id: User ID snowflake :param reason: Optional reason to unban.
- async get_guild_bans(guild_id: int) List[dict]
Gets a list of banned users. :param guild_id: Guild ID snowflake. :return: A list of banned users.
- async get_user_ban(guild_id: int, user_id: int) Optional[dict]
Gets an object pertaining to the user, if it exists. Returns a 404 if it doesn’t. :param guild_id: Guild ID snowflake :param user_id: User ID snowflake. :return: Ban object if it exists.
- async add_guild_member(guild_id: int, user_id: int, access_token: str, nick: Optional[str] = None, roles: Optional[List[interactions.api.models.role.Role]] = None, mute: Optional[bool] = None, deaf: Optional[bool] = None) interactions.api.models.member.Member
A low level method of adding a user to a guild with pre-defined attributes.
- Parameters
guild_id – Guild ID snowflake.
user_id – User ID snowflake.
access_token – User access token.
nick – User’s nickname on join.
roles – An array of roles that the user is assigned.
mute – Whether the user is mute in voice channels.
deaf – Whether the user is deafened in voice channels.
- Returns
Guild member object (?)
- async remove_guild_member(guild_id: int, user_id: int, reason: Optional[str] = None) None
A low level method of removing a member from a guild. This is different from banning them. :param guild_id: Guild ID snowflake. :param user_id: User ID snowflake. :param reason: Reason to send to audit log, if any.
- async get_guild_prune_count(guild_id: int, days: int = 7, include_roles: Optional[List[int]] = None) dict
Retrieves a dict from an API that results in how many members would be pruned given the amount of days. :param guild_id: Guild ID snowflake. :param days: Number of days to count. Defaults to
7
. :param include_roles: Role IDs to include, if given. :return: A dict denoting {“pruned”: int}
- async get_member(guild_id: int, member_id: int) Optional[interactions.api.models.member.Member]
Uses the API to fetch a member from a guild. :param guild_id: Guild ID snowflake. :param member_id: Member ID snowflake. :return: A member object, if any.
- async get_list_of_members(guild_id: int, limit: int = 1, after: Optional[int] = None) List[interactions.api.models.member.Member]
Lists the members of a guild.
- Parameters
guild_id – Guild ID snowflake
limit – How many members to get from the API. Max is 1000. Defaults to 1.
after – Get Member IDs after this snowflake. Defaults to None.
- Returns
An array of Member objects.
- async search_guild_members(guild_id: int, query: str, limit: int = 1) List[interactions.api.models.member.Member]
Search a guild for members who’s username or nickname starts with provided string.
- Parameters
guild_id – Guild ID snowflake.
query – The string to search for
limit – The number of members to return. Defaults to 1.
- async add_member_role(guild_id: int, user_id: int, role_id: int, reason: Optional[str] = None) None
Adds a role to a guild member.
- Parameters
guild_id – The ID of the guild
user_id – The ID of the user
role_id – The ID of the role to add
reason – The reason for this action. Defaults to None.
- async remove_member_role(guild_id: int, user_id: int, role_id: int, reason: Optional[str] = None) None
Removes a role to a guild member.
- Parameters
guild_id – The ID of the guild
user_id – The ID of the user
role_id – The ID of the role to add
reason – The reason for this action. Defaults to None.
- async modify_member(user_id: int, guild_id: int, payload: dict)
Edits a member. This can nick them, change their roles, mute/deafen (and its contrary), and moving them across channels and/or disconnect them
- Parameters
user_id – Member ID snowflake.
guild_id – Guild ID snowflake.
payload – Payload representing parameters (nick, roles, mute, deaf, channel_id)
- Returns
? (modified voice state? not sure)
- async get_channel(channel_id: int) interactions.api.models.channel.Channel
Gets a channel by ID. If the channel is a thread, it also includes thread members (and other thread attributes) :param channel_id: Channel ID snowflake. :return: Channel object.
- async delete_channel(channel_id: int) None
Deletes a channel.
- Parameters
channel_id – Channel ID snowflake
- async get_channel_messages(channel_id: int, limit: int = 50, around: Optional[int] = None, before: Optional[int] = None, after: Optional[int] = None) List[interactions.api.models.message.Message]
Get messages from a channel.
- ..note::
around, before, and after arguments are mutually exclusive.
- Parameters
channel_id – Channel ID snowflake.
limit – How many messages to get. Defaults to 50, the max is 100.
around – Get messages around this snowflake ID.
before – Get messages before this snowflake ID.
after – Get messages after this snowflake ID.
- Returns
An array of Message objects.
- async create_channel(guild_id: int, payload: dict, reason: Optional[str] = None) interactions.api.models.channel.Channel
Creates a channel within a guild.
- ..note::
This does not handle payload in this method. Tread carefully.
- Parameters
guild_id – Guild ID snowflake.
payload – Payload data.
reason – Reason to show in audit log, if needed.
- Returns
Channel object.
- async move_channel(guild_id: int, channel_id: int, new_pos: int, parent_id: Optional[int], lock_perms: bool = False, reason: Optional[str] = None)
Moves a channel to a new position.
- Parameters
guild_id – Guild ID snowflake.
channel_id – Channel ID snowflake.
new_pos – The new channel position.
parent_id – The category parent ID, if needed.
lock_perms – Sync permissions with the parent associated with parent_id. Defaults to False.
reason – Reason to display to the audit log, if any.
- Returns
?
- async modify_channel(channel_id: int, data: dict, reason: Optional[str] = None) interactions.api.models.channel.Channel
Update a channel’s settings. :param channel_id: Channel ID snowflake. :param data: Data representing updated settings. :param reason: Reason, if any. :return: Channel with updated attributes, if successful.
- async get_channel_invites(channel_id: int) List[interactions.api.models.guild.Invite]
Get the invites for the channel. :param channel_id: Channel ID snowflake. :return: List of invite objects
- async create_channel_invite(channel_id: int, data: dict, reason: Optional[str] = None) interactions.api.models.guild.Invite
Creates an invite for the given channel.
- ..note::
This method does not handle payload. It just sends it.
- Parameters
channel_id – Channel ID snowflake.
data – Data representing the payload/invite attributes.
reason – Reason to show in the audit log, if any.
- Returns
An invite object.
- async delete_invite(invite_code: str, reason: Optional[str] = None) dict
Delete an invite. :param invite_code: The code of the invite to delete :param reason: Reason to show in the audit log, if any. :return: The deleted invite object
- async edit_channel_permission(channel_id: int, overwrite_id: int, allow: str, deny: str, perm_type: int, reason: Optional[str] = None) None
Edits the channel’s permission overwrites for a user or role in a given channel.
- Parameters
channel_id – Channel ID snowflake.
overwrite_id – The ID of the overridden object.
allow – the bitwise value of all allowed permissions
deny – the bitwise value of all disallowed permissions
perm_type – 0 for a role or 1 for a member
reason – Reason to display in the Audit Log, if given.
- async delete_channel_permission(channel_id: int, overwrite_id: int, reason: Optional[str] = None) None
Deletes a channel permission overwrite for a user or role in a channel.
- Parameters
channel_id – Channel ID snowflake.
overwrite_id – The ID of the overridden object.
reason – Reason to display in the Audit Log, if given.
- async trigger_typing(channel_id: int) None
Posts “… is typing” in a given channel.
- ..note:
By default, this lib doesn’t use this endpoint, however, this is listed for third-party implementation.
- Parameters
channel_id – Channel ID snowflake.
- async get_pinned_messages(channel_id: int) List[interactions.api.models.message.Message]
Get all pinned messages from a channel. :param channel_id: Channel ID snowflake. :return: A list of pinned message objects.
- async create_stage_instance(channel_id: int, topic: str, privacy_level: int = 1, reason: Optional[str] = None) interactions.api.models.guild.StageInstance
Create a new stage instance.
- Parameters
channel_id – Channel ID snowflake.
topic – The topic of the stage instance. Limited to 1-120 characters.
privacy_level – The privacy_level of the stage instance (defaults to guild-only “1”).
reason – The reason for the creating the stage instance, if any.
- Returns
The new stage instance
- async get_stage_instance(channel_id: int) interactions.api.models.guild.StageInstance
Get the stage instance associated with a given channel, if it exists.
- Parameters
channel_id – Channel ID snowflake.
- Returns
A stage instance.
- async modify_stage_instance(channel_id: int, topic: Optional[str] = None, privacy_level: Optional[int] = None, reason: Optional[str] = None) interactions.api.models.guild.StageInstance
Update the fields of a given stage instance.
- Parameters
channel_id – Channel ID snowflake.
topic – The new topic of the stage instance, if given. Limited to 1-120 characters.
privacy_level – The new privacy_level of the stage instance.
reason – The reason for the creating the stage instance, if any.
- Returns
The updated stage instance.
- async delete_stage_instance(channel_id: int, reason: Optional[str] = None) None
Delete a stage instance.
- Parameters
channel_id – Channel ID snowflake.
reason – The reason for the creating the stage instance, if any.
- async join_thread(thread_id: int) None
Have the bot user join a thread. :param thread_id: The thread to join.
- async leave_thread(thread_id: int) None
Have the bot user leave a thread. :param thread_id: The thread to leave.
- async add_member_to_thread(thread_id: int, user_id: int) None
Add another user to a thread. :param thread_id: The ID of the thread :param user_id: The ID of the user to add
- async remove_member_from_thread(thread_id: int, user_id: int) None
Remove another user from a thread. :param thread_id: The ID of the thread :param user_id: The ID of the user to remove
- async list_thread_members(thread_id: int) List[dict]
Get a list of members in the thread. :param thread_id: the id of the thread :return: a list of member objects
- async list_public_archived_threads(channel_id: int, limit: Optional[int] = None, before: Optional[int] = None) List[dict]
Get a list of archived public threads in a given channel.
- Parameters
channel_id – The channel to get threads from
limit – Optional limit of threads to
before – Get threads before this Thread snowflake ID
- Returns
a list of threads
- async list_private_archived_threads(channel_id: int, limit: Optional[int] = None, before: Optional[int] = None) List[dict]
Get a list of archived private threads in a channel. :param channel_id: The channel to get threads from :param limit: Optional limit of threads to :param before: Get threads before this Thread snowflake ID :return: a list of threads
- async list_joined_private_archived_threads(channel_id: int, limit: Optional[int] = None, before: Optional[int] = None) List[dict]
Get a list of archived private threads in a channel that the bot has joined. :param channel_id: The channel to get threads from :param limit: Optional limit of threads to :param before: Get threads before this snowflake ID :return: a list of threads
- async list_active_threads(guild_id: int) List[dict]
List active threads within a guild. :param guild_id: the guild id to get threads from :return: A list of active threads
- async create_thread(channel_id: int, name: str, auto_archive_duration: int, thread_type: Optional[int] = None, invitable: Optional[bool] = None, message_id: Optional[int] = None, reason: Optional[str] = None) dict
From a given channel, create a Thread with an optional message to start with..
- Parameters
channel_id – The ID of the channel to create this thread in
name – The name of the thread
auto_archive_duration – duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080
thread_type – The type of thread, defaults to public. ignored if creating thread from a message
invitable – Boolean to display if the Thread is open to join or private.
message_id – An optional message to create a thread from.
reason – An optional reason for the audit log
- Returns
The created thread
- async create_reaction(channel_id: int, message_id: int, emoji: str) None
Create a reaction for a message. :param channel_id: Channel snowflake ID. :param message_id: Message snowflake ID. :param emoji: The emoji to use (format: name:id)
- async remove_self_reaction(channel_id: int, message_id: int, emoji: str) None
Remove bot user’s reaction from a message. :param channel_id: Channel snowflake ID. :param message_id: Message snowflake ID. :param emoji: The emoji to remove (format: name:id)
- async remove_user_reaction(channel_id: int, message_id: int, emoji: str, user_id: int) None
Remove user’s reaction from a message
- Parameters
channel_id – The channel this is taking place in
message_id – The message to remove the reaction on.
emoji – The emoji to remove. (format: name:id)
user_id – The user to remove reaction of.
- async remove_all_reactions(channel_id: int, message_id: int) None
Remove all reactions from a message.
- Parameters
channel_id – The channel this is taking place in.
message_id – The message to clear reactions from.
- async remove_all_reactions_of_emoji(channel_id: int, message_id: int, emoji: str) None
Remove all reactions of a certain emoji from a message. :param channel_id: Channel snowflake ID. :param message_id: Message snowflake ID. :param emoji: The emoji to remove (format: name:id)
- async get_reactions_of_emoji(channel_id: int, message_id: int, emoji: str) List[interactions.api.models.user.User]
Gets the users who reacted to the emoji. :param channel_id: Channel snowflake ID. :param message_id: Message snowflake ID. :param emoji: The emoji to get (format: name:id) :return A list of users who sent that emoji.
- async get_sticker(sticker_id: int) dict
Get a specific sticker. :param sticker_id: The id of the sticker :return: Sticker or None
- async list_nitro_sticker_packs() list
Gets the list of sticker packs available to Nitro subscribers. :return: List of sticker packs
- async list_guild_stickers(guild_id: int) List[dict]
Get the stickers for a guild. :param guild_id: The guild to get stickers from :return: List of Stickers or None
- async get_guild_sticker(guild_id: int, sticker_id: int) dict
Get a sticker from a guild. :param guild_id: The guild to get stickers from :param sticker_id: The sticker to get from the guild :return: Sticker or None
- async create_guild_sticker(payload: aiohttp.formdata.FormData, guild_id: int, reason: Optional[str] = None)
Create a new sticker for the guild. Requires the MANAGE_EMOJIS_AND_STICKERS permission. :param payload: the payload to send. :param guild_id: The guild to create sticker at. :param reason: The reason for this action. :return: The new sticker data on success.
- async modify_guild_sticker(payload: dict, guild_id: int, sticker_id: int, reason: Optional[str] = None)
Modify the given sticker. Requires the MANAGE_EMOJIS_AND_STICKERS permission. :param payload: the payload to send. :param guild_id: The guild of the target sticker. :param sticker_id: The sticker to modify. :param reason: The reason for this action. :return: The updated sticker data on success.
- async delete_guild_sticker(guild_id: int, sticker_id: int, reason: Optional[str] = None) None
Delete the given sticker. Requires the MANAGE_EMOJIS_AND_STICKERS permission. :param guild_id: The guild of the target sticker. :param sticker_id: The sticker to delete. :param reason: The reason for this action. :return: Returns 204 No Content on success.
- async get_application_command(application_id: int, guild_id: Optional[int] = None) List[dict]
Get all application commands from an application :param application_id: Application ID snowflake :param guild_id: Guild to get commands from, if specified. Defaults to global (None) :return: A list of Application commands.
- async create_application_command(application_id: int, data: dict, guild_id: Optional[int] = None)
Registers to the Discord API an application command.
- Parameters
application_id – Application ID snowflake
data – The dictionary that contains the command (name, description, etc)
guild_id – Guild ID snowflake to put them in, if applicable.
- Returns
An application command object.
- async overwrite_application_command(application_id: int, data: List[dict], guild_id: Optional[int] = None) List[dict]
Overwrites application command(s) from a scope to the new, updated commands.
- ..note:
This applies to all forms of application commands (slash and context menus)
- Parameters
application_id – Application ID snowflake
data – The dictionary that contains the command (name, description, etc)
guild_id – Guild ID snowflake to put them in, if applicable.
- Returns
An array of application command objects.
- async edit_application_command(application_id: int, data: dict, command_id: int, guild_id: Optional[int] = None) dict
Edits an application command.
- Parameters
application_id – Application ID snowflake.
data – A dictionary containing updated attributes
command_id – The application command ID snowflake
guild_id – Guild ID snowflake, if given. Defaults to None/global.
- Returns
The updated application command object.
- async delete_application_command(application_id: int, command_id: int, guild_id: Optional[int] = None) None
Deletes an application command.
- Parameters
application_id – Application ID snowflake.
command_id – Application command ID snowflake.
guild_id – Guild ID snowflake, if declared. Defaults to None (Global).
- async edit_application_command_permissions(application_id: int, guild_id: int, command_id: int, data: List[dict]) dict
Edits permissions for an application command
- Parameters
application_id – Application ID snowflake
guild_id – Guild ID snowflake
command_id – Application command ID snowflake
data – Permission data.
- Returns
Returns an updated Application Guild permission object.
- async batch_edit_application_command_permissions(application_id: int, guild_id: int, data: List[dict]) List[dict]
Edits permissions for all Application Commands in a guild.
- Parameters
application_id – Application ID snowflake
guild_id – Guild ID snowflake
data – An array of permission dictionaries.
- Returns
An updated array of application array permissions.
- async get_application_command_permissions(application_id: int, guild_id: int, command_id: int) dict
Gets, from the Discord API, permissions from a specific Guild application command.
- Parameters
application_id – Application ID snowflake
guild_id – Guild ID snowflake
command_id – Application Command ID snowflake
- Returns
a Guild Application Command permissions object
- async get_all_application_command_permissions(application_id: int, guild_id: int) List[dict]
Gets, from the Discord API, permissions from all Application commands at that Guild.
- Parameters
application_id – Application ID snowflake
guild_id – Guild ID snowflake
- Returns
An array of Guild Application Command permissions
- async create_interaction_response(token: str, application_id: int, data: dict) None
Posts initial response to an interaction, but you need to add the token.
- Parameters
token – Token.
application_id – Application ID snowflake
data – The data to send.
- async get_original_interaction_response(token: str, application_id: str, message_id: int = '@original') dict
Gets an existing interaction message. :param token: token :param application_id: Application ID snowflake. :param message_id: Message ID snowflake. Defaults to @original which represents the initial response msg. :return: Message data.
- async edit_interaction_response(data: dict, token: str, application_id: str, message_id: int = '@original') dict
Edits an existing interaction message, but token needs to be manually called. :param data: A dictionary containing the new response. :param token: token :param application_id: Application ID snowflake. :param message_id: Message ID snowflake. Defaults to @original which represents the initial response msg. :return: Updated message data.
- async create_webhook(channel_id: int, name: str, avatar: Optional[Any] = None) dict
Create a new webhook. :param channel_id: Channel ID snowflake. :param name: Name of the webhook (1-80 characters) :param avatar: The image for the default webhook avatar, if given.
:return Webhook object
- async get_channel_webhooks(channel_id: int) List[dict]
Return a list of channel webhook objects. :param channel_id: Channel ID snowflake. :return:List of webhook objects
- async get_guild_webhooks(guild_id: int) List[dict]
Return a list of guild webhook objects. :param guild_id: Guild ID snowflake
- Returns
List of webhook objects
- async get_webhook(webhook_id: int, webhook_token: Optional[str] = None) dict
Return the new webhook object for the given id. :param webhook_id: Webhook ID snowflake. :param webhook_token: Webhook Token, if given.
:return:Webhook object
- async modify_webhook(webhook_id: int, name: str, avatar: Any, channel_id: int, webhook_token: Optional[str] = None) dict
Modify a webhook. :param webhook_id: Webhook ID snowflake :param name: the default name of the webhook :param avatar: image for the default webhook avatar :param channel_id: Channel ID snowflake of new destination :param webhook_token: The token for the webhook, if given.
- Returns
Modified webhook object.
- async delete_webhook(webhook_id: int, webhook_token: Optional[str] = None)
Delete a webhook :param webhook_id: Webhook ID snowflake. :param webhook_token: The token for the webhook, if given.
- async execute_webhook(webhook_id: int, webhook_token: str, payload: dict, wait: bool = False, thread_id: Optional[int] = None) Optional[interactions.api.models.message.Message]
Sends a message as a webhook.
- Parameters
webhook_id – Webhook ID snowflake.
webhook_token – The token for the webhook.
payload – Payload consisting of the message.
wait – A bool that signifies waiting for server confirmation of a send before responding.
thread_id – Optional, sends a message to the specified thread.
- Returns
The message sent, if wait=True, else None.
- async execute_slack_webhook(webhook_id: int, webhook_token: str, payload: dict) None
Sends a message to a Slack-compatible webhook.
- Parameters
webhook_id – Webhook ID snowflake.
webhook_token – The token for the webhook.
payload – Payload consisting of the message.
- Returns
?
Note
Payload structure is different than Discord’s. See here <https://api.slack.com/messaging/webhooks>_ for more details.
- async execute_github_webhook(webhook_id: int, webhook_token: str, payload: dict) None
Sends a message to a Github-compatible webhook.
- Parameters
webhook_id – Webhook ID snowflake.
webhook_token – The token for the webhook.
payload – Payload consisting of the message.
- Returns
?
Note
Payload structure is different than Discord’s. See here <https://discord.com/developers/docs/resources/webhook#execute-githubcompatible-webhook>_ for more details.
- async get_webhook_message(webhook_id: int, webhook_token: str, message_id: int) interactions.api.models.message.Message
Retrieves a message sent from a Webhook.
- Parameters
webhook_id – Webhook ID snowflake.
webhook_token – Webhook token.
message_id – Message ID snowflake,
- Returns
A Message object.
- async edit_webhook_message(webhook_id: int, webhook_token: str, message_id: int, data: dict) interactions.api.models.message.Message
Edits a message sent from a Webhook.
- Parameters
webhook_id – Webhook ID snowflake.
webhook_token – Webhook token.
message_id – Message ID snowflake.
data – A payload consisting of new message attributes.
- Returns
An updated message object.
- async delete_webhook_message(webhook_id: int, webhook_token: str, message_id: int) None
Deletes a message object.
- Parameters
webhook_id – Webhook ID snowflake.
webhook_token – Webhook token.
message_id – Message ID snowflake.
- async get_all_emoji(guild_id: int) List[interactions.api.models.message.Emoji]
Gets all emojis from a guild.
- Parameters
guild_id – Guild ID snowflake.
- Returns
A list of emojis.
- async get_guild_emoji(guild_id: int, emoji_id: int) interactions.api.models.message.Emoji
Gets an emote from a guild. :param guild_id: Guild ID snowflake. :param emoji_id: Emoji ID snowflake. :return: Emoji object
- async create_guild_emoji(guild_id: int, data: dict, reason: Optional[str] = None) interactions.api.models.message.Emoji
Creates an emoji. :param guild_id: Guild ID snowflake. :param data: Emoji parameters. :param reason: Optionally, give a reason. :return: An emoji object with the included parameters.
- async modify_guild_emoji(guild_id: int, emoji_id: int, data: dict, reason: Optional[str] = None) interactions.api.models.message.Emoji
Modifies an emoji. :param guild_id: Guild ID snowflake. :param emoji_id: Emoji ID snowflake :param data: Emoji parameters with updated attributes :param reason: Optionally, give a reason. :return: An emoji object with updated attributes.