HTTP#

Important

  1. This page shows internal functions that you should not use unless you know how to use them. Most of these functions should have their own implementation in the different Models of the library.

  2. Because this page is showcasing internal functions the versionadded, deprecated and versionchanged markers will not be added.

class interactions.api.http.route.Route(method, path, **kwargs)[source]

A class representing how an HTTP route is structured.

Variables:
  • __api__ (ClassVar[str]) – The HTTP route path.

  • method (str) – The HTTP method.

  • path (str) – The URL path.

  • channel_id (Optional[str]) – The channel ID from the bucket if given.

  • guild_id (Optional[str]) – The guild ID from the bucket if given.

get_bucket(shared_bucket=None)[source]

Returns the route’s bucket. If shared_bucket is None, returns the path with major parameters. Otherwise, it relies on Discord’s given bucket.

Parameters:

shared_bucket (Optional[str]) – The bucket that Discord provides, if available.

Returns:

The route bucket.

Return type:

str

property endpoint: str

Returns the route’s endpoint.

Returns:

The route endpoint.

Return type:

str

class interactions.api.http.limiter.Limiter(*, lock, reset_after=<interactions.MISSING>)[source]

A class representing a limitation for an HTTP request.

Variables:
  • lock (Lock) – The “lock” or controller of the request.

  • reset_after (float) – The remaining time before the request can be ran.

class interactions.api.http.request._Request(token)[source]

A class representing how HTTP requests are sent/read.

Variables:
  • token (str) – The current application token.

  • _loop (AbstractEventLoop) – The current coroutine event loop.

  • ratelimits (Dict[str, Limiter]) – The current per-route rate limiters from the API.

  • buckets (Dict[str, str]) – The current endpoint to shared_bucket cache from the API.

  • _headers (dict) – The current headers for an HTTP request.

  • _session (ClientSession) – The current session for making requests.

  • _global_lock (Limiter) – The global rate limiter.

async request(route, **kwargs)[source]

Sends a request to the Discord API.

Parameters:
  • route (Route) – The HTTP route to request.

  • **kwargs? (dict) – Optional keyword-only arguments to pass as information in the request.

Returns:

The contents of the request if any.

Return type:

Optional[Any]

async close()[source]

Closes the current session.

class interactions.api.http.client.HTTPClient(token, cache)[source]

The user-facing client of the Web API for individual endpoints.

Variables:
  • token (str) – The token of the application.

  • _req (Request) – The requesting interface for endpoints.

  • cache (Cache) – The referenced cache.

async get_gateway()[source]

This calls the Gateway endpoint and returns a v9 gateway link with JSON encoding.

Return type:

str

async get_bot_gateway()[source]

This calls the BOT Gateway endpoint.

Returns:

A tuple denoting (shard, gateway_url), url from API v9 and JSON encoding

Return type:

Tuple[int, str]

async login()[source]

This ‘logins’ to the gateway, which makes it available to use any other endpoint.

Return type:

Optional[dict]

async logout()[source]

This ‘log outs’ the session.

async get_current_bot_information()[source]

Returns the bot user application object without flags.

Return type:

dict

async add_guild_member(guild_id, user_id, access_token, nick=None, roles=None, mute=None, deaf=None)

A low level method of adding a user to a guild with pre-defined attributes.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • user_id (int) – User ID snowflake.

  • access_token (str) – User access token.

  • nick (Optional[str]) – User’s nickname on join.

  • roles (Optional[List[Role]]) – An array of roles that the user is assigned.

  • mute (Optional[bool]) – Whether the user is mute in voice channels.

  • deaf (Optional[bool]) – Whether the user is deafened in voice channels.

Returns:

Guild member object as dictionary

Return type:

dict

async add_member_role(guild_id, user_id, role_id, reason=None)

Adds a role to a guild member.

Parameters:
  • guild_id (int) – The ID of the guild

  • user_id (int) – The ID of the user

  • role_id (int) – The ID of the role to add

  • reason (Optional[str]) – The reason for this action. Defaults to None.

async add_member_to_thread(thread_id, user_id)

Add another user to a thread.

Parameters:
  • thread_id (int) – The ID of the thread

  • user_id (int) – The ID of the user to add

async begin_guild_prune(guild_id, days=7, compute_prune_count=True, include_roles=None)

Begins a prune operation.

Parameters:
  • guild_id (int) – Guild ID snowflake

  • days (int) – Number of days to count, minimum 1, maximum 30. Defaults to 7.

  • compute_prune_count (bool) – Whether the returned “pruned” dict contains the computed prune count or None.

  • include_roles (Optional[List[int]]) – Role IDs to include, if given.

Returns:

A dict containing {“pruned”: int} or {“pruned”: None}

Return type:

dict

async create_application_command(application_id, data, guild_id=None)

Registers to the Discord API an application command.

Parameters:
  • application_id (Union[int, Snowflake]) – Application ID snowflake

  • data (dict) – The dictionary that contains the command (name, description, etc)

  • guild_id (Optional[int]) – Guild ID snowflake to put them in, if applicable.

Returns:

An application command object.

Return type:

dict

async create_auto_moderation_rule(guild_id, name, event_type, trigger_type, actions, trigger_metadata=None, enabled=False, exempt_roles=None, exempt_channels=None, reason=None)

Create a new AutoMod rule in a guild.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • name (str) – The name of the new rule.

  • event_type (int) – The event type of the new rule.

  • trigger_type (int) – The trigger type of the new rule.

  • trigger_metadata (Optional[dict]) – The trigger metadata payload representation. This can be omitted based on the trigger type.

  • actions (List[dict]) – The actions that will execute when the rule is triggered.

  • enabled (Optional[bool]) – Whether the rule will be enabled upon creation. False by default.

  • exempt_roles (Optional[List[str]]) – The role IDs that are whitelisted by the rule, if given. The maximum is 20.

  • exempt_channels (Optional[List[str]]) – The channel IDs that are whitelisted by the rule, if given. The maximum is 20

  • reason (Optional[str]) – Reason to send to audit log, if any.

Returns:

A dictionary containing the new automod rule.

Return type:

dict

async create_channel(guild_id, payload, reason=None)

Creates a channel within a guild.

Note

This does not handle payload in this method. Tread carefully.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • payload (dict) – Payload data.

  • reason (Optional[str]) – Reason to show in audit log, if needed.

Returns:

Channel object as dictionary.

Return type:

dict

async create_channel_invite(channel_id, payload, reason=None)

Creates an invite for the given channel.

Note

This method does not handle payload. It just sends it.

Parameters:
  • channel_id (int) – Channel ID snowflake.

  • payload (dict) – Data representing the payload/invite attributes.

  • reason (Optional[str]) – Reason to show in the audit log, if any.

Returns:

An invite object.

Return type:

dict

async create_dm(recipient_id)

Creates a new DM channel with a user.

Parameters:

recipient_id (int) – User snowflake ID.

Returns:

Returns a dictionary representing a DM Channel object.

Return type:

dict

async create_guild_ban(guild_id, user_id, delete_message_seconds=0, reason=None)

Bans a person from the guild, and optionally deletes previous messages sent by them.

Parameters:
  • guild_id (int) – Guild ID snowflake

  • user_id (int) – User ID snowflake

  • delete_message_seconds (Optional[int]) – Number of seconds to delete messages for, between 0 and 604800. Default to 0

  • reason (Optional[str]) – Optional reason to ban.

async create_guild_emoji(guild_id, payload, reason=None)

Creates an emoji.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • payload (dict) – Emoji parameters.

  • reason (Optional[str]) – Optionally, give a reason.

Returns:

An emoji object with the included parameters.

Return type:

dict

async create_guild_from_guild_template(template_code, name, icon=None)

Create a new guild based on a template.

Note

This endpoint can only be used by bots in less than 10 guilds.

Parameters:
  • template_code (str) – The code of the template to use.

  • name (str) – The name of the guild (2-100 characters)

  • icon (Optional[str]) – Guild icon URI, if given.

Returns:

The newly created guild object.

Return type:

dict

async create_guild_kick(guild_id, user_id, reason=None)

Kicks a person from the guild.

Parameters:
  • guild_id (int) – Guild ID snowflake

  • user_id (int) – User ID snowflake

  • reason (Optional[str]) – Optional Reason argument.

async create_guild_role(guild_id, payload, reason=None)

Create a new role for the guild.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • payload (dict) – A dict containing metadata for the role.

  • reason (Optional[str]) – The reason for this action, if given.

Returns:

Role object

Return type:

dict

async create_guild_sticker(payload, file, guild_id, reason=None)

Create a new sticker for the guild. Requires the MANAGE_EMOJIS_AND_STICKERS permission.

Parameters:
  • payload (dict) – The payload to send.

  • file (File) – The file to send.

  • guild_id (int) – The guild to create sticker at.

  • reason (Optional[str]) – The reason for this action.

Returns:

The new sticker data on success.

Return type:

dict

async create_guild_template(guild_id, name, description=None)

Create a guild template for the guild.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • name (str) – The name of the template

  • description (Optional[str]) – The description of the template, if given.

Returns:

The created guild template

Return type:

dict

async create_interaction_response(token, application_id, data, files=None)

Posts initial response to an interaction, but you need to add the token.

Parameters:
  • token (str) – Token.

  • application_id (int) – Application ID snowflake

  • data (dict) – The data to send.

  • files (Optional[List[File]]) – The files to send.

async create_message(payload, channel_id, files=<interactions.MISSING>)

Send a message to the specified channel.

Parameters:
  • payload (dict) – Dictionary contents of a message. (i.e. message payload)

  • channel_id (int) – Channel snowflake ID.

  • files (Optional[List[File]]) – An optional list of files to send attached to the message.

Return dict:

Dictionary representing a message (?)

Return type:

dict

async create_reaction(channel_id, message_id, emoji)

Create a reaction for a message.

Parameters:
  • channel_id (int) – Channel snowflake ID.

  • message_id (int) – Message snowflake ID.

  • emoji (str) – The emoji to use (format: name:id)

async create_scheduled_event(guild_id, payload)

Creates a scheduled event.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • payload (dict) – The dictionary containing the parameters and values to edit the associated event.

Returns:

A dictionary containing the new guild scheduled event object on success.

Return type:

dict

async create_stage_instance(channel_id, topic, privacy_level=1, reason=None)

Create a new stage instance.

Parameters:
  • channel_id (int) – Channel ID snowflake.

  • topic (str) – The topic of the stage instance. Limited to 1-120 characters.

  • privacy_level (int) – The privacy_level of the stage instance (defaults to guild-only “1”).

  • reason (Optional[str]) – The reason for the creating the stage instance, if any.

Returns:

The new stage instance

Return type:

dict

async create_tag(channel_id, name, moderated=False, emoji_id=None, emoji_name=None, reason=None)

Create a new tag.

Note

Can either have an emoji_id or an emoji_name, but not both. emoji_id is meant for custom emojis, emoji_name is meant for unicode emojis.

Parameters:
  • channel_id (int) – Channel ID snowflake.

  • name (str) – The name of the tag

  • moderated (bool) – Whether the tag can only be assigned to moderators or not. Defaults to False

  • emoji_id (Optional[int]) – The ID of the emoji to use for the tag

  • emoji_name (Optional[str]) – The name of the emoji to use for the tag

  • reason (Optional[str]) – The reason for the creating the tag, if any.

Returns:

A Forum tag.

Return type:

dict

async create_thread(channel_id, name, thread_type=None, auto_archive_duration=None, invitable=None, message_id=None, reason=None)

From a given channel, create a Thread with an optional message to start with.

Parameters:
  • channel_id (int) – The ID of the channel to create this thread in

  • name (str) – The name of the thread

  • auto_archive_duration (Optional[int]) – duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080

  • thread_type (Optional[int]) – The type of thread, defaults to public. ignored if creating thread from a message

  • invitable (Optional[bool]) – Boolean to display if the Thread is open to join or private.

  • message_id (Optional[int]) – An optional message to create a thread from.

  • reason (Optional[str]) – An optional reason for the audit log

Returns:

The created thread

Return type:

dict

async create_thread_in_forum(channel_id, name, auto_archive_duration, message, applied_tags=None, files=<interactions.MISSING>, rate_limit_per_user=None, reason=None)

From a given Forum channel, create a Thread with a message to start with.

Parameters:
  • channel_id (int) – The ID of the channel to create this thread in

  • name (str) – The name of the thread

  • auto_archive_duration (int) – duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080

  • message (dict) – The payload/dictionary contents of the first message in the forum thread.

  • applied_tags (Optional[List[str]]) – List of tag ids that can be applied to the forum, if any.

  • files (Optional[List[File]]) – An optional list of files to send attached to the message.

  • rate_limit_per_user (Optional[int]) – Seconds a user has to wait before sending another message (0 to 21600), if given.

  • reason (Optional[str]) – An optional reason for the audit log

Returns:

Returns a Thread in a Forum object with a starting Message.

Return type:

dict

async create_webhook(channel_id, name, avatar=None)

Create a new webhook.

Parameters:
  • channel_id (int) – Channel ID snowflake.

  • name (str) – Name of the webhook (1-80 characters)

  • avatar (Optional[str]) – The image for the default webhook avatar, if given.

Returns:

Webhook object

Return type:

dict

async delete_application_command(application_id, command_id, guild_id=None)

Deletes an application command.

Parameters:
  • application_id (Union[int, Snowflake]) – Application ID snowflake.

  • command_id (int) – Application command ID snowflake.

  • guild_id (Optional[int]) – Guild ID snowflake, if declared. Defaults to None (Global).

async delete_auto_moderation_rule(guild_id, rule_id, reason=None)

Deletes an AutoMod rule. :param guild_id: Guild ID snowflake. :param rule_id: Rule ID snowflake. :param reason: Reason to send to audit log, if any.

async delete_channel(channel_id)

Deletes a channel.

Parameters:

channel_id (int) – Channel ID snowflake

async delete_channel_permission(channel_id, overwrite_id, reason=None)

Deletes a channel permission overwrite for a user or role in a channel.

Parameters:
  • channel_id (int) – Channel ID snowflake.

  • overwrite_id (int) – The ID of the overridden object.

  • reason (Optional[str]) – Reason to display in the Audit Log, if given.

async delete_guild(guild_id)

Deletes a guild.

Parameters:

guild_id (int) – Guild ID snowflake.

async delete_guild_emoji(guild_id, emoji_id, reason=None)

Deletes an emoji.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • emoji_id (int) – Emoji ID snowflake

  • reason (Optional[str]) – Optionally, give a reason.

async delete_guild_integration(guild_id, integration_id)

Deletes an integration from the guild.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • integration_id (int) – Integration ID snowflake.

async delete_guild_role(guild_id, role_id, reason=None)

Delete a guild role.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • role_id (int) – Role ID snowflake.

  • reason (Optional[str]) – The reason for this action, if any.

async delete_guild_sticker(guild_id, sticker_id, reason=None)

Delete the given sticker. Requires the MANAGE_EMOJIS_AND_STICKERS permission.

Parameters:
  • guild_id (int) – The guild of the target sticker.

  • sticker_id (int) – The sticker to delete.

  • reason (Optional[str]) – The reason for this action.

Returns:

Returns 204 No Content on success.

Return type:

None

async delete_guild_template(guild_id, template_code)

Delete the guild template.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • template_code (str) – Template ID.

Returns:

The deleted template object

Return type:

dict

async delete_interaction_response(token, application_id, message_id='@original')

Deletes an existing interaction message.

Parameters:
  • token (str) – the token of the interaction

  • application_id (str) – Application ID snowflake.

  • message_id (int) – Message ID snowflake. Defaults to @original which represents the initial response msg.

async delete_invite(invite_code, reason=None)

Delete an invite.

Parameters:
  • invite_code (str) – The code of the invite to delete.

  • reason (Optional[str]) – Reason to show in the audit log, if any.

Returns:

The deleted invite object.

Return type:

dict

async delete_message(channel_id, message_id, reason=None)

Deletes a message from a specified channel.

Parameters:
  • channel_id (int) – Channel snowflake ID.

  • message_id (int) – Message snowflake ID.

  • reason (Optional[str]) – Optional reason to show up in the audit log. Defaults to None.

async delete_messages(channel_id, message_ids, reason=None)

Deletes messages from a specified channel.

Parameters:
  • channel_id (int) – Channel snowflake ID.

  • message_ids (List[int]) – An array of message snowflake IDs.

  • reason (Optional[str]) – Optional reason to show up in the audit log. Defaults to None.

async delete_original_webhook_message(webhook_id, webhook_token)

Deletes the original message object sent.

Parameters:
  • webhook_id (int) – Webhook ID snowflake.

  • webhook_token (str) – Webhook token.

async delete_scheduled_event(guild_id, guild_scheduled_event_id)

Deletes a guild scheduled event.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • guild_scheduled_event_id (int) – Guild Scheduled Event ID snowflake.

Returns:

Nothing on success.

Return type:

None

async delete_stage_instance(channel_id, reason=None)

Delete a stage instance.

Parameters:
  • channel_id (int) – Channel ID snowflake.

  • reason (Optional[str]) – The reason for the creating the stage instance, if any.

async delete_tag(channel_id, tag_id, reason=None)

Delete a forum tag.

Parameters:
  • channel_id (int) – Channel ID snowflake.

  • tag_id (int) – The ID of the tag to delete

  • reason (Optional[str]) – The reason for deleting the tag, if any.

async delete_webhook(webhook_id, webhook_token=None)

Delete a webhook.

Parameters:
  • webhook_id (int) – Webhook ID snowflake.

  • webhook_token (Optional[str]) – The token for the webhook, if given.

async delete_webhook_message(webhook_id, webhook_token, message_id)

Deletes a message object.

Parameters:
  • webhook_id (int) – Webhook ID snowflake.

  • webhook_token (str) – Webhook token.

  • message_id (int) – Message ID snowflake.

async edit_application_command(application_id, data, command_id, guild_id=None)

Edits an application command.

Parameters:
  • application_id (Union[int, Snowflake]) – Application ID snowflake.

  • data (dict) – A dictionary containing updated attributes

  • command_id (Union[int, Snowflake]) – The application command ID snowflake

  • guild_id (Optional[int]) – Guild ID snowflake, if given. Defaults to None/global.

Returns:

The updated application command object.

Return type:

dict

async edit_application_command_permissions(application_id, guild_id, command_id, data)

Edits permissions for an application command.

Note

This requires authenticating with the Bearer token. Likewise, if this function is used in a bot process with a bot token, this will fail.

Parameters:
  • application_id (int) – Application ID snowflake

  • guild_id (int) – Guild ID snowflake

  • command_id (int) – Application command ID snowflake

  • data (List[dict]) – Permission data.

Returns:

Returns an updated Application Guild permission object.

Return type:

dict

async edit_channel_permission(channel_id, overwrite_id, allow, deny, perm_type, reason=None)

Edits the channel’s permission overwrites for a user or role in a given channel.

Parameters:
  • channel_id (int) – Channel ID snowflake.

  • overwrite_id (int) – The ID of the overridden object.

  • allow (str) – the bitwise value of all allowed permissions

  • deny (str) – the bitwise value of all disallowed permissions

  • perm_type (int) – 0 for a role or 1 for a member

  • reason (Optional[str]) – Reason to display in the Audit Log, if given.

async edit_interaction_response(data, token, application_id, files=None, message_id='@original')

Edits an existing interaction message, but token needs to be manually called.

Parameters:
  • data (dict) – A dictionary containing the new response.

  • token (str) – the token of the interaction

  • application_id (str) – Application ID snowflake.

  • files (Optional[List[File]]) – The files to send.

  • message_id (str) – Message ID snowflake. Defaults to @original which represents the initial response msg.

Returns:

Updated message data.

Return type:

dict

async edit_message(channel_id, message_id, payload, files=<interactions.MISSING>)

Edits a message that already exists.

Parameters:
  • channel_id (int) – Channel snowflake ID.

  • message_id (int) – Message snowflake ID.

  • payload (dict) – Any new data that needs to be changed.

  • files (Optional[List[File]]) – An optional list of files to send attached to the message.

Returns:

A message object with edited attributes.

Return type:

dict

async edit_tag(channel_id, tag_id, name, moderated=None, emoji_id=None, emoji_name=None, reason=None)

Update a tag.

Note

Can either have an emoji_id or an emoji_name, but not both. emoji_id is meant for custom emojis, emoji_name is meant for unicode emojis.

The object returns will have a different tag ID.

Parameters:
  • channel_id (int) – Channel ID snowflake.

  • tag_id (int) – The ID of the tag to update.

  • moderated (Optional[bool]) – Whether the tag can only be assigned to moderators or not. Defaults to False

  • name (str) – The new name of the tag

  • emoji_id (Optional[int]) – The ID of the emoji to use for the tag

  • emoji_name (Optional[str]) – The name of the emoji to use for the tag

  • reason (Optional[str]) – The reason for deleting the tag, if any.

Return type:

dict

:return The updated tag object.

async edit_webhook_message(webhook_id, webhook_token, message_id, data)

Edits a message sent from a Webhook.

Parameters:
  • webhook_id (int) – Webhook ID snowflake.

  • webhook_token (str) – Webhook token.

  • message_id (int) – Message ID snowflake.

  • data (dict) – A payload consisting of new message attributes.

Returns:

An updated message object.

Return type:

dict

async execute_github_webhook(webhook_id, webhook_token, payload)

Sends a message to a Github-compatible webhook.

Parameters:
  • webhook_id (int) – Webhook ID snowflake.

  • webhook_token (str) – The token for the webhook.

  • payload (dict) – Payload consisting of the message.

Returns:

?

Return type:

None

Note

Payload structure is different than Discord’s. See here <https://discord.com/developers/docs/resources/webhook#execute-githubcompatible-webhook>_ for more details.

async execute_slack_webhook(webhook_id, webhook_token, payload)

Sends a message to a Slack-compatible webhook.

Parameters:
  • webhook_id (int) – Webhook ID snowflake.

  • webhook_token (str) – The token for the webhook.

  • payload (dict) – Payload consisting of the message.

Returns:

?

Return type:

None

Note

Payload structure is different than Discord’s. See here <https://api.slack.com/messaging/webhooks>_ for more details.

async execute_webhook(webhook_id, webhook_token, payload, files=<interactions.MISSING>, wait=False, thread_id=None)

Sends a message as a webhook.

Parameters:
  • webhook_id (int) – Webhook ID snowflake.

  • webhook_token (str) – The token for the webhook.

  • payload (dict) – Payload consisting of the message.

  • files (Optional[List[File]]) – The files to upload to the message.

  • wait (Optional[bool]) – A bool that signifies waiting for server confirmation of a send before responding.

  • thread_id (Optional[int]) – Optional, sends a message to the specified thread.

Returns:

The message sent, if wait=True, else None.

Return type:

Optional[dict]

async get_all_application_command_permissions(application_id, guild_id)

Gets, from the Discord API, permissions from all Application commands at that Guild.

Parameters:
  • application_id (int) – Application ID snowflake

  • guild_id (int) – Guild ID snowflake

Returns:

An array of Guild Application Command permissions

Return type:

List[dict]

async get_all_channels(guild_id)

Requests from the API to get all channels in the guild.

Parameters:

guild_id (int) – Guild Snowflake ID

Returns:

A list of channels.

Return type:

List[dict]

async get_all_emoji(guild_id)

Gets all emojis from a guild.

Parameters:

guild_id (int) – Guild ID snowflake.

Returns:

A list of emojis.

Return type:

List[dict]

async get_all_roles(guild_id)

Gets all roles from a Guild.

Parameters:

guild_id (int) – Guild ID snowflake

Returns:

An array of Role objects as dictionaries.

Return type:

List[dict]

async get_application_command_permissions(application_id, guild_id, command_id)

Gets, from the Discord API, permissions from a specific Guild application command.

Parameters:
  • application_id (int) – Application ID snowflake

  • guild_id (int) – Guild ID snowflake

  • command_id (int) – Application Command ID snowflake

Returns:

a Guild Application Command permissions object

Return type:

dict

async get_application_commands(application_id, guild_id=None, with_localizations=None)

Get all application commands from an application.

Parameters:
  • application_id (Union[int, Snowflake]) – Application ID snowflake

  • guild_id (Optional[int]) – Guild to get commands from, if specified. Defaults to global (None)

  • with_localizations (Optional[bool]) – Whether to include full localization dictionaries (name_localizations and description_localizations) in the returned objects, instead of the name_localized and description_localized fields. Default false.

Returns:

A list of Application commands.

Return type:

List[dict]

async get_auto_moderation_rule(guild_id, rule_id)

Get a single AutoMod rule in a guild. :param guild_id: Guild ID snowflake. :param rule_id: Rule ID snowflake. :return: A dictionary containing the automod rule.

Return type:

dict

async get_channel(channel_id)

Gets a channel by ID. If the channel is a thread, it also includes thread members (and other thread attributes).

Parameters:

channel_id (int) – Channel ID snowflake.

Returns:

Dictionary of the channel object.

Return type:

dict

async get_channel_invites(channel_id)

Get the invites for the channel.

Parameters:

channel_id (int) – Channel ID snowflake.

Returns:

List of invite objects

Return type:

List[dict]

async get_channel_messages(channel_id, limit=50, around=None, before=None, after=None)

Get messages from a channel.

Note

around, before, and after arguments are mutually exclusive.

Parameters:
  • channel_id (int) – Channel ID snowflake.

  • limit (int) – How many messages to get. Defaults to 50, the max is 100.

  • around (Optional[int]) – Get messages around this snowflake ID.

  • before (Optional[int]) – Get messages before this snowflake ID.

  • after (Optional[int]) – Get messages after this snowflake ID.

Returns:

An array of Message objects.

Return type:

List[dict]

async get_channel_webhooks(channel_id)

Return a list of channel webhook objects.

Parameters:

channel_id (int) – Channel ID snowflake.

Returns:

List of webhook objects

Return type:

List[dict]

async get_current_authorisation_information()[source]

Returns info about the current authorization of the bot user

Return type:

dict

async get_guild(guild_id, with_counts=False)

Requests an individual guild from the API.

Parameters:
  • guild_id (int) – The guild snowflake ID associated.

  • with_counts (bool) – Whether the approximate member count should be included

Returns:

The guild object associated, if any.

Return type:

dict

async get_guild_auditlog(guild_id, user_id=None, action_type=None, before=None, limit=50)

Returns an audit log object for the guild. Requires the ‘VIEW_AUDIT_LOG’ permission. :param guild_id: Guild ID snowflake. :param user_id: User ID snowflake. filter the log for actions made by a user. :param action_type: the type ID of audit log event. :param before: filter the log before a certain entry id. :param limit: how many entries are returned (default 50, minimum 1, maximum 100)

Return type:

dict

async get_guild_bans(guild_id, limit=1000, before=None, after=None)

Gets a list of banned users.

Note

If both before and after are provided, only before is respected.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • limit (Optional[int]) – Number of users to return. Defaults to 1000.

  • before (Optional[int]) – Consider only users before the given User ID snowflake.

  • after (Optional[int]) – Consider only users after the given User ID snowflake.

Returns:

A list of banned users.

Return type:

List[dict]

async get_guild_emoji(guild_id, emoji_id)

Gets an emote from a guild.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • emoji_id (int) – Emoji ID snowflake.

Returns:

Emoji object

Return type:

dict

async get_guild_integrations(guild_id)

Gets a list of integration objects associated with the Guild from the API.

Parameters:

guild_id (int) – Guild ID snowflake.

Returns:

An array of integration objects

Return type:

List[dict]

async get_guild_invites(guild_id)

Retrieves a list of invite objects with their own metadata.

Parameters:

guild_id (int) – Guild ID snowflake.

Returns:

A list of invite objects

Return type:

List[dict]

async get_guild_preview(guild_id)

Get a guild’s preview.

Parameters:

guild_id (int) – Guild ID snowflake.

Returns:

Guild Preview object associated with the snowflake

Return type:

dict

async get_guild_prune_count(guild_id, days=7, include_roles=None)

Retrieves a dict from an API that results in how many members would be pruned given the amount of days.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • days (int) – Number of days to count, minimum 1, maximum 30. Defaults to 7.

  • include_roles (Optional[List[int]]) – Role IDs to include, if given.

Returns:

A dict denoting {“pruned”: int}

Return type:

dict

async get_guild_sticker(guild_id, sticker_id)

Get a sticker from a guild.

Parameters:
  • guild_id (int) – The guild to get stickers from

  • sticker_id (int) – The sticker to get from the guild

Returns:

Sticker or None

Return type:

dict

async get_guild_template(template_code)

New in version 4.4.0.

Returns a guild template.

Parameters:

template_code (str) – The code for the template to get

Returns:

A guild template

Return type:

dict

async get_guild_templates(guild_id)

Returns an array of guild templates.

Parameters:

guild_id (int) – Guild ID snowflake.

Returns:

An array of guild templates

Return type:

List[dict]

async get_guild_webhooks(guild_id)

Return a list of guild webhook objects.

Parameters:

guild_id (int) – Guild ID snowflake

Returns:

List of webhook objects

Return type:

List[dict]

async get_guild_welcome_screen(guild_id)

Retrieves from the API a welcome screen associated with the guild.

Parameters:

guild_id (int) – Guild ID snowflake.

Returns:

Welcome Screen object

Return type:

dict

async get_guild_widget(guild_id)

Returns the widget for the guild.

Parameters:

guild_id (int) – Guild ID snowflake.

Returns:

Guild Widget contents as a dict: {“enabled”:bool, “channel_id”: str}

Return type:

dict

async get_guild_widget_image(guild_id, style=None)

Get an url representing a png image widget for the guild.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • style (Optional[str]) – The style of widget required, if given.

Returns:

A url pointing to this image

Return type:

str

async get_guild_widget_settings(guild_id)

Get guild widget settings.

Parameters:

guild_id (int) – Guild ID snowflake.

Returns:

Guild Widget contents as a dict: {“enabled”:bool, “channel_id”: str}

Return type:

dict

async get_invite(invite_code, with_counts=None, with_expiration=None, guild_scheduled_event_id=None)

Gets a Discord invite using its code.

Parameters:
  • invite_code (str) – A string representing the invite code.

  • with_counts (Optional[bool]) – Whether approximate_member_count and approximate_presence_count are returned.

  • with_expiration (Optional[bool]) – Whether the invite’s expiration date is returned.

  • guild_scheduled_event_id (Optional[int]) – A guild scheduled event’s ID.

Return type:

dict

async get_list_of_members(guild_id, limit=1, after=None)

Lists the members of a guild.

Parameters:
  • guild_id (int) – Guild ID snowflake

  • limit (int) – How many members to get from the API. Max is 1000. Defaults to 1.

  • after (Optional[int]) – Get Member IDs after this snowflake. Defaults to None.

Returns:

An array of Member objects.

Return type:

List[dict]

async get_member(guild_id, member_id)

Uses the API to fetch a member from a guild.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • member_id (int) – Member ID snowflake.

Returns:

A member object, if any.

Return type:

Optional[dict]

async get_member_from_thread(thread_id, user_id)

Get a member from a thread.

Parameters:
  • thread_id (int) – The ID of the thread

  • user_id (int) – The ID of the user to find

Returns:

A thread member object, if they’re in the thread.

Return type:

dict

async get_message(channel_id, message_id)

Get a specific message in the channel.

Parameters:
  • channel_id (int) – the channel this message belongs to

  • message_id (int) – the id of the message

Returns:

message if it exists.

Return type:

Optional[dict]

async get_original_interaction_response(token, application_id, message_id='@original')

Gets an existing interaction message.

Parameters:
  • token (str) – token

  • application_id (str) – Application ID snowflake.

  • message_id (int) – Message ID snowflake. Defaults to @original which represents the initial response msg.

Returns:

Message data.

Return type:

dict

async get_pinned_messages(channel_id)

Get all pinned messages from a channel.

Parameters:

channel_id (int) – Channel ID snowflake.

Returns:

A list of pinned message objects.

Return type:

List[dict]

async get_reactions_of_emoji(channel_id, message_id, emoji, limit=25, after=None)

Gets the users who reacted to the emoji.

Parameters:
  • channel_id (int) – Channel snowflake ID.

  • message_id (int) – Message snowflake ID.

  • emoji (str) – The emoji to get (format: name:id)

  • limit (int) – Max number of users to return (1-100)

  • after (Optional[int]) – Get users after this user ID

Returns:

A list of users who sent that emoji.

Return type:

List[dict]

async get_scheduled_event(guild_id, guild_scheduled_event_id, with_user_count)

Gets a guild scheduled event.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • guild_scheduled_event_id (int) – Guild Scheduled Event ID snowflake.

  • with_user_count (bool) – Whether the number of users subscribed to the events is returned.

Returns:

A dictionary containing the guild scheduled event object on success.

Return type:

dict

async get_scheduled_event_users(guild_id, guild_scheduled_event_id, limit=100, with_member=False, before=None, after=None)

Get the registered users of a scheduled event.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • guild_scheduled_event_id (int) – Guild Scheduled Event snowflake.

  • limit (int) – Limit of how many users to pull from the event. Defaults to 100.

  • with_member (bool) – Include guild member data if it exists. Defaults to False.

  • before (Optional[int]) – Considers only users before given user ID snowflake. Defaults to None.

  • after (Optional[int]) – Considers only users after given user ID snowflake. Defaults to None.

Returns:

Returns a list of guild scheduled event user objects on success.

Return type:

dict

async get_scheduled_events(guild_id, with_user_count)

Gets all guild scheduled events in a guild.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • with_user_count (bool) – Whether the number of users subscribed to the associated event is returned.

Returns:

A List of a dictionary containing the guild scheduled event objects on success.

Return type:

List[dict]

async get_self()

An alias to get_user, but only gets the current bot user.

Returns:

A partial User object of the current bot user in the form of a dictionary.

Return type:

dict

async get_self_guilds(limit=200, before=None, after=None)

Gets all guild objects associated with the current bot user.

Parameters:
  • limit (Optional[int]) – Number of guilds to return. Defaults to 200.

  • before (Optional[int]) – Consider only users before the given Guild ID snowflake.

  • after (Optional[int]) – Consider only users after the given Guild ID snowflake.

Returns:

A list of partial guild objects the current bot user is a part of.

Return type:

List[dict]

async get_stage_instance(channel_id)

Get the stage instance associated with a given channel, if it exists.

Parameters:

channel_id (int) – Channel ID snowflake.

Returns:

A stage instance.

Return type:

dict

async get_sticker(sticker_id)

Get a specific sticker.

Parameters:

sticker_id (int) – The id of the sticker

Returns:

Sticker or None

Return type:

dict

async get_user(user_id=None)

Gets a user object for a given user ID.

Parameters:

user_id (Optional[int]) – A user snowflake ID. If omitted, this defaults to the current bot user.

Returns:

A partial User object in the form of a dictionary.

Return type:

dict

async get_user_ban(guild_id, user_id)

Gets an object pertaining to the user, if it exists. Returns a 404 if it doesn’t.

Parameters:
  • guild_id (int) – Guild ID snowflake

  • user_id (int) – User ID snowflake.

Returns:

Ban object if it exists.

Return type:

Optional[dict]

async get_webhook(webhook_id, webhook_token=None)

Return the new webhook object for the given id.

Parameters:
  • webhook_id (int) – Webhook ID snowflake.

  • webhook_token (Optional[str]) – Webhook Token, if given.

Return type:

dict

:return:Webhook object

async get_webhook_message(webhook_id, webhook_token, message_id)

Retrieves a message sent from a Webhook.

Parameters:
  • webhook_id (int) – Webhook ID snowflake.

  • webhook_token (str) – Webhook token.

  • message_id (int) – Message ID snowflake,

Returns:

A Message object.

Return type:

dict

async join_thread(thread_id)

Have the bot user join a thread.

Parameters:

thread_id (int) – The thread to join.

async leave_guild(guild_id)

Leaves a guild.

Parameters:

guild_id (int) – The guild snowflake ID associated.

Returns:

None

Return type:

None

async leave_thread(thread_id)

Have the bot user leave a thread.

Parameters:

thread_id (int) – The thread to leave.

async list_active_threads(guild_id)

List active threads within a guild.

Parameters:

guild_id (int) – the guild id to get threads from

Returns:

A list of active threads

Return type:

Dict[str, List[dict]]

async list_auto_moderation_rules(guild_id)

Returns a list of all AutoMod rules in a guild. :poram guild_id: Guild ID snowflake. :return: A list of dictionaries containing the automod rules.

Return type:

List[dict]

async list_guild_stickers(guild_id)

Get the stickers for a guild.

Parameters:

guild_id (int) – The guild to get stickers from

Returns:

List of Stickers or None

Return type:

List[dict]

async list_joined_private_archived_threads(channel_id, limit=None, before=None)

Get a list of archived private threads in a channel that the bot has joined.

Parameters:
  • channel_id (int) – The channel to get threads from

  • limit (Optional[int]) – Optional limit of threads to

  • before (Optional[int]) – Get threads before this snowflake ID

Returns:

a list of threads

Return type:

List[dict]

async list_nitro_sticker_packs()

Gets the list of sticker packs available to Nitro subscribers.

Returns:

List of sticker packs

Return type:

List[dict]

async list_private_archived_threads(channel_id, limit=None, before=None)

Get a list of archived private threads in a channel.

Parameters:
  • channel_id (int) – The channel to get threads from

  • limit (Optional[int]) – Optional limit of threads to

  • before (Optional[int]) – Get threads before this Thread snowflake ID

Returns:

a list of threads

Return type:

List[dict]

async list_public_archived_threads(channel_id, limit=None, before=None)

Get a list of archived public threads in a given channel.

Parameters:
  • channel_id (int) – The channel to get threads from

  • limit (Optional[int]) – Optional limit of threads to

  • before (Optional[int]) – Get threads before this Thread snowflake ID

Returns:

a list of threads

Return type:

List[dict]

async list_thread_members(thread_id)

Get a list of members in the thread.

Parameters:

thread_id (int) – the id of the thread

Returns:

a list of thread member objects

Return type:

List[dict]

async modify_auto_moderation_rule(guild_id, rule_id, name=None, event_type=None, trigger_metadata=None, actions=None, enabled=None, exempt_roles=None, exempt_channels=None, reason=None)

Modify an existing AutoMod rule in a guild.

Note

All parameters besides guild and rule ID are optional.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • rule_id (int) – Rule ID snowflake.

  • name (Optional[str]) – The new name of the rule.

  • event_type (Optional[int]) – The new event type of the rule.

  • trigger_metadata (Optional[dict]) – The new trigger metadata payload representation. This can be omitted based on the trigger type.

  • actions (Optional[List[dict]]) – The new actions that will execute when the rule is triggered.

  • enabled (Optional[bool]) – Whether the rule will be enabled upon creation.

  • exempt_roles (Optional[List[str]]) – The role IDs that are whitelisted by the rule, if given. The maximum is 20.

  • exempt_channels (Optional[List[str]]) – The channel IDs that are whitelisted by the rule, if given. The maximum is 20

  • reason (Optional[str]) – Reason to send to audit log, if any.

Returns:

A dictionary containing the updated automod rule.

Return type:

dict

async modify_channel(channel_id, payload, reason=None)

Update a channel’s settings.

Parameters:
  • channel_id (int) – Channel ID snowflake.

  • payload (dict) – Data representing updated settings.

  • reason (Optional[str]) – Reason, if any.

Returns:

Channel with updated attributes, if successful.

Return type:

dict

async modify_current_user_voice_state(guild_id, channel_id, suppress=None, request_to_speak_timestamp=None)

Update the current user voice state.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • channel_id (int) – Voice channel ID snowflake.

  • suppress (Optional[bool]) – Toggle the user’s suppress state, if given.

  • request_to_speak_timestamp (Optional[str]) – Sets the user’s request to speak, if given.

async modify_guild(guild_id, payload, reason=None)

Modifies a guild’s attributes.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • payload (dict) – The parameters to change.

  • reason (Optional[str]) – Reason to send to the audit log, if given.

Returns:

The modified guild object as a dictionary

Return type:

dict

async modify_guild_emoji(guild_id, emoji_id, payload, reason=None)

Modifies an emoji.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • emoji_id (int) – Emoji ID snowflake

  • payload (dict) – Emoji parameters with updated attributes

  • reason (Optional[str]) – Optionally, give a reason.

Returns:

An emoji object with updated attributes.

Return type:

dict

async modify_guild_role(guild_id, role_id, payload, reason=None)

Modify a given role for the guild.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • role_id (int) – Role ID snowflake.

  • payload (dict) – A dict containing updated metadata for the role.

  • reason (Optional[str]) – The reason for this action, if given.

Returns:

Updated role object.

Return type:

dict

async modify_guild_role_positions(guild_id, payload, reason=None)

Modify the position of a role in the guild.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • payload (List[dict]) – A list of dicts containing the role IDs and new positions for all the roles to be moved.

  • reason (Optional[str]) – The reason for this action, if given.

Returns:

List of guild roles with updated hierarchy.

Return type:

List[dict]

async modify_guild_sticker(payload, guild_id, sticker_id, reason=None)

Modify the given sticker. Requires the MANAGE_EMOJIS_AND_STICKERS permission.

Parameters:
  • payload (dict) – the payload to send.

  • guild_id (int) – The guild of the target sticker.

  • sticker_id (int) – The sticker to modify.

  • reason (Optional[str]) – The reason for this action.

Returns:

The updated sticker data on success.

Return type:

dict

async modify_guild_template(guild_id, template_code, name=None, description=None)

Modify a guild template.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • template_code (str) – Template ID.

  • name (Optional[str]) – The name of the template

  • description (Optional[str]) – The description of the template

Returns:

The updated guild template

Return type:

dict

async modify_guild_welcome_screen(guild_id, enabled, welcome_channels, description)

Modify the guild’s welcome screen.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • enabled (bool) – Whether the welcome screen is enabled or not.

  • welcome_channels (List[int]) – The new channels (by their ID) linked in the welcome screen and their display options

  • description (str) – The new server description to show in the welcome screen

Returns:

Updated Welcome screen object.

Return type:

dict

async modify_guild_widget(guild_id, payload)

Modify a guild widget.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • payload (dict) – Payload containing new widget attributes.

Returns:

Updated widget attributes.

Return type:

dict

async modify_member(user_id, guild_id, payload, reason=None)

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 (int) – Member ID snowflake.

  • guild_id (int) – Guild ID snowflake.

  • payload (dict) – Payload representing parameters (nick, roles, mute, deaf, channel_id)

  • reason (Optional[str]) – The reason for this action. Defaults to None.

Returns:

Modified member object.

Return type:

dict

async modify_scheduled_event(guild_id, guild_scheduled_event_id, payload)

Modifies a scheduled event.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • guild_scheduled_event_id (int) – Guild Scheduled Event ID snowflake.

  • payload (dict) – The dictionary containing the parameters and values to edit the associated event.

Returns:

A dictionary containing the updated guild scheduled event object on success.

Return type:

dict

async modify_self(payload)

Modify the bot user account settings.

Parameters:

payload (dict) – The data to send.

Return type:

dict

async modify_self_nick_in_guild(guild_id, nickname)

Changes a nickname of the current bot user in a guild.

Parameters:
  • guild_id (int) – Guild snowflake ID.

  • nickname (Optional[str]) – The new nickname, if any.

Returns:

Nothing needed to be yielded.

Return type:

dict

async modify_stage_instance(channel_id, topic=None, privacy_level=None, reason=None)

Update the fields of a given stage instance.

Parameters:
  • channel_id (int) – Channel ID snowflake.

  • topic (Optional[str]) – The new topic of the stage instance, if given. Limited to 1-120 characters.

  • privacy_level (Optional[int]) – The new privacy_level of the stage instance.

  • reason (Optional[str]) – The reason for the creating the stage instance, if any.

Returns:

The updated stage instance.

Return type:

dict

async modify_user_voice_state(guild_id, user_id, channel_id, suppress=None)

Modify the voice state of a user.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • user_id (int) – User ID snowflake.

  • channel_id (int) – Voice channel ID snowflake.

  • suppress (Optional[bool]) – Toggles the user’s suppress state, if given.

async modify_webhook(webhook_id, payload, webhook_token=None)

Modify a webhook.

Parameters:
  • webhook_id (int) – Webhook ID snowflake

  • payload (dict) – The payload for the webhook

  • webhook_token (Optional[str]) – The token for the webhook, if given.

Returns:

Modified webhook object.

Return type:

dict

async move_channel(guild_id, channel_id, new_pos, parent_id, lock_perms=False, reason=None)

Moves a channel to a new position.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • channel_id (int) – Channel ID snowflake.

  • new_pos (int) – The new channel position.

  • parent_id (Optional[int]) – The category parent ID, if needed.

  • lock_perms (bool) – Sync permissions with the parent associated with parent_id. Defaults to False.

  • reason (Optional[str]) – Reason to display to the audit log, if any.

Returns:

?

Return type:

dict

async overwrite_application_command(application_id, data, guild_id=None)

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 (int) – Application ID snowflake

  • data (List[dict]) – The dictionary that contains the command (name, description, etc)

  • guild_id (Optional[int]) – Guild ID snowflake to put them in, if applicable.

Returns:

An array of application command objects.

Return type:

List[dict]

async pin_message(channel_id, message_id)

Pin a message to a channel.

Parameters:
  • channel_id (int) – Channel ID snowflake.

  • message_id (int) – Message ID snowflake.

async publish_message(channel_id, message_id)

Publishes (API calls it crossposts) a message in a News channel to any that is followed by.

Parameters:
  • channel_id (int) – Channel the message is in

  • message_id (int) – The id of the message to publish

Returns:

message object

Return type:

dict

async remove_all_reactions(channel_id, message_id)

Remove all reactions from a message.

Parameters:
  • channel_id (int) – The channel this is taking place in.

  • message_id (int) – The message to clear reactions from.

async remove_all_reactions_of_emoji(channel_id, message_id, emoji)

Remove all reactions of a certain emoji from a message.

Parameters:
  • channel_id (int) – Channel snowflake ID.

  • message_id (int) – Message snowflake ID.

  • emoji (str) – The emoji to remove (format: name:id)

async remove_guild_ban(guild_id, user_id, reason=None)

Unbans someone using the API.

Parameters:
  • guild_id (int) – Guild ID snowflake

  • user_id (int) – User ID snowflake

  • reason (Optional[str]) – Optional reason to unban.

async remove_guild_member(guild_id, user_id, reason=None)

A low level method of removing a member from a guild. This is different from banning them.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • user_id (int) – User ID snowflake.

  • reason (Optional[str]) – Reason to send to audit log, if any.

async remove_member_from_thread(thread_id, user_id)

Remove another user from a thread.

Parameters:
  • thread_id (int) – The ID of the thread

  • user_id (int) – The ID of the user to remove

async remove_member_role(guild_id, user_id, role_id, reason=None)

Removes a role to a guild member.

Parameters:
  • guild_id (int) – The ID of the guild

  • user_id (int) – The ID of the user

  • role_id (int) – The ID of the role to add

  • reason (Optional[str]) – The reason for this action. Defaults to None.

async remove_self_reaction(channel_id, message_id, emoji)

Remove bot user’s reaction from a message.

Parameters:
  • channel_id (int) – Channel snowflake ID.

  • message_id (int) – Message snowflake ID.

  • emoji (str) – The emoji to remove (format: name:id)

async remove_user_reaction(channel_id, message_id, emoji, user_id)

Remove user’s reaction from a message.

Parameters:
  • channel_id (int) – The channel this is taking place in

  • message_id (int) – The message to remove the reaction on.

  • emoji (str) – The emoji to remove. (format: name:id)

  • user_id (int) – The user to remove reaction of.

async search_guild_members(guild_id, query, limit=1)

Search a guild for members whose username or nickname starts with provided string.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • query (str) – The string to search for

  • limit (int) – The number of members to return. Defaults to 1.

Return type:

List[dict]

async send_message(channel_id, content, tts=False, embeds=None, nonce=None, allowed_mentions=None, message_reference=None, stickers=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

Return type:

dict

async sync_guild_template(guild_id, template_code)

Sync the template to the guild’s current state.

Parameters:
  • guild_id (int) – Guild ID snowflake.

  • template_code (str) – The code for the template to sync

Returns:

The updated guild template.

Return type:

dict

async trigger_typing(channel_id)

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 (int) – Channel ID snowflake.

async unpin_message(channel_id, message_id)

Unpin a message to a channel.

Parameters:
  • channel_id (int) – Channel ID snowflake.

  • message_id (int) – Message ID snowflake.

async get_application_role_connection_metadata(application_id)[source]

Returns a list of application role connection metadata objects for an application.

Return type:

List[dict]

async update_application_role_connection_metadata(application_id, payload)[source]

Updates and returns a list of application role connection metadata objects for an application.

Note

The maximum metadata objects supported via the API is five.

Return type:

List[dict]