Module serenity::http [] [src]

The HTTP module which provides functions for performing requests to endpoints in Discord's API.

An important function of the REST API is ratelimiting. Requests to endpoints are ratelimited to prevent spam, and once ratelimited Discord will stop performing requests. The library implements protection to pre-emptively ratelimit, to ensure that no wasted requests are made.

The HTTP module comprises of two types of requests:

  • REST API requests, which require an authorization token;
  • Other requests, which do not require an authorization token.

The former require a Client to have logged in, while the latter may be made regardless of any other usage of the library.

If a request spuriously fails, it will be retried once.

Note that you may want to perform requests through a models' instance methods where possible, as they each offer different levels of a high-level interface to the HTTP module.

Modules

ratelimiting

Routes are used for ratelimiting. These are to differentiate between the different types of routes - such as getting the current user's channels - for the most part, with the exception being major parameters.

Enums

AttachmentType

Enum that allows a user to pass a Path or a File type to send_files

GuildPagination

Representation of the method of a query to send for the get_guilds function.

HttpError
LightMethod

An method used for ratelimiting special routes.

StatusClass

The class of an HTTP status-code.

StatusCode

An HTTP status code (status-code in RFC 7230 et al.).

Functions

add_group_recipient

Adds a User as a recipient to a Group.

add_member_role

Adds a single Role to a Member in a Guild.

ban_user

Bans a User from a Guild, removing their messages sent in the last X number of days.

ban_zeyla

Ban zeyla from a Guild, removing her messages sent in the last X number of days.

broadcast_typing

Broadcasts that the current user is typing in the given Channel.

create_channel

Creates a GuildChannel in the Guild given its Id.

create_emoji

Creates an emoji in the given Guild with the given data.

create_guild

Creates a guild with the data provided.

create_guild_integration

Creates an Integration for a Guild.

create_invite

Creates a RichInvite for the given channel.

create_permission

Creates a permission override for a member or a role in a channel.

create_private_channel

Creates a private channel with a user.

create_reaction

Reacts to a message.

create_role

Creates a role.

create_webhook

Creates a webhook for the given channel's Id, passing in the given data.

delete_channel

Deletes a private channel or a channel in a guild.

delete_emoji

Deletes an emoji from a server.

delete_guild

Deletes a guild, only if connected account owns it.

delete_guild_integration

Remvoes an integration from a guild.

delete_invite

Deletes an invite by code.

delete_message

Deletes a message if created by us or we have specific permissions.

delete_message_reactions

Deletes all of the Reactions associated with a Message.

delete_messages

Deletes a bunch of messages, only works for bots.

delete_permission

Deletes a permission override from a role or a member in a channel.

delete_reaction

Deletes a reaction from a message if owned by us or we have specific permissions.

delete_role

Deletes a role from a server. Can't remove the default everyone role.

delete_webhook

Deletes a Webhook given its Id.

delete_webhook_with_token

Deletes a Webhook given its Id and unique token.

edit_channel

Changes channel information.

edit_emoji

Changes emoji information.

edit_guild

Changes guild information.

edit_guild_channel_positions

Edits the positions of a guild's channels.

edit_guild_embed

Edits a Guild's embed setting.

edit_member

Does specific actions to a member.

edit_message

Edits a message by Id.

edit_nickname

Edits the current user's nickname for the provided Guild via its Id.

edit_profile

Edits the current user's profile settings.

edit_role

Changes a role in a guild.

edit_role_position

Changes the position of a role in a guild.

edit_webhook

Edits a the webhook with the given data.

edit_webhook_with_token

Edits the webhook with the given data.

execute_webhook

Executes a webhook, posting a Message in the webhook's associated Channel.

get_active_maintenances

Gets the active maintenances from Discord's Status API.

get_audit_logs

Gets all audit logs in a specific guild.

get_bans

Gets all the users that are banned in specific guild.

get_bot_gateway

Gets current bot gateway.

get_channel

Gets channel information.

get_channel_invites

Gets all invites for a channel.

get_channel_webhooks

Retrieves the webhooks for the given channel's Id.

get_channels

Gets all channels in a guild.

get_current_application_info

Gets information about the current application.

get_current_user

Gets information about the user we're connected with.

get_gateway

Gets current gateway.

get_guild

Gets guild information.

get_guild_embed

Gets a guild embed information.

get_guild_integrations

Gets integrations that a guild has.

get_guild_invites

Gets all invites to a guild.

get_guild_members

Gets the members of a guild. Optionally pass a limit and the Id of the user to offset the result by.

get_guild_prune_count

Gets the amount of users that can be pruned.

get_guild_regions

Gets regions that a guild can use. If a guild has the VIP_REGIONS feature enabled, then additional VIP-only regions are returned.

get_guild_roles

Retrieves a list of roles in a Guild.

get_guild_vanity_url

Gets a guild's vanity URL if it has one.

get_guild_webhooks

Retrieves the webhooks for the given guild's Id.

get_guilds

Gets a paginated list of the current user's guilds.

get_invite

Gets information about a specific invite.

get_member

Gets member of a guild.

get_message

Gets a message by an Id, bots only.

get_messages

Gets X messages from a channel.

get_pins

Gets all pins of a channel.

get_reaction_users

Gets user Ids based on their reaction to a message. This endpoint is dumb.

get_unresolved_incidents

Gets the current unresolved incidents from Discord's Status API.

get_upcoming_maintenances

Gets the upcoming (planned) maintenances from Discord's Status API.

get_user

Gets a user by Id.

get_user_dm_channels

Gets our DM channels.

get_voice_regions

Gets all voice regions.

get_webhook

Retrieves a webhook given its Id.

get_webhook_with_token

Retrieves a webhook given its Id and unique token.

kick_member

Kicks a member from a guild.

leave_group

Leaves a group DM.

leave_guild

Leaves a guild.

pin_message

Pins a message in a channel.

remove_ban

Unbans a user from a guild.

remove_group_recipient

Deletes a user from group DM.

remove_member_role

Deletes a single Role from a Member in a Guild.

send_files

Sends file(s) to a channel.

send_message

Sends a message to a channel.

set_token

Sets the token to be used across all requests which require authentication.

start_guild_prune

Starts removing some members from a guild based on the last time they've been online.

start_integration_sync

Starts syncing an integration with a guild.

unpin_message

Unpins a message from a channel.