Skip to main content

Rest

Struct Rest 

Source
pub struct Rest { /* private fields */ }
Expand description

A client for the Discord REST API.

Rest handles authentication, rate limits, retries and timeouts. It is cheap to Clone — clones share the same connection pool and rate-limit state, so create one per bot and pass clones around.

HTTP/2 is negotiated automatically, so concurrent requests share a single connection.

discord.js counterpart: REST from @discordjs/rest.

§Examples

use djs_model::id::ChannelId;
use djs_rest::Rest;

let rest = Rest::new(std::env::var("DISCORD_TOKEN").unwrap());

let gateway = rest.get_gateway_bot().await?;
println!("recommended shards: {}", gateway.shards);

rest.create_message(ChannelId::new(1_234_567_890_123_456_789), &"Hello!".into())
    .await?;

Implementations§

Source§

impl Rest

Source

pub fn new(token: impl Into<String>) -> Self

Creates a client authenticated with a bot token, using default options.

Pass the raw token, without the Bot prefix. An invalid token (one containing characters that cannot appear in an HTTP header) is reported by the first request as ErrorKind::BuildRequest.

discord.js counterpart: new REST().setToken(token).

Source

pub fn cdn(&self) -> &Cdn

Returns the client’s CDN URL builder (D-137), with the base URLs set on the RestBuilder.

discord.js counterpart: REST#cdn.

§Examples
use djs_model::id::EmojiId;
use djs_rest::cdn::ImageOptions;

let rest = djs_rest::Rest::new("my-token");
assert_eq!(
    rest.cdn().emoji(EmojiId::new(1), false, ImageOptions::new()),
    "https://cdn.discordapp.com/emojis/1.webp"
);
Source

pub fn guild_widget_image_url( &self, guild_id: GuildId, style: Option<WidgetStyle>, ) -> String

The URL of a guild’s widget image (a public PNG; the widget must be enabled), in style or Discord’s default (shield) (D-116).

discord.js counterpart: Guild#widgetImageURL.

§Examples
use djs_model::{guild::WidgetStyle, id::GuildId};

let rest = djs_rest::Rest::new("my-token");
assert_eq!(
    rest.guild_widget_image_url(GuildId::new(1), Some(WidgetStyle::Banner2)),
    "https://discord.com/api/v10/guilds/1/widget.png?style=banner2"
);
Source

pub fn builder() -> RestBuilder

Returns a builder to configure a client.

discord.js counterpart: new REST(options) (@discordjs/rest).

§Examples
use std::time::Duration;

let rest = djs_rest::Rest::builder()
    .token("my-token")
    .timeout(Duration::from_secs(10))
    .retries(5)
    .build();
Source

pub fn invalid_requests(&self) -> u32

Returns the number of invalid requests (401, 403 and 429 responses, except 429s with the shared scope) this client made in the last 10 minutes.

Discord temporarily bans the IP (for about an hour) once it sees 10 000 of them in 10 minutes. The count is kept in 10-second slots, so it may include requests up to 10 s older than the window. A warning is logged at every 1 000; see also RestBuilder::invalid_request_limit.

discord.js counterpart: the invalidRequestWarning event.

Source

pub fn request<'a, T: DeserializeOwned + 'a>( &'a self, request: Request<'a>, ) -> impl Future<Output = Result<T, Error>> + Send + 'a

Sends a request and deserializes the JSON response into T.

This is the low-level entry point for endpoints without a typed method; the typed methods send their requests the same way. Use T = () for endpoints that return 204 No Content.

Requests are rate limited and retried automatically:

  • 429 Too Many Requests is retried after the time Discord asks for (it does not count towards the retry limit);
  • 5xx responses, transport errors and timeouts are retried up to RestBuilder::retries times.

discord.js counterpart: REST#request / REST#get / REST#post.

§Errors

Returns an Error if the request cannot be built or sent, Discord responds with an error status, or the response body does not match T.

Source§

impl Rest

Source

pub fn get_current_application( &self, ) -> impl Future<Output = Result<Application, Error>> + Send + '_

Get Current Application: returns the application of the bot, with its owner or team and approximate install counts.

discord.js counterpart: ClientApplication#fetch.

§Examples
let application = rest.get_current_application().await?;
println!(
    "{} is in about {:?} guilds",
    application.name, application.approximate_guild_count
);
§Errors

See Rest::request.

Source

pub fn edit_current_application<'a>( &'a self, body: &'a EditCurrentApplication, ) -> impl Future<Output = Result<Application, Error>> + Send + 'a

Edit Current Application: changes the settings of the bot’s application and returns it.

discord.js counterpart: ClientApplication#edit.

§Errors

See Rest::request; 50035 for a field Discord does not accept (for example an interactions endpoint URL that fails validation).

Source

pub fn get_application_activity_instance<'a>( &'a self, application_id: ApplicationId, instance_id: &'a str, ) -> impl Future<Output = Result<ActivityInstance, Error>> + Send + 'a

Get Application Activity Instance: returns a running instance of the application’s Activity, with the users connected to it — for example to check that a user who claims to be in it really is.

discord.js counterpart: ClientApplication#fetchActivityInstance.

§Errors

See Rest::request; 404 when the instance does not exist (anymore).

Source§

impl Rest

Source

pub fn get_global_application_commands<'a>( &'a self, application_id: ApplicationId, query: &'a GetApplicationCommands, ) -> impl Future<Output = Result<Vec<ApplicationCommand>, Error>> + Send + 'a

Get Global Application Commands: returns the application’s global commands.

discord.js counterpart: ApplicationCommandManager#fetch.

§Errors

See Rest::request.

Source

pub fn create_global_application_command<'a>( &'a self, application_id: ApplicationId, body: &'a CreateApplicationCommand, ) -> impl Future<Output = Result<ApplicationCommand, Error>> + Send + 'a

Create Global Application Command: registers a global command, or updates the one with the same name and type. Discord answers 201 Created for a new command and 200 OK for an update.

discord.js counterpart: ApplicationCommandManager#create.

§Examples
use djs_model::rest::CreateApplicationCommand;

let ping = CreateApplicationCommand::chat_input("ping", "Checks that the bot is alive");
let command = rest
    .create_global_application_command(application_id, &ping)
    .await?;
println!("registered /ping as {}", command.id);
§Errors

See Rest::request; 30032 at the maximum number of commands, 50035 for an invalid command (see ApiError::field_errors).

Source

pub fn get_global_application_command( &self, application_id: ApplicationId, command_id: CommandId, ) -> impl Future<Output = Result<ApplicationCommand, Error>> + Send + '_

Get Global Application Command: returns one global command.

discord.js counterpart: ApplicationCommandManager#fetch(id).

§Errors

See Rest::request; 10063 Unknown Application Command.

Source

pub fn edit_global_application_command<'a>( &'a self, application_id: ApplicationId, command_id: CommandId, body: &'a EditApplicationCommand, ) -> impl Future<Output = Result<ApplicationCommand, Error>> + Send + 'a

Edit Global Application Command: changes the fields of a global command that are set in body.

discord.js counterpart: ApplicationCommandManager#edit.

§Errors

See Rest::request.

Source

pub fn delete_global_application_command( &self, application_id: ApplicationId, command_id: CommandId, ) -> impl Future<Output = Result<(), Error>> + Send + '_

Delete Global Application Command: unregisters a global command.

discord.js counterpart: ApplicationCommandManager#delete.

§Errors

See Rest::request.

Source

pub fn bulk_overwrite_global_application_commands<'a>( &'a self, application_id: ApplicationId, commands: &'a [CreateApplicationCommand], ) -> impl Future<Output = Result<Vec<ApplicationCommand>, Error>> + Send + 'a

Bulk Overwrite Global Application Commands: replaces all global commands with commands, and returns them.

Commands not in the list are deleted (an empty list deletes all); listed commands keep their IDs when their name and type match an existing command. This is the usual way to register commands when a bot starts.

discord.js counterpart: ApplicationCommandManager#set.

§Examples
use djs_model::rest::CreateApplicationCommand;

let commands = [
    CreateApplicationCommand::chat_input("ping", "Checks that the bot is alive"),
    CreateApplicationCommand::user("Show avatar"),
];
rest.bulk_overwrite_global_application_commands(application_id, &commands)
    .await?;
§Errors

See Rest::request.

Source

pub fn get_guild_application_commands<'a>( &'a self, application_id: ApplicationId, guild_id: GuildId, query: &'a GetApplicationCommands, ) -> impl Future<Output = Result<Vec<ApplicationCommand>, Error>> + Send + 'a

Get Guild Application Commands: returns the application’s commands in a guild (not its global commands).

discord.js counterpart: GuildApplicationCommandManager#fetch.

§Errors

See Rest::request.

Source

pub fn create_guild_application_command<'a>( &'a self, application_id: ApplicationId, guild_id: GuildId, body: &'a CreateApplicationCommand, ) -> impl Future<Output = Result<ApplicationCommand, Error>> + Send + 'a

Create Guild Application Command: registers a command in one guild, or updates the one with the same name and type. Guild commands are available at once, which makes them handy while developing.

discord.js counterpart: GuildApplicationCommandManager#create.

§Errors

See Rest::request; 50001 Missing Access when the application is not in the guild with the applications.commands scope.

Source

pub fn get_guild_application_command( &self, application_id: ApplicationId, guild_id: GuildId, command_id: CommandId, ) -> impl Future<Output = Result<ApplicationCommand, Error>> + Send + '_

Get Guild Application Command: returns one guild command.

discord.js counterpart: GuildApplicationCommandManager#fetch(id).

§Errors

See Rest::request; 10063 Unknown Application Command.

Source

pub fn edit_guild_application_command<'a>( &'a self, application_id: ApplicationId, guild_id: GuildId, command_id: CommandId, body: &'a EditApplicationCommand, ) -> impl Future<Output = Result<ApplicationCommand, Error>> + Send + 'a

Edit Guild Application Command: changes the fields of a guild command that are set in body.

discord.js counterpart: GuildApplicationCommandManager#edit.

§Errors

See Rest::request.

Source

pub fn delete_guild_application_command( &self, application_id: ApplicationId, guild_id: GuildId, command_id: CommandId, ) -> impl Future<Output = Result<(), Error>> + Send + '_

Delete Guild Application Command: unregisters a guild command.

discord.js counterpart: GuildApplicationCommandManager#delete.

§Errors

See Rest::request.

Source

pub fn bulk_overwrite_guild_application_commands<'a>( &'a self, application_id: ApplicationId, guild_id: GuildId, commands: &'a [CreateApplicationCommand], ) -> impl Future<Output = Result<Vec<ApplicationCommand>, Error>> + Send + 'a

Bulk Overwrite Guild Application Commands: replaces all of the application’s commands in a guild with commands, and returns them; see bulk_overwrite_global_application_commands.

discord.js counterpart: GuildApplicationCommandManager#set.

§Errors

See Rest::request.

Source

pub fn get_guild_application_command_permissions( &self, application_id: ApplicationId, guild_id: GuildId, ) -> impl Future<Output = Result<Vec<GuildCommandPermissions>, Error>> + Send + '_

Get Guild Application Command Permissions: returns the permission overwrites of the application’s commands in a guild (only commands that have overwrites).

discord.js counterpart: ApplicationCommandPermissionsManager#fetch.

§Errors

See Rest::request.

Source

pub fn get_application_command_permissions( &self, application_id: ApplicationId, guild_id: GuildId, command_id: CommandId, ) -> impl Future<Output = Result<GuildCommandPermissions, Error>> + Send + '_

Get Application Command Permissions: returns the permission overwrites of one command in a guild.

command_id may also be the application ID, for the overwrites that apply to all of its commands without their own.

discord.js counterpart: ApplicationCommandPermissionsManager#fetch({ command }).

§Errors

See Rest::request; 10066 Unknown Application Command Permissions when the command has none.

Source

pub fn edit_application_command_permissions<'a>( &'a self, application_id: ApplicationId, guild_id: GuildId, command_id: CommandId, body: &'a EditApplicationCommandPermissions, ) -> impl Future<Output = Result<GuildCommandPermissions, Error>> + Send + 'a

Edit Application Command Permissions: replaces the permission overwrites of one command in a guild.

Discord rejects bot tokens here: the client must be built with RestBuilder::bearer_token, holding the OAuth2 access token (scope applications.commands.permissions.update) of a user who can manage the guild and the command (D-108).

discord.js counterpart: ApplicationCommandPermissionsManager#set.

§Examples
use djs_model::{
    application_command::{CommandPermission, CommandPermissionType},
    rest::EditApplicationCommandPermissions,
};
use djs_rest::Rest;

let user = Rest::builder().bearer_token(access_token).build();
let allow_role = CommandPermission::new(role.cast(), CommandPermissionType::Role, true);
let body = EditApplicationCommandPermissions::new(vec![allow_role]);
user.edit_application_command_permissions(application_id, guild_id, command_id, &body)
    .await?;
§Errors

See Rest::request; 401 Unauthorized with a bot token, 50001 Missing Access when the user cannot manage the guild.

Source§

impl Rest

Source

pub fn update_application_identity_profile<'a>( &'a self, application_id: ApplicationId, user_id: UserId, provider_issued_user_id: &'a str, body: &'a UpdateApplicationIdentityProfile, ) -> impl Future<Output = Result<Option<ApplicationIdentityProfile>, Error>> + Send + 'a

Update Application Identity Profile: stores a user’s game stats for their account provider_issued_user_id in the app’s system. The first write creates the identity (provider type NONE) and returns its profile; later writes return None (D-135).

discord.js counterpart: none.

§Examples
use djs_model::{application_identity_profile::ProfileData, rest::UpdateApplicationIdentityProfile};

let mut body = UpdateApplicationIdentityProfile::default();
body.username = Some("ferris".into());
body.data = Some(ProfileData::default());
rest.update_application_identity_profile(application_id, user_id, "player-42", &body)
    .await?;
§Errors

See Rest::request; 403 when the application may not store game stats; 400 for data over 10 KB or an external ID that belongs to another user or does not match the user’s identity.

Source

pub fn get_application_identity_profile<'a>( &'a self, application_id: ApplicationId, user_id: UserId, provider_issued_user_id: &'a str, ) -> impl Future<Output = Result<ApplicationIdentityProfile, Error>> + Send + 'a

Get Application Identity Profile: returns the game stats stored for a user’s account in the app’s system.

discord.js counterpart: none.

§Errors

See Rest::request.

Source

pub fn get_application_identities_by_user_id( &self, user_id: UserId, application_id: ApplicationId, ) -> impl Future<Output = Result<Vec<ApplicationIdentity>, Error>> + Send + '_

Get Application Identities by User ID: returns a user’s identities in the application (without profiles), e.g. to find the values delete_application_identity needs.

discord.js counterpart: none.

§Errors

See Rest::request.

Source

pub fn get_application_identities_by_external_id<'a>( &'a self, application_id: ApplicationId, provider_type: &'a str, provider_issued_user_id: &'a str, query: &'a GetApplicationIdentitiesByExternalId, ) -> impl Future<Output = Result<Vec<ApplicationIdentity>, Error>> + Send + 'a

Get Application Identities by External ID: returns the identities of the Discord user that an external account belongs to (the identities carry the user_id).

discord.js counterpart: none.

§Errors

See Rest::request.

Source

pub fn delete_application_identity<'a>( &'a self, user_id: UserId, application_id: ApplicationId, provider_type: &'a str, provider_issued_user_id: &'a str, body: &'a DeleteApplicationIdentity, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Delete Application Identity: deletes one of a user’s identities and its game stats — e.g. a stale external ID that blocks writing the current one. The user’s last account-linking identity cannot be deleted.

discord.js counterpart: none.

§Errors

See Rest::request.

Source§

impl Rest

Source

pub fn get_application_role_connection_metadata_records( &self, application_id: ApplicationId, ) -> impl Future<Output = Result<Vec<ApplicationRoleConnectionMetadata>, Error>> + Send + '_

Get Application Role Connection Metadata Records: returns the fields guilds can require for the application’s linked roles.

discord.js counterpart: ClientApplication#fetchRoleConnectionMetadataRecords.

§Errors

See Rest::request.

Source

pub fn update_application_role_connection_metadata_records<'a>( &'a self, application_id: ApplicationId, records: &'a [ApplicationRoleConnectionMetadata], ) -> impl Future<Output = Result<Vec<ApplicationRoleConnectionMetadata>, Error>> + Send + 'a

Update Application Role Connection Metadata Records: replaces the fields of the application’s linked roles (up to 5) and returns them.

discord.js counterpart: ClientApplication#editRoleConnectionMetadataRecords.

§Examples
use djs_model::application_role_connection_metadata::{
    ApplicationRoleConnectionMetadata, MetadataType,
};

let records = [ApplicationRoleConnectionMetadata::new(
    MetadataType::DatetimeGreaterThanOrEqual,
    "joined",
    "Member since",
    "Days since the player joined",
)];
rest.update_application_role_connection_metadata_records(application_id, &records)
    .await?;
§Errors

See Rest::request; 50035 for more than 5 records or an invalid key.

Source§

impl Rest

Source

pub fn get_guild_audit_log<'a>( &'a self, guild_id: GuildId, query: &'a GetGuildAuditLog, ) -> impl Future<Output = Result<AuditLog, Error>> + Send + 'a

Get Guild Audit Log: returns a page of a guild’s audit log entries (50 by default) with the users, webhooks, threads and other objects they refer to. Needs VIEW_AUDIT_LOG.

The reasons that methods taking a reason send (D-086) appear here.

discord.js counterpart: Guild#fetchAuditLogs.

§Examples
use djs_model::{audit_log::AuditLogEvent, rest::GetGuildAuditLog};

let mut query = GetGuildAuditLog::default();
query.action_type = Some(AuditLogEvent::MemberBanAdd);
query.limit = Some(10);
let log = rest.get_guild_audit_log(guild_id, &query).await?;
for entry in &log.audit_log_entries {
    println!("{:?} banned {:?}: {:?}", entry.user_id, entry.target_id, entry.reason);
}
§Errors

See Rest::request; 50013 Missing Permissions without VIEW_AUDIT_LOG.

Source§

impl Rest

Source

pub fn list_auto_moderation_rules_for_guild( &self, guild_id: GuildId, ) -> impl Future<Output = Result<Vec<Rule>, Error>> + Send + '_

List Auto Moderation Rules for Guild: returns every rule of the guild.

discord.js counterpart: AutoModerationRuleManager#fetch().

§Errors

See Rest::request.

Source

pub fn get_auto_moderation_rule( &self, guild_id: GuildId, rule_id: AutoModerationRuleId, ) -> impl Future<Output = Result<Rule, Error>> + Send + '_

Get Auto Moderation Rule: returns one rule.

discord.js counterpart: AutoModerationRuleManager#fetch(id).

§Errors

See Rest::request.

Source

pub fn create_auto_moderation_rule<'a>( &'a self, guild_id: GuildId, body: &'a CreateAutoModerationRule, reason: Option<&'a str>, ) -> impl Future<Output = Result<Rule, Error>> + Send + 'a

Create Auto Moderation Rule: adds a rule. A Timeout action also needs MODERATE_MEMBERS.

reason is shown in the audit log (D-086).

discord.js counterpart: AutoModerationRuleManager#create.

§Examples
use djs_model::{auto_moderation::Action, rest::CreateAutoModerationRule};

let mut body = CreateAutoModerationRule::mention_spam(
    "Mention spam",
    10,
    [Action::block_message(), Action::send_alert_message(log)],
);
body.enabled = Some(true);
let rule = rest
    .create_auto_moderation_rule(guild_id, &body, Some("Raid protection"))
    .await?;
println!("Created rule {}", rule.id);
§Errors

See Rest::request; 400 when the guild already has the most rules of that trigger type, or for metadata or actions the trigger type does not accept.

Source

pub fn modify_auto_moderation_rule<'a>( &'a self, guild_id: GuildId, rule_id: AutoModerationRuleId, body: &'a ModifyAutoModerationRule, reason: Option<&'a str>, ) -> impl Future<Output = Result<Rule, Error>> + Send + 'a

Modify Auto Moderation Rule: changes a rule and returns it.

reason is shown in the audit log (D-086).

discord.js counterpart: AutoModerationRule#edit and its setters, AutoModerationRuleManager#edit.

§Examples
use djs_model::rest::ModifyAutoModerationRule;

let mut body = ModifyAutoModerationRule::default();
body.enabled = Some(false);
rest.modify_auto_moderation_rule(guild_id, rule_id, &body, None)
    .await?;
§Errors

See Rest::request.

Source

pub fn delete_auto_moderation_rule<'a>( &'a self, guild_id: GuildId, rule_id: AutoModerationRuleId, reason: Option<&'a str>, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Delete Auto Moderation Rule: deletes a rule.

reason is shown in the audit log (D-086).

discord.js counterpart: AutoModerationRule#delete, AutoModerationRuleManager#delete.

§Errors

See Rest::request.

Source§

impl Rest

Source

pub fn get_channel( &self, channel_id: ChannelId, ) -> impl Future<Output = Result<Channel, Error>> + Send + '_

Get Channel: returns a channel; for a thread the current user joined, with their [ThreadMember].

discord.js counterpart: ChannelManager#fetch.

§Errors

See Rest::request; 10003 Unknown Channel, 50001 Missing Access.

Source

pub fn modify_channel<'a>( &'a self, channel_id: ChannelId, body: &'a ModifyGuildChannel, reason: Option<&'a str>, ) -> impl Future<Output = Result<Channel, Error>> + Send + 'a

Modify Channel of a guild channel (D-109): changes the fields set in body. Needs MANAGE_CHANNELS, and MANAGE_ROLES to change permission overwrites.

reason is shown in the audit log (D-086).

discord.js counterpart: GuildChannel#edit.

§Examples
use djs_model::{rest::ModifyGuildChannel, util::Patch};

let mut body = ModifyGuildChannel::default();
body.topic = Patch::Set("Rust bots only".into());
body.rate_limit_per_user = Patch::Set(30);
rest.modify_channel(channel_id, &body, Some("Calming things down"))
    .await?;
§Errors

See Rest::request; 50035 for an invalid field (see ApiError::field_errors), 50013 Missing Permissions.

Source

pub fn modify_thread<'a>( &'a self, channel_id: ChannelId, body: &'a ModifyThread, reason: Option<&'a str>, ) -> impl Future<Output = Result<Channel, Error>> + Send + 'a

Modify Channel of a thread (D-109): changes the fields set in body. Needs MANAGE_THREADS, except for unarchiving an unlocked thread; an archived thread must be unarchived by the same request.

reason is shown in the audit log (D-086).

discord.js counterpart: ThreadChannel#edit.

§Errors

See Rest::request; 50083 when the thread is archived.

Source

pub fn modify_group_dm<'a>( &'a self, channel_id: ChannelId, body: &'a ModifyGroupDm, ) -> impl Future<Output = Result<Channel, Error>> + Send + 'a

Modify Channel of a group DM (D-109): changes its name or icon.

discord.js counterpart: PartialGroupDMChannel#edit.

§Errors

See Rest::request.

Source

pub fn delete_channel<'a>( &'a self, channel_id: ChannelId, reason: Option<&'a str>, ) -> impl Future<Output = Result<Channel, Error>> + Send + 'a

Delete/Close Channel: deletes a guild channel or thread (for good), or closes a DM; returns the channel. Needs MANAGE_CHANNELS, or MANAGE_THREADS for a thread. The channels of a deleted category are kept, without a parent.

reason is shown in the audit log (D-086).

discord.js counterpart: GuildChannel#delete, DMChannel#delete.

§Errors

See Rest::request; 50074 for the rules, guidelines or community updates channel of a community guild.

Source

pub fn get_channel_member_permissions<'a>( &'a self, channel_id: ChannelId, user_id: UserId, query: &'a GetChannelPermissions, ) -> impl Future<Output = Result<Permissions, Error>> + Send + 'a

Get Channel Member Permissions: returns a member’s permissions in a channel, computed from their roles and the channel’s overwrites (a thread uses its parent’s). Needs VIEW_CHANNEL (and CONNECT in voice and stage channels).

discord.js counterpart: GuildChannel#permissionsFor(member) (computed locally).

§Errors

See Rest::request; 10007 Unknown Member.

Source

pub fn get_channel_role_permissions<'a>( &'a self, channel_id: ChannelId, role_id: RoleId, query: &'a GetChannelPermissions, ) -> impl Future<Output = Result<Permissions, Error>> + Send + 'a

Get Channel Role Permissions: returns the permissions of a role together with @everyone in a channel, with their overwrites applied (other roles and member overwrites are ignored). Needs VIEW_CHANNEL (and CONNECT in voice and stage channels).

discord.js counterpart: GuildChannel#permissionsFor(role) (computed locally).

§Errors

See Rest::request; 10011 Unknown Role.

Source

pub fn set_voice_channel_status<'a>( &'a self, channel_id: ChannelId, body: &'a SetVoiceChannelStatus, reason: Option<&'a str>, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Set Voice Channel Status: sets or removes the status of a voice channel. Needs SET_VOICE_CHANNEL_STATUS, and MANAGE_CHANNELS when the current user is not connected to the channel.

reason is shown in the audit log (D-086).

discord.js counterpart: VoiceChannel#setStatus.

§Errors

See Rest::request.

Source

pub fn edit_channel_permissions<'a>( &'a self, channel_id: ChannelId, overwrite_id: GenericId, body: &'a EditChannelPermissions, reason: Option<&'a str>, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Edit Channel Permissions: creates or replaces the permission overwrite of a role or member (overwrite_id) in a guild channel. Needs MANAGE_ROLES; only permissions the bot has can be allowed or denied, unless it has a MANAGE_ROLES overwrite there.

reason is shown in the audit log (D-086).

discord.js counterpart: PermissionOverwriteManager#edit / #create.

§Examples
use djs_model::{channel::OverwriteType, permissions::Permissions, rest::EditChannelPermissions};

let mut muted = EditChannelPermissions::new(OverwriteType::Role);
muted.deny = Some(Permissions::SEND_MESSAGES | Permissions::ADD_REACTIONS);
rest.edit_channel_permissions(channel_id, role_id.cast(), &muted, None)
    .await?;
§Errors

See Rest::request; 50013 Missing Permissions.

Source

pub fn delete_channel_permission<'a>( &'a self, channel_id: ChannelId, overwrite_id: GenericId, reason: Option<&'a str>, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Delete Channel Permission: removes the permission overwrite of a role or member (overwrite_id). Needs MANAGE_ROLES.

reason is shown in the audit log (D-086).

discord.js counterpart: PermissionOverwriteManager#delete.

§Errors

See Rest::request.

Source

pub fn get_channel_invites( &self, channel_id: ChannelId, ) -> impl Future<Output = Result<Vec<InviteWithMetadata>, Error>> + Send + '_

Get Channel Invites: returns the invites of a guild channel. Needs MANAGE_CHANNELS.

discord.js counterpart: GuildChannel#fetchInvites.

§Errors

See Rest::request.

Source

pub fn create_channel_invite<'a>( &'a self, channel_id: ChannelId, body: &'a CreateChannelInvite, reason: Option<&'a str>, ) -> impl Future<Output = Result<InviteWithMetadata, Error>> + Send + 'a

Create Channel Invite: creates an invite to a guild channel. Needs CREATE_INSTANT_INVITE (and MANAGE_ROLES for role_ids). With a target_users_file the request is sent as multipart/form-data (D-111).

reason is shown in the audit log (D-086).

discord.js counterpart: GuildChannel#createInvite.

§Examples
use djs_model::rest::CreateChannelInvite;

let mut body = CreateChannelInvite::default();
body.max_uses = Some(1);
body.unique = true;
let invite = rest.create_channel_invite(channel_id, &body, None).await?;
println!("https://discord.gg/{}", invite.code);
§Errors

See Rest::request; 30016 Maximum number of invites reached.

Source

pub fn follow_announcement_channel<'a>( &'a self, channel_id: ChannelId, body: &'a FollowAnnouncementChannel, reason: Option<&'a str>, ) -> impl Future<Output = Result<FollowedChannel, Error>> + Send + 'a

Follow Announcement Channel: publishes the messages of an announcement channel into another channel, through a webhook created there. Needs MANAGE_WEBHOOKS in the target channel.

reason is shown in the audit log (D-086).

discord.js counterpart: NewsChannel#addFollower.

§Errors

See Rest::request; 30007 Maximum number of webhooks reached.

Source

pub fn trigger_typing_indicator( &self, channel_id: ChannelId, ) -> impl Future<Output = Result<(), Error>> + Send + '_

Trigger Typing Indicator: shows “… is typing” for 10 seconds (or until the bot sends a message). Meant for commands that take a few seconds to answer.

discord.js counterpart: TextBasedChannel#sendTyping.

§Errors

See Rest::request.

Source

pub fn group_dm_add_recipient<'a>( &'a self, channel_id: ChannelId, user_id: UserId, body: &'a GroupDmAddRecipient, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Group DM Add Recipient: adds a user to a group DM with the access token they gave the application (gdm.join scope).

discord.js counterpart: PartialGroupDMChannel#addRecipient.

§Errors

See Rest::request.

Source

pub fn group_dm_remove_recipient( &self, channel_id: ChannelId, user_id: UserId, ) -> impl Future<Output = Result<(), Error>> + Send + '_

Group DM Remove Recipient: removes a user from a group DM.

discord.js counterpart: PartialGroupDMChannel#removeRecipient.

§Errors

See Rest::request.

Source

pub fn start_thread_from_message<'a>( &'a self, channel_id: ChannelId, message_id: MessageId, body: &'a StartThreadFromMessage, reason: Option<&'a str>, ) -> impl Future<Output = Result<Channel, Error>> + Send + 'a

Start Thread from Message: creates a thread on an existing message (a public thread in a text channel, an announcement thread in an announcement channel); the thread gets the message’s ID. Needs CREATE_PUBLIC_THREADS.

reason is shown in the audit log (D-086).

discord.js counterpart: Message#startThread.

§Errors

See Rest::request; 160004 when the message already has a thread.

Source

pub fn start_thread_without_message<'a>( &'a self, channel_id: ChannelId, body: &'a StartThreadWithoutMessage, reason: Option<&'a str>, ) -> impl Future<Output = Result<Channel, Error>> + Send + 'a

Start Thread without Message: creates a thread that does not start from a message. Needs CREATE_PUBLIC_THREADS or CREATE_PRIVATE_THREADS.

reason is shown in the audit log (D-086).

discord.js counterpart: GuildTextThreadManager#create.

§Examples
use djs_model::{channel::ChannelType, rest::StartThreadWithoutMessage};

let mut body = StartThreadWithoutMessage::new("Ticket #42", ChannelType::PrivateThread);
body.invitable = Some(false);
let thread = rest
    .start_thread_without_message(channel_id, &body, None)
    .await?;
§Errors

See Rest::request; 160006 Maximum number of active threads reached.

Source

pub fn start_thread_in_forum_or_media_channel<'a>( &'a self, channel_id: ChannelId, body: &'a StartThreadInForumOrMediaChannel, reason: Option<&'a str>, ) -> impl Future<Output = Result<ForumThread, Error>> + Send + 'a

Start Thread in Forum or Media Channel: creates a post with its first message, and returns both (D-115). The files of the message are uploaded with it. Needs SEND_MESSAGES.

reason is shown in the audit log (D-086).

discord.js counterpart: GuildForumThreadManager#create.

§Errors

See Rest::request; 40067 when the channel requires a tag and none is applied.

Source

pub fn join_thread( &self, channel_id: ChannelId, ) -> impl Future<Output = Result<(), Error>> + Send + '_

Join Thread: adds the current user to a thread that is not archived.

discord.js counterpart: ThreadMemberManager#add('@me') / ThreadChannel#join.

§Errors

See Rest::request.

Source

pub fn add_thread_member( &self, channel_id: ChannelId, user_id: UserId, ) -> impl Future<Output = Result<(), Error>> + Send + '_

Add Thread Member: adds a member to a thread that is not archived (also succeeds if they already are one). Needs permission to send messages in the thread.

discord.js counterpart: ThreadMemberManager#add.

§Errors

See Rest::request.

Source

pub fn leave_thread( &self, channel_id: ChannelId, ) -> impl Future<Output = Result<(), Error>> + Send + '_

Leave Thread: removes the current user from a thread that is not archived.

discord.js counterpart: ThreadChannel#leave.

§Errors

See Rest::request.

Source

pub fn remove_thread_member( &self, channel_id: ChannelId, user_id: UserId, ) -> impl Future<Output = Result<(), Error>> + Send + '_

Remove Thread Member: removes a member from a thread that is not archived. Needs MANAGE_THREADS (or to be the creator of a private thread).

discord.js counterpart: ThreadMemberManager#remove.

§Errors

See Rest::request.

Source

pub fn get_thread_member<'a>( &'a self, channel_id: ChannelId, user_id: UserId, query: &'a GetThreadMember, ) -> impl Future<Output = Result<ThreadMember, Error>> + Send + 'a

Get Thread Member: returns a member of a thread.

discord.js counterpart: ThreadMemberManager#fetch.

§Errors

See Rest::request; 10007 Unknown Member when the user is not in the thread.

Source

pub fn list_thread_members<'a>( &'a self, channel_id: ChannelId, query: &'a ListThreadMembers, ) -> impl Future<Output = Result<Vec<ThreadMember>, Error>> + Send + 'a

List Thread Members: returns the members of a thread; with with_member one page of them, each with their guild member. Needs the GUILD_MEMBERS privileged intent.

discord.js counterpart: ThreadMemberManager#fetch().

§Errors

See Rest::request.

Source

pub fn list_public_archived_threads<'a>( &'a self, channel_id: ChannelId, query: &'a ListArchivedThreads, ) -> impl Future<Output = Result<ArchivedThreads, Error>> + Send + 'a

List Public Archived Threads: returns archived public (or announcement) threads of a channel, most recently archived first. Needs READ_MESSAGE_HISTORY.

discord.js counterpart: GuildTextThreadManager#fetchArchived({ type: 'public' }).

§Errors

See Rest::request.

Source

pub fn list_private_archived_threads<'a>( &'a self, channel_id: ChannelId, query: &'a ListArchivedThreads, ) -> impl Future<Output = Result<ArchivedThreads, Error>> + Send + 'a

List Private Archived Threads: returns archived private threads of a channel, most recently archived first. Needs READ_MESSAGE_HISTORY and MANAGE_THREADS.

discord.js counterpart: GuildTextThreadManager#fetchArchived({ type: 'private' }).

§Errors

See Rest::request.

Source

pub fn list_joined_private_archived_threads<'a>( &'a self, channel_id: ChannelId, query: &'a ListJoinedPrivateArchivedThreads, ) -> impl Future<Output = Result<ArchivedThreads, Error>> + Send + 'a

List Joined Private Archived Threads: returns the archived private threads of a channel that the current user joined, highest ID first. Needs READ_MESSAGE_HISTORY.

discord.js counterpart: GuildTextThreadManager#fetchArchived({ type: 'private', fetchAll: false }).

§Errors

See Rest::request.

Source§

impl Rest

Guild emojis.

Source

pub fn list_guild_emojis( &self, guild_id: GuildId, ) -> impl Future<Output = Result<Vec<Emoji>, Error>> + Send + '_

List Guild Emojis: returns every custom emoji of a guild. [Emoji::user] is included with the CREATE_GUILD_EXPRESSIONS or MANAGE_GUILD_EXPRESSIONS permission.

discord.js counterpart: GuildEmojiManager#fetch().

§Errors

See Rest::request.

Source

pub fn get_guild_emoji( &self, guild_id: GuildId, emoji_id: EmojiId, ) -> impl Future<Output = Result<Emoji, Error>> + Send + '_

Get Guild Emoji: returns one custom emoji of a guild.

discord.js counterpart: GuildEmojiManager#fetch(id).

§Errors

See Rest::request; 10014 Unknown Emoji.

Source

pub fn create_guild_emoji<'a>( &'a self, guild_id: GuildId, body: &'a CreateGuildEmoji, reason: Option<&'a str>, ) -> impl Future<Output = Result<Emoji, Error>> + Send + 'a

Create Guild Emoji: uploads a custom emoji. Needs CREATE_GUILD_EXPRESSIONS.

reason is shown in the audit log (D-086).

discord.js counterpart: GuildEmojiManager#create.

§Examples
use djs_model::{rest::CreateGuildEmoji, util::ImageData};

let image = ImageData::new(std::fs::read("ferris.png")?)?;
let emoji = rest
    .create_guild_emoji(guild_id, &CreateGuildEmoji::new("ferris", image), Some("New mascot"))
    .await?;
println!("Use it as <:{}:{}>", emoji.name, emoji.id);
§Errors

See Rest::request; 30008 or 30018 when the guild has no free (animated) emoji slot; a 400 without a JSON error code when the image is larger than 256 KiB.

Source

pub fn modify_guild_emoji<'a>( &'a self, guild_id: GuildId, emoji_id: EmojiId, body: &'a ModifyGuildEmoji, reason: Option<&'a str>, ) -> impl Future<Output = Result<Emoji, Error>> + Send + 'a

Modify Guild Emoji: renames an emoji or changes which roles may use it. Needs MANAGE_GUILD_EXPRESSIONS, or CREATE_GUILD_EXPRESSIONS for emojis the bot created.

reason is shown in the audit log (D-086).

discord.js counterpart: GuildEmoji#edit, GuildEmojiManager#edit.

§Errors

See Rest::request; 10014 Unknown Emoji.

Source

pub fn delete_guild_emoji<'a>( &'a self, guild_id: GuildId, emoji_id: EmojiId, reason: Option<&'a str>, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Delete Guild Emoji: deletes a custom emoji. Needs MANAGE_GUILD_EXPRESSIONS, or CREATE_GUILD_EXPRESSIONS for emojis the bot created.

reason is shown in the audit log (D-086).

discord.js counterpart: GuildEmoji#delete, GuildEmojiManager#delete.

§Errors

See Rest::request; 10014 Unknown Emoji.

Source§

impl Rest

Application emojis: emojis owned by the bot’s application, usable by the bot everywhere.

Source

pub fn list_application_emojis( &self, application_id: ApplicationId, ) -> impl Future<Output = Result<Vec<Emoji>, Error>> + Send + '_

List Application Emojis: returns every emoji of the application, with [Emoji::user] (the team member who uploaded it, or the bot). Discord wraps the list in an object; it is unwrapped.

discord.js counterpart: ApplicationEmojiManager#fetch().

§Errors

See Rest::request.

Source

pub fn get_application_emoji( &self, application_id: ApplicationId, emoji_id: EmojiId, ) -> impl Future<Output = Result<Emoji, Error>> + Send + '_

Get Application Emoji: returns one emoji of the application, with [Emoji::user].

discord.js counterpart: ApplicationEmojiManager#fetch(id).

§Errors

See Rest::request; 10014 Unknown Emoji.

Source

pub fn create_application_emoji<'a>( &'a self, application_id: ApplicationId, body: &'a CreateApplicationEmoji, ) -> impl Future<Output = Result<Emoji, Error>> + Send + 'a

Create Application Emoji: uploads an emoji the bot can use in every guild and DM, without needing the USE_EXTERNAL_EMOJIS permission there.

discord.js counterpart: ApplicationEmojiManager#create.

§Examples
use djs_model::{rest::CreateApplicationEmoji, util::ImageData};

let image = ImageData::new(std::fs::read("loading.gif")?)?;
let body = CreateApplicationEmoji::new("loading", image);
let emoji = rest.create_application_emoji(application_id, &body).await?;
assert!(emoji.animated);
§Errors

See Rest::request; 30008 when the application has no free emoji slot; a 400 without a JSON error code when the image is larger than 256 KiB.

Source

pub fn modify_application_emoji<'a>( &'a self, application_id: ApplicationId, emoji_id: EmojiId, body: &'a ModifyApplicationEmoji, ) -> impl Future<Output = Result<Emoji, Error>> + Send + 'a

Modify Application Emoji: renames an emoji of the application.

discord.js counterpart: ApplicationEmoji#edit, ApplicationEmojiManager#edit.

§Errors

See Rest::request; 10014 Unknown Emoji.

Source

pub fn delete_application_emoji( &self, application_id: ApplicationId, emoji_id: EmojiId, ) -> impl Future<Output = Result<(), Error>> + Send + '_

Delete Application Emoji: deletes an emoji of the application.

discord.js counterpart: ApplicationEmoji#delete, ApplicationEmojiManager#delete.

§Errors

See Rest::request; 10014 Unknown Emoji.

Source§

impl Rest

Source

pub fn list_entitlements<'a>( &'a self, application_id: ApplicationId, query: &'a ListEntitlements, ) -> impl Future<Output = Result<Vec<Entitlement>, Error>> + Send + 'a

List Entitlements: returns a page of the application’s entitlements, active and ended (100 by default).

discord.js counterpart: EntitlementManager#fetch.

§Examples
use djs_model::{rest::ListEntitlements, util::Timestamp};

let mut query = ListEntitlements::default();
query.user_id = Some(user_id);
query.exclude_ended = Some(true);
let entitlements = rest.list_entitlements(application_id, &query).await?;
let premium = entitlements
    .iter()
    .any(|entitlement| entitlement.is_active(Timestamp::now()));
§Errors

See Rest::request.

Source

pub fn get_entitlement( &self, application_id: ApplicationId, entitlement_id: EntitlementId, ) -> impl Future<Output = Result<Entitlement, Error>> + Send + '_

Get Entitlement: returns one entitlement.

discord.js counterpart: none.

§Errors

See Rest::request; 10029 Unknown Entitlement.

Source

pub fn consume_entitlement( &self, application_id: ApplicationId, entitlement_id: EntitlementId, ) -> impl Future<Output = Result<(), Error>> + Send + '_

Consume an Entitlement: marks the entitlement to a consumable one-time purchase as used; it then has consumed set.

discord.js counterpart: Entitlement#consume, EntitlementManager#consume.

§Errors

See Rest::request; 10029 Unknown Entitlement; 40018 for an entitlement to an SKU that is not consumable.

Source

pub fn create_test_entitlement<'a>( &'a self, application_id: ApplicationId, body: &'a CreateTestEntitlement, ) -> impl Future<Output = Result<Entitlement, Error>> + Send + 'a

Create Test Entitlement: grants a guild or user access to an SKU for testing, without an end. Discord returns it without starts_at and ends_at.

discord.js counterpart: EntitlementManager#createTest.

§Examples
use djs_model::rest::CreateTestEntitlement;

let body = CreateTestEntitlement::guild(sku_id, guild_id);
let entitlement = rest.create_test_entitlement(application_id, &body).await?;
println!("Test entitlement {}", entitlement.id);
§Errors

See Rest::request; 40074 when the owner already has the entitlement.

Source

pub fn delete_test_entitlement( &self, application_id: ApplicationId, entitlement_id: EntitlementId, ) -> impl Future<Output = Result<(), Error>> + Send + '_

Delete Test Entitlement: removes a test entitlement.

discord.js counterpart: EntitlementManager#deleteTest.

§Errors

See Rest::request; 10029 Unknown Entitlement; 40019 for an entitlement that is not a test entitlement.

Source§

impl Rest

The guild itself, its channels and active threads.

Source

pub fn get_guild<'a>( &'a self, guild_id: GuildId, query: &'a GetGuild, ) -> impl Future<Output = Result<Guild, Error>> + Send + 'a

Get Guild: returns a guild the bot is in; with with_counts also the approximate member and presence counts.

discord.js counterpart: GuildManager#fetch.

§Errors

See Rest::request; 10004 Unknown Guild.

Source

pub fn get_guild_preview( &self, guild_id: GuildId, ) -> impl Future<Output = Result<Preview, Error>> + Send + '_

Get Guild Preview: returns the public preview of a guild (one the bot is not in must be discoverable).

discord.js counterpart: Client#fetchGuildPreview.

§Errors

See Rest::request; 10004 Unknown Guild.

Source

pub fn modify_guild<'a>( &'a self, guild_id: GuildId, body: &'a ModifyGuild, reason: Option<&'a str>, ) -> impl Future<Output = Result<Guild, Error>> + Send + 'a

Modify Guild: changes the settings set in body. Needs MANAGE_GUILD.

reason is shown in the audit log (D-086).

discord.js counterpart: Guild#edit.

§Errors

See Rest::request; 50035 for an invalid field (see ApiError::field_errors).

Source

pub fn get_guild_channels( &self, guild_id: GuildId, ) -> impl Future<Output = Result<Vec<Channel>, Error>> + Send + '_

Get Guild Channels: returns the guild’s channels, without threads. From 2026-11-16 Discord leaves out the channels the bot cannot view.

discord.js counterpart: GuildChannelManager#fetch().

§Errors

See Rest::request.

Source

pub fn create_guild_channel<'a>( &'a self, guild_id: GuildId, body: &'a CreateGuildChannel, reason: Option<&'a str>, ) -> impl Future<Output = Result<Channel, Error>> + Send + 'a

Create Guild Channel: creates a channel. Needs MANAGE_CHANNELS; only permissions the bot has can be set in its overwrites.

reason is shown in the audit log (D-086).

discord.js counterpart: GuildChannelManager#create.

§Examples
use djs_model::{
    channel::Overwrite, id::RoleId, permissions::Permissions, rest::CreateGuildChannel,
};

let mut announcements = CreateGuildChannel::new("announcements");
// `@everyone` (the guild's ID) can read but not write.
announcements.permission_overwrites.push(Overwrite::role(
    guild_id.cast(),
    Permissions::VIEW_CHANNEL,
    Permissions::SEND_MESSAGES,
));
rest.create_guild_channel(guild_id, &announcements, None).await?;
§Errors

See Rest::request; 30013 at the maximum number of channels (500).

Source

pub fn modify_guild_channel_positions<'a>( &'a self, guild_id: GuildId, positions: &'a [ModifyGuildChannelPosition], reason: Option<&'a str>, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Modify Guild Channel Positions: moves channels within the list or between categories (only the listed channels). Needs MANAGE_CHANNELS.

reason is shown in the audit log (D-086).

discord.js counterpart: GuildChannelManager#setPositions.

§Errors

See Rest::request; 40009 when more than one entry changes its parent.

Source

pub fn list_active_guild_threads( &self, guild_id: GuildId, ) -> impl Future<Output = Result<ActiveThreads, Error>> + Send + '_

List Active Guild Threads: returns the active public and private threads of the guild, highest ID first.

discord.js counterpart: GuildChannelManager#fetchActiveThreads.

§Errors

See Rest::request.

Source§

impl Rest

Members.

Source

pub fn get_guild_member( &self, guild_id: GuildId, user_id: UserId, ) -> impl Future<Output = Result<Member, Error>> + Send + '_

Get Guild Member: returns a member of the guild.

discord.js counterpart: GuildMemberManager#fetch.

§Errors

See Rest::request; 10007 Unknown Member.

Source

pub fn list_guild_members<'a>( &'a self, guild_id: GuildId, query: &'a ListGuildMembers, ) -> impl Future<Output = Result<Vec<Member>, Error>> + Send + 'a

List Guild Members: returns a page of members, sorted by user ID. Needs the GUILD_MEMBERS privileged intent.

For all members of a large guild, the gateway’s Request Guild Members is usually better.

discord.js counterpart: GuildMemberManager#list.

§Errors

See Rest::request; 50001 Missing Access without the intent.

Source

pub fn search_guild_members<'a>( &'a self, guild_id: GuildId, query: &'a SearchGuildMembers, ) -> impl Future<Output = Result<Vec<Member>, Error>> + Send + 'a

Search Guild Members: returns members whose username or nickname starts with the query.

discord.js counterpart: GuildMemberManager#search.

§Errors

See Rest::request.

Source

pub fn get_guild_member_permissions( &self, guild_id: GuildId, user_id: UserId, ) -> impl Future<Output = Result<Permissions, Error>> + Send + '_

Get Guild Member Permissions: returns a member’s guild-wide permissions (their roles with @everyone; D-110).

discord.js counterpart: GuildMember#permissions (computed locally).

§Errors

See Rest::request; 10007 Unknown Member.

Source

pub fn add_guild_member<'a>( &'a self, guild_id: GuildId, user_id: UserId, body: &'a AddGuildMember, ) -> impl Future<Output = Result<Option<Member>, Error>> + Send + 'a

Add Guild Member: adds a user to the guild with an OAuth2 access token they granted the bot’s application (guilds.join scope). Returns the new member, or None when the user already is one. The bot must be in the guild with CREATE_INSTANT_INVITE.

discord.js counterpart: GuildMemberManager#add.

§Errors

See Rest::request; 40007 when the user is banned, 30001 when they are in 100 guilds.

Source

pub fn modify_guild_member<'a>( &'a self, guild_id: GuildId, user_id: UserId, body: &'a ModifyGuildMember, reason: Option<&'a str>, ) -> impl Future<Output = Result<Member, Error>> + Send + 'a

Modify Guild Member: changes a member’s nickname, roles, voice state or timeout (each needs its own permission; see [ModifyGuildMember]).

reason is shown in the audit log (D-086).

discord.js counterpart: GuildMember#edit, #timeout, #setNickname, …

§Examples
use djs_model::{rest::ModifyGuildMember, util::{Patch, Timestamp}};

// Time the member out for ten minutes.
let now = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap();
let until = Timestamp::from_unix_secs(now.as_secs() as i64 + 600).unwrap();
let mut body = ModifyGuildMember::default();
body.communication_disabled_until = Patch::Set(until);
rest.modify_guild_member(guild_id, user_id, &body, Some("Spam"))
    .await?;
§Errors

See Rest::request; 50013 Missing Permissions (also for members above the bot’s highest role).

Source

pub fn modify_current_member<'a>( &'a self, guild_id: GuildId, body: &'a ModifyCurrentMember, reason: Option<&'a str>, ) -> impl Future<Output = Result<Member, Error>> + Send + 'a

Modify Current Member: changes the bot’s own nickname, guild avatar, banner or bio.

reason is shown in the audit log (D-086).

discord.js counterpart: GuildMemberManager#editMe.

§Errors

See Rest::request.

Source

pub fn add_guild_member_role<'a>( &'a self, guild_id: GuildId, user_id: UserId, role_id: RoleId, reason: Option<&'a str>, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Add Guild Member Role: gives a member a role. Needs MANAGE_ROLES and a higher role than the one given.

reason is shown in the audit log (D-086).

discord.js counterpart: GuildMemberRoleManager#add.

§Errors

See Rest::request; 10011 Unknown Role.

Source

pub fn remove_guild_member_role<'a>( &'a self, guild_id: GuildId, user_id: UserId, role_id: RoleId, reason: Option<&'a str>, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Remove Guild Member Role: takes a role from a member. Needs MANAGE_ROLES.

reason is shown in the audit log (D-086).

discord.js counterpart: GuildMemberRoleManager#remove.

§Errors

See Rest::request.

Source

pub fn remove_guild_member<'a>( &'a self, guild_id: GuildId, user_id: UserId, reason: Option<&'a str>, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Remove Guild Member: kicks a member. Needs KICK_MEMBERS.

reason is shown in the audit log (D-086).

discord.js counterpart: GuildMember#kick.

§Errors

See Rest::request; 50013 Missing Permissions.

Source§

impl Rest

Bans.

Source

pub fn get_guild_bans<'a>( &'a self, guild_id: GuildId, query: &'a GetGuildBans, ) -> impl Future<Output = Result<Vec<Ban>, Error>> + Send + 'a

Get Guild Bans: returns a page of bans, sorted by user ID. Needs BAN_MEMBERS or VIEW_AUDIT_LOG.

discord.js counterpart: GuildBanManager#fetch().

§Errors

See Rest::request.

Source

pub fn get_guild_ban( &self, guild_id: GuildId, user_id: UserId, ) -> impl Future<Output = Result<Ban, Error>> + Send + '_

Get Guild Ban: returns the ban of a user. Needs BAN_MEMBERS or VIEW_AUDIT_LOG.

discord.js counterpart: GuildBanManager#fetch(user).

§Errors

See Rest::request; 10026 Unknown Ban.

Source

pub fn create_guild_ban<'a>( &'a self, guild_id: GuildId, user_id: UserId, body: &'a CreateGuildBan, reason: Option<&'a str>, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Create Guild Ban: bans a user (member or not), optionally deleting their recent messages. Needs BAN_MEMBERS.

reason is shown in the audit log (D-086).

discord.js counterpart: GuildBanManager#create.

§Examples
use djs_model::rest::CreateGuildBan;

let mut body = CreateGuildBan::default();
body.delete_message_seconds = Some(24 * 60 * 60);
rest.create_guild_ban(guild_id, user_id, &body, Some("Raid"))
    .await?;
§Errors

See Rest::request; 50013 Missing Permissions.

Source

pub fn remove_guild_ban<'a>( &'a self, guild_id: GuildId, user_id: UserId, reason: Option<&'a str>, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Remove Guild Ban: unbans a user. Needs BAN_MEMBERS.

reason is shown in the audit log (D-086).

discord.js counterpart: GuildBanManager#remove.

§Errors

See Rest::request; 10026 Unknown Ban.

Source

pub fn bulk_guild_ban<'a>( &'a self, guild_id: GuildId, body: &'a BulkGuildBan, reason: Option<&'a str>, ) -> impl Future<Output = Result<BulkBanResponse, Error>> + Send + 'a

Bulk Guild Ban: bans up to 200 users at once, returning who was and was not banned. Needs BAN_MEMBERS and MANAGE_GUILD.

reason is shown in the audit log (D-086).

discord.js counterpart: GuildBanManager#bulkCreate.

§Errors

See Rest::request; 500000 when none of the users could be banned.

Source§

impl Rest

Roles.

Source

pub fn get_guild_roles( &self, guild_id: GuildId, ) -> impl Future<Output = Result<Vec<Role>, Error>> + Send + '_

Get Guild Roles: returns the guild’s roles.

discord.js counterpart: RoleManager#fetch().

§Errors

See Rest::request.

Source

pub fn get_guild_role( &self, guild_id: GuildId, role_id: RoleId, ) -> impl Future<Output = Result<Role, Error>> + Send + '_

Get Guild Role: returns one role.

discord.js counterpart: RoleManager#fetch(id).

§Errors

See Rest::request; 10011 Unknown Role.

Source

pub fn get_guild_role_permissions( &self, guild_id: GuildId, role_id: RoleId, ) -> impl Future<Output = Result<Permissions, Error>> + Send + '_

Get Guild Role Permissions: returns the guild-wide permissions of a role together with @everyone (D-110).

discord.js counterpart: Role#permissions (computed locally).

§Errors

See Rest::request; 10011 Unknown Role.

Source

pub fn get_guild_role_member_counts( &self, guild_id: GuildId, ) -> impl Future<Output = Result<HashMap<RoleId, u32>, Error>> + Send + '_

Get Guild Role Member Counts: returns how many members have each role (without @everyone).

discord.js counterpart: RoleManager#fetchMemberCounts.

§Errors

See Rest::request.

Source

pub fn create_guild_role<'a>( &'a self, guild_id: GuildId, body: &'a CreateGuildRole, reason: Option<&'a str>, ) -> impl Future<Output = Result<Role, Error>> + Send + 'a

Create Guild Role: creates a role. Needs MANAGE_ROLES.

reason is shown in the audit log (D-086).

discord.js counterpart: RoleManager#create.

§Examples
use djs_model::{guild::RoleColors, rest::CreateGuildRole};

let mut body = CreateGuildRole::default();
body.name = Some("Rustacean".into());
body.colors = Some(RoleColors::solid(0xdea5_84));
body.mentionable = true;
let role = rest.create_guild_role(guild_id, &body, None).await?;
§Errors

See Rest::request; 30005 at the maximum number of roles (250).

Source

pub fn modify_guild_role_positions<'a>( &'a self, guild_id: GuildId, positions: &'a [ModifyGuildRolePosition], reason: Option<&'a str>, ) -> impl Future<Output = Result<Vec<Role>, Error>> + Send + 'a

Modify Guild Role Positions: reorders roles and returns all of them. Needs MANAGE_ROLES.

reason is shown in the audit log (D-086).

discord.js counterpart: RoleManager#setPositions.

§Errors

See Rest::request.

Source

pub fn modify_guild_role<'a>( &'a self, guild_id: GuildId, role_id: RoleId, body: &'a ModifyGuildRole, reason: Option<&'a str>, ) -> impl Future<Output = Result<Role, Error>> + Send + 'a

Modify Guild Role: changes the fields set in body. Needs MANAGE_ROLES and a higher role.

reason is shown in the audit log (D-086).

discord.js counterpart: Role#edit.

§Errors

See Rest::request.

Source

pub fn delete_guild_role<'a>( &'a self, guild_id: GuildId, role_id: RoleId, reason: Option<&'a str>, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Delete Guild Role: deletes a role. Needs MANAGE_ROLES.

reason is shown in the audit log (D-086).

discord.js counterpart: Role#delete.

§Errors

See Rest::request; 10011 Unknown Role.

Source§

impl Rest

Prune, voice regions, invites and integrations.

Source

pub fn get_guild_prune_count<'a>( &'a self, guild_id: GuildId, query: &'a GetGuildPruneCount, ) -> impl Future<Output = Result<u32, Error>> + Send + 'a

Get Guild Prune Count: returns how many members a prune would kick. Needs MANAGE_GUILD and KICK_MEMBERS (ADMINISTRATOR with the PRUNE_REQUIRES_ADMIN feature).

discord.js counterpart: GuildMemberManager#prune({ dry: true }).

§Errors

See Rest::request.

Source

pub fn begin_guild_prune<'a>( &'a self, guild_id: GuildId, body: &'a BeginGuildPrune, reason: Option<&'a str>, ) -> impl Future<Output = Result<Option<u32>, Error>> + Send + 'a

Begin Guild Prune: kicks the inactive members and returns how many, unless compute_prune_count is false. Needs the permissions of get_guild_prune_count.

reason is shown in the audit log (D-086).

discord.js counterpart: GuildMemberManager#prune.

§Errors

See Rest::request.

Source

pub fn get_guild_voice_regions( &self, guild_id: GuildId, ) -> impl Future<Output = Result<Vec<VoiceRegion>, Error>> + Send + '_

Get Guild Voice Regions: returns the voice regions available to the guild (including VIP ones).

discord.js counterpart: Guild#fetchVoiceRegions.

§Errors

See Rest::request.

Source

pub fn get_guild_invites( &self, guild_id: GuildId, ) -> impl Future<Output = Result<Vec<InviteWithMetadata>, Error>> + Send + '_

Get Guild Invites: returns the guild’s invites. Needs MANAGE_GUILD or VIEW_AUDIT_LOG; the metadata is only included with MANAGE_GUILD (D-117).

discord.js counterpart: GuildInviteManager#fetch().

§Errors

See Rest::request.

Source

pub fn get_guild_integrations( &self, guild_id: GuildId, ) -> impl Future<Output = Result<Vec<Integration>, Error>> + Send + '_

Get Guild Integrations: returns up to 50 integrations of the guild. Needs MANAGE_GUILD.

discord.js counterpart: Guild#fetchIntegrations.

§Errors

See Rest::request.

Source

pub fn delete_guild_integration<'a>( &'a self, guild_id: GuildId, integration_id: IntegrationId, reason: Option<&'a str>, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Delete Guild Integration: removes an integration with its webhooks, kicking its bot. Needs MANAGE_GUILD.

reason is shown in the audit log (D-086).

discord.js counterpart: Integration#delete.

§Errors

See Rest::request.

Source§

impl Rest

Widget, vanity URL, welcome screen, onboarding and incident actions.

Source

pub fn get_guild_widget_settings( &self, guild_id: GuildId, ) -> impl Future<Output = Result<WidgetSettings, Error>> + Send + '_

Get Guild Widget Settings: returns whether the widget is enabled and its invite channel. Needs MANAGE_GUILD.

discord.js counterpart: Guild#fetchWidgetSettings.

§Errors

See Rest::request.

Source

pub fn modify_guild_widget<'a>( &'a self, guild_id: GuildId, body: &'a ModifyGuildWidget, reason: Option<&'a str>, ) -> impl Future<Output = Result<WidgetSettings, Error>> + Send + 'a

Modify Guild Widget: changes the widget settings. Needs MANAGE_GUILD.

reason is shown in the audit log (D-086).

discord.js counterpart: Guild#setWidgetSettings.

§Errors

See Rest::request.

Source

pub fn get_guild_widget( &self, guild_id: GuildId, ) -> impl Future<Output = Result<Widget, Error>> + Send + '_

Get Guild Widget: returns the public widget data (online members, voice channels, invite).

discord.js counterpart: Client#fetchGuildWidget.

§Errors

See Rest::request; 50004 when the widget is disabled.

Source

pub fn get_guild_vanity_url( &self, guild_id: GuildId, ) -> impl Future<Output = Result<VanityUrl, Error>> + Send + '_

Get Guild Vanity URL: returns the vanity invite code and its uses. Needs MANAGE_GUILD.

discord.js counterpart: Guild#fetchVanityData.

§Errors

See Rest::request.

Source

pub fn get_guild_welcome_screen( &self, guild_id: GuildId, ) -> impl Future<Output = Result<WelcomeScreen, Error>> + Send + '_

Get Guild Welcome Screen: returns the welcome screen (needs MANAGE_GUILD when it is disabled).

discord.js counterpart: Guild#fetchWelcomeScreen.

§Errors

See Rest::request.

Source

pub fn modify_guild_welcome_screen<'a>( &'a self, guild_id: GuildId, body: &'a ModifyGuildWelcomeScreen, reason: Option<&'a str>, ) -> impl Future<Output = Result<WelcomeScreen, Error>> + Send + 'a

Modify Guild Welcome Screen: changes the welcome screen. Needs MANAGE_GUILD.

reason is shown in the audit log (D-086).

discord.js counterpart: Guild#editWelcomeScreen.

§Errors

See Rest::request.

Source

pub fn get_guild_onboarding( &self, guild_id: GuildId, ) -> impl Future<Output = Result<Onboarding, Error>> + Send + '_

Get Guild Onboarding: returns the onboarding flow.

discord.js counterpart: Guild#fetchOnboarding.

§Errors

See Rest::request.

Source

pub fn modify_guild_onboarding<'a>( &'a self, guild_id: GuildId, body: &'a ModifyGuildOnboarding, reason: Option<&'a str>, ) -> impl Future<Output = Result<Onboarding, Error>> + Send + 'a

Modify Guild Onboarding: replaces the onboarding configuration. Needs MANAGE_GUILD and MANAGE_ROLES. New prompts get generated IDs (D-118).

reason is shown in the audit log (D-086).

discord.js counterpart: Guild#editOnboarding.

§Errors

See Rest::request; 50035 when the enabled flow lacks default channels.

Source

pub fn modify_guild_incident_actions<'a>( &'a self, guild_id: GuildId, body: &'a ModifyGuildIncidentActions, ) -> impl Future<Output = Result<IncidentsData, Error>> + Send + 'a

Modify Guild Incident Actions: pauses invites or direct messages for up to 24 hours (e.g. during a raid), or ends a pause. Needs MANAGE_GUILD.

discord.js counterpart: Guild#setIncidentActions.

§Errors

See Rest::request.

Source§

impl Rest

Source

pub fn list_scheduled_events_for_guild<'a>( &'a self, guild_id: GuildId, query: &'a ListScheduledEventsForGuild, ) -> impl Future<Output = Result<Vec<GuildScheduledEvent>, Error>> + Send + 'a

List Scheduled Events for Guild: returns the guild’s scheduled and active events.

discord.js counterpart: GuildScheduledEventManager#fetch().

§Errors

See Rest::request.

Source

pub fn create_guild_scheduled_event<'a>( &'a self, guild_id: GuildId, body: &'a CreateGuildScheduledEvent, reason: Option<&'a str>, ) -> impl Future<Output = Result<GuildScheduledEvent, Error>> + Send + 'a

Create Guild Scheduled Event: plans an event. Needs CREATE_EVENTS, plus the permissions to manage the stage or join the voice channel for events there.

reason is shown in the audit log (D-086).

discord.js counterpart: GuildScheduledEventManager#create.

§Examples
use djs_model::{
    guild_scheduled_event::RecurrenceWeekday,
    rest::{CreateGuildScheduledEvent, RecurrenceRuleData},
    util::Timestamp,
};

let start = Timestamp::parse("2026-11-19T18:00:00Z")?;
let mut body = CreateGuildScheduledEvent::stage(stage, "Office hours", start);
body.recurrence_rule = Some(RecurrenceRuleData::weekly(start, RecurrenceWeekday::Thursday));
let event = rest.create_guild_scheduled_event(guild_id, &body, None).await?;
println!("Planned event {}", event.id);
§Errors

See Rest::request; 30038 at 100 events that have not ended; 50035 for a combination of fields Discord does not accept.

Source

pub fn get_guild_scheduled_event<'a>( &'a self, guild_id: GuildId, event_id: ScheduledEventId, query: &'a GetGuildScheduledEvent, ) -> impl Future<Output = Result<GuildScheduledEvent, Error>> + Send + 'a

Get Guild Scheduled Event: returns one event.

discord.js counterpart: GuildScheduledEventManager#fetch(id).

§Errors

See Rest::request; 10070 Unknown Guild Scheduled Event.

Source

pub fn modify_guild_scheduled_event<'a>( &'a self, guild_id: GuildId, event_id: ScheduledEventId, body: &'a ModifyGuildScheduledEvent, reason: Option<&'a str>, ) -> impl Future<Output = Result<GuildScheduledEvent, Error>> + Send + 'a

Modify Guild Scheduled Event: changes an event, or starts, ends or cancels it through its status. Needs MANAGE_EVENTS, or CREATE_EVENTS for events the bot created.

reason is shown in the audit log (D-086).

discord.js counterpart: GuildScheduledEvent#edit, #setStatus, GuildScheduledEventManager#edit.

§Examples
use djs_model::{guild_scheduled_event::Status, rest::ModifyGuildScheduledEvent};

let mut body = ModifyGuildScheduledEvent::default();
body.status = Some(Status::Completed);
rest.modify_guild_scheduled_event(guild_id, event_id, &body, Some("Meetup is over"))
    .await?;
§Errors

See Rest::request; 10070 Unknown Guild Scheduled Event; 180000 for an event that has already ended.

Source

pub fn delete_guild_scheduled_event( &self, guild_id: GuildId, event_id: ScheduledEventId, ) -> impl Future<Output = Result<(), Error>> + Send + '_

Delete Guild Scheduled Event: deletes an event. Needs MANAGE_EVENTS, or CREATE_EVENTS for events the bot created.

discord.js counterpart: GuildScheduledEvent#delete, GuildScheduledEventManager#delete.

§Errors

See Rest::request; 10070 Unknown Guild Scheduled Event.

Source

pub fn get_guild_scheduled_event_users<'a>( &'a self, guild_id: GuildId, event_id: ScheduledEventId, query: &'a GetGuildScheduledEventUsers, ) -> impl Future<Output = Result<Vec<GuildScheduledEventUser>, Error>> + Send + 'a

Get Guild Scheduled Event Users: returns a page of the users interested in an event, sorted by user ID (100 by default); with with_member, their member data too.

discord.js counterpart: GuildScheduledEvent#fetchSubscribers.

§Errors

See Rest::request; 10070 Unknown Guild Scheduled Event.

Source§

impl Rest

Source

pub fn get_guild_template<'a>( &'a self, template_code: &'a str, ) -> impl Future<Output = Result<GuildTemplate, Error>> + Send + 'a

Get Guild Template: resolves a template code (the part after discord.new/).

discord.js counterpart: Client#fetchGuildTemplate.

§Errors

See Rest::request; 10057 Unknown Guild Template.

Source

pub fn get_guild_templates( &self, guild_id: GuildId, ) -> impl Future<Output = Result<Vec<GuildTemplate>, Error>> + Send + '_

Get Guild Templates: returns the templates of a guild (at most one).

discord.js counterpart: Guild#fetchTemplates.

§Errors

See Rest::request.

Source

pub fn create_guild_template<'a>( &'a self, guild_id: GuildId, body: &'a CreateGuildTemplate, ) -> impl Future<Output = Result<GuildTemplate, Error>> + Send + 'a

Create Guild Template: snapshots the guild into a new template.

discord.js counterpart: Guild#createTemplate.

§Examples
use djs_model::rest::CreateGuildTemplate;

let template = rest
    .create_guild_template(guild_id, &CreateGuildTemplate::new("Study group"))
    .await?;
println!("https://discord.new/{}", template.code);
§Errors

See Rest::request; 30031 when the guild already has a template.

Source

pub fn sync_guild_template<'a>( &'a self, guild_id: GuildId, template_code: &'a str, ) -> impl Future<Output = Result<GuildTemplate, Error>> + Send + 'a

Sync Guild Template: updates the template’s snapshot to the guild’s current state.

discord.js counterpart: GuildTemplate#sync.

§Errors

See Rest::request; 10057 Unknown Guild Template.

Source

pub fn modify_guild_template<'a>( &'a self, guild_id: GuildId, template_code: &'a str, body: &'a ModifyGuildTemplate, ) -> impl Future<Output = Result<GuildTemplate, Error>> + Send + 'a

Modify Guild Template: changes the template’s name or description.

discord.js counterpart: GuildTemplate#edit.

§Errors

See Rest::request; 10057 Unknown Guild Template.

Source

pub fn delete_guild_template<'a>( &'a self, guild_id: GuildId, template_code: &'a str, ) -> impl Future<Output = Result<GuildTemplate, Error>> + Send + 'a

Delete Guild Template: deletes the template and returns it.

discord.js counterpart: GuildTemplate#delete.

§Errors

See Rest::request; 10057 Unknown Guild Template.

Source§

impl Rest

Source

pub fn create_interaction_response<'a>( &'a self, interaction_id: InteractionId, interaction_token: &'a str, response: &'a InteractionResponse, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Create Interaction Response: the initial response to an interaction, within 3 seconds of receiving it. Files of the response’s message are uploaded with it.

To get the callback (e.g. the created message), use create_interaction_response_with_response.

discord.js counterpart: reply, deferReply, update, deferUpdate, showModal, respond of the interaction classes.

§Examples
use djs_model::interaction::{InteractionResponse, MessageCallbackData};

let reply = InteractionResponse::ChannelMessageWithSource(Box::new(
    MessageCallbackData::from("Pong!"),
));
rest.create_interaction_response(interaction.id, &interaction.token, &reply)
    .await?;
§Errors

See Rest::request; 40060 if the interaction was already acknowledged, 10062 Unknown Interaction once it expired.

Source

pub fn create_interaction_response_with_response<'a>( &'a self, interaction_id: InteractionId, interaction_token: &'a str, response: &'a InteractionResponse, ) -> impl Future<Output = Result<InteractionCallbackResponse, Error>> + Send + 'a

Create Interaction Response with with_response: like create_interaction_response, but returns the callback (D-106), which holds e.g. the created message.

discord.js counterpart: the same methods with withResponse: true.

§Errors

See create_interaction_response.

Source

pub fn get_original_interaction_response<'a>( &'a self, application_id: ApplicationId, interaction_token: &'a str, ) -> impl Future<Output = Result<Message, Error>> + Send + 'a

Get Original Interaction Response: returns the message of the initial response.

discord.js counterpart: fetchReply.

§Errors

See Rest::request.

Source

pub fn edit_original_interaction_response<'a>( &'a self, application_id: ApplicationId, interaction_token: &'a str, body: &'a EditWebhookMessage, ) -> impl Future<Output = Result<Message, Error>> + Send + 'a

Edit Original Interaction Response: edits the message of the initial response (also the way to answer a deferred response).

discord.js counterpart: editReply.

§Errors

See Rest::request.

Source

pub fn delete_original_interaction_response<'a>( &'a self, application_id: ApplicationId, interaction_token: &'a str, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Delete Original Interaction Response: deletes the message of the initial response.

discord.js counterpart: deleteReply.

§Errors

See Rest::request.

Source

pub fn create_followup_message<'a>( &'a self, application_id: ApplicationId, interaction_token: &'a str, body: &'a CreateFollowupMessage, ) -> impl Future<Output = Result<Message, Error>> + Send + 'a

Create Followup Message: sends another message for the interaction and returns it.

Apps installed only for the user (not in the guild) may send at most 5 follow-ups per interaction.

discord.js counterpart: followUp.

§Errors

See Rest::request; 40094 once the maximum number of follow-ups is reached.

Source

pub fn get_followup_message<'a>( &'a self, application_id: ApplicationId, interaction_token: &'a str, message_id: MessageId, ) -> impl Future<Output = Result<Message, Error>> + Send + 'a

Get Followup Message: returns a follow-up message.

discord.js counterpart: fetchReply with a message ID.

§Errors

See Rest::request.

Source

pub fn edit_followup_message<'a>( &'a self, application_id: ApplicationId, interaction_token: &'a str, message_id: MessageId, body: &'a EditWebhookMessage, ) -> impl Future<Output = Result<Message, Error>> + Send + 'a

Edit Followup Message: edits a follow-up message.

discord.js counterpart: editReply with a message ID / InteractionWebhook#editMessage.

§Errors

See Rest::request.

Source

pub fn delete_followup_message<'a>( &'a self, application_id: ApplicationId, interaction_token: &'a str, message_id: MessageId, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Delete Followup Message: deletes a follow-up message.

discord.js counterpart: deleteReply with a message ID.

§Errors

See Rest::request.

Source§

impl Rest

Invites.

Source

pub fn get_invite<'a>( &'a self, invite_code: &'a str, query: &'a GetInvite, ) -> impl Future<Output = Result<Invite, Error>> + Send + 'a

Get Invite: resolves an invite code (the part after discord.gg/).

discord.js counterpart: Client#fetchInvite.

§Examples
use djs_model::rest::GetInvite;

let mut query = GetInvite::default();
query.with_counts = Some(true);
let invite = rest.get_invite("rust-lang", &query).await?;
println!("{:?} members", invite.approximate_member_count);
§Errors

See Rest::request; 10006 Unknown Invite.

Source

pub fn delete_invite<'a>( &'a self, invite_code: &'a str, reason: Option<&'a str>, ) -> impl Future<Output = Result<Invite, Error>> + Send + 'a

Delete Invite: revokes an invite and returns it. Needs MANAGE_CHANNELS on its channel or MANAGE_GUILD.

reason is shown in the audit log (D-086).

discord.js counterpart: Invite#delete, GuildInviteManager#delete.

§Errors

See Rest::request; 10006 Unknown Invite.

Source§

impl Rest

Target users: the users allowed to see and accept an invite. Each endpoint needs the bot to be the inviter or to have MANAGE_GUILD (reading also works with VIEW_AUDIT_LOG).

Source

pub fn get_target_users<'a>( &'a self, invite_code: &'a str, ) -> impl Future<Output = Result<Vec<UserId>, Error>> + Send + 'a

Get Target Users: returns the users allowed to accept the invite. Discord sends a CSV file, which is parsed (D-126).

discord.js counterpart: GuildInviteManager#fetchTargetUsers (the raw file).

§Errors

See Rest::request; ErrorKind::Deserialize when a line of the file is not a user ID; 10129 when the invite has no target users.

Source

pub fn add_target_user<'a>( &'a self, invite_code: &'a str, user_id: UserId, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Add Target User: allows one more user to accept the invite.

discord.js counterpart: none.

§Errors

See Rest::request; 30084 at the limit of target users.

Source

pub fn remove_target_user<'a>( &'a self, invite_code: &'a str, user_id: UserId, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Remove Target User: no longer allows a user to accept the invite.

discord.js counterpart: none.

§Errors

See Rest::request.

Source

pub fn update_target_users<'a>( &'a self, invite_code: &'a str, file: &'a FileUpload, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Update Target Users: replaces the users allowed to accept the invite with those of a CSV file — build it with [FileUpload::target_users] (D-127). Discord processes the file in the background; follow it with get_target_users_job_status.

discord.js counterpart: GuildInviteManager#updateTargetUsers.

§Examples
use djs_model::rest::FileUpload;

rest.update_target_users(invite_code, &FileUpload::target_users(members))
    .await?;
§Errors

See Rest::request; 400 listing the invalid lines of the file; 40114 while a previous file is still being processed.

Source

pub fn bulk_add_target_users<'a>( &'a self, invite_code: &'a str, body: &'a BulkTargetUsers, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Bulk-Add Target Users: allows up to 1000 more users to accept the invite.

discord.js counterpart: none.

§Errors

See Rest::request; 30084 at the limit of target users.

Source

pub fn bulk_delete_target_users<'a>( &'a self, invite_code: &'a str, body: &'a BulkTargetUsers, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Bulk-Delete Target Users: no longer allows up to 1000 users to accept the invite.

discord.js counterpart: none.

§Errors

See Rest::request.

Source

pub fn get_target_users_job_status<'a>( &'a self, invite_code: &'a str, ) -> impl Future<Output = Result<InviteTargetUsersJobStatus, Error>> + Send + 'a

Get Target Users Job Status: returns the progress of processing the invite’s target users file.

discord.js counterpart: GuildInviteManager#fetchTargetUsersJobStatus.

§Errors

See Rest::request; 10124 when there is no job for the invite.

Source§

impl Rest

Lobbies.

Source

pub fn create_lobby<'a>( &'a self, body: &'a CreateLobby, ) -> impl Future<Output = Result<Lobby, Error>> + Send + 'a

Create Lobby: creates a lobby with the given members. Social SDK clients cannot join or leave it themselves.

discord.js counterpart: none.

§Examples
use djs_model::rest::{CreateLobby, LobbyMemberData};

let mut body = CreateLobby::default();
body.members = players.into_iter().map(LobbyMemberData::new).collect();
let lobby = rest.create_lobby(&body).await?;
println!("Lobby {} has {} members", lobby.id, lobby.members.len());
§Errors

See Rest::request.

Source

pub fn create_or_join_lobby<'a>( &'a self, body: &'a CreateOrJoinLobby, ) -> impl Future<Output = Result<Lobby, Error>> + Send + 'a

Create or Join Lobby: joins the application’s lobby with the body’s secret, creating it if there is none. Needs the player’s access token with the sdk.social_layer scope.

discord.js counterpart: none.

§Errors

See Rest::request.

Source

pub fn get_lobby( &self, lobby_id: LobbyId, ) -> impl Future<Output = Result<Lobby, Error>> + Send + '_

Get Lobby: returns a lobby with its members.

discord.js counterpart: none.

§Errors

See Rest::request.

Source

pub fn modify_lobby<'a>( &'a self, lobby_id: LobbyId, body: &'a ModifyLobby, ) -> impl Future<Output = Result<Lobby, Error>> + Send + 'a

Modify Lobby: changes a lobby’s metadata, members or idle timeout and returns it.

discord.js counterpart: none.

§Errors

See Rest::request.

Source

pub fn delete_lobby( &self, lobby_id: LobbyId, ) -> impl Future<Output = Result<(), Error>> + Send + '_

Delete Lobby: deletes a lobby; deleting one that is already gone succeeds too.

discord.js counterpart: none.

§Errors

See Rest::request.

Source§

impl Rest

Lobby members.

Source

pub fn add_lobby_member<'a>( &'a self, lobby_id: LobbyId, user_id: UserId, body: &'a AddLobbyMember, ) -> impl Future<Output = Result<LobbyMember, Error>> + Send + 'a

Add a Member to a Lobby: adds a user to a lobby, or updates the member if they are in it already.

discord.js counterpart: none.

§Errors

See Rest::request.

Source

pub fn bulk_update_lobby_members<'a>( &'a self, lobby_id: LobbyId, members: &'a [BulkLobbyMember], ) -> impl Future<Output = Result<Vec<LobbyMember>, Error>> + Send + 'a

Bulk Update Lobby Members: adds, updates or removes up to 25 members in one request (D-134) and returns the added and updated ones. Users that fail permission checks or are in too many lobbies are silently left out.

discord.js counterpart: none.

§Examples
use djs_model::rest::{BulkLobbyMember, LobbyMemberData};

rest.bulk_update_lobby_members(
    lobby_id,
    &[
        BulkLobbyMember::upsert(LobbyMemberData::new(joined)),
        BulkLobbyMember::remove(left),
    ],
)
.await?;
§Errors

See Rest::request; 10013 Unknown User for a user Discord does not know.

Source

pub fn remove_lobby_member( &self, lobby_id: LobbyId, user_id: UserId, ) -> impl Future<Output = Result<(), Error>> + Send + '_

Remove a Member from a Lobby: removes a user from a lobby; removing one who already left succeeds too.

discord.js counterpart: none.

§Errors

See Rest::request; an error for a lobby that does not exist.

Source

pub fn leave_lobby( &self, lobby_id: LobbyId, ) -> impl Future<Output = Result<(), Error>> + Send + '_

Leave Lobby: removes the player from a lobby. Needs the player’s access token.

discord.js counterpart: none.

§Errors

See Rest::request; an error for a lobby that does not exist.

Source§

impl Rest

Linked channels and lobby invites.

Link Channel to Lobby: links a guild text channel to the lobby, so their messages are shared. Needs the access token of a member with CAN_LINK_LOBBY.

discord.js counterpart: none.

§Errors

See Rest::request.

Unlink Channel from Lobby: removes the lobby’s linked channel. Needs the access token of a member with CAN_LINK_LOBBY.

discord.js counterpart: none.

§Errors

See Rest::request.

Source

pub fn create_lobby_channel_invite_for_self( &self, lobby_id: LobbyId, ) -> impl Future<Output = Result<LobbyInvite, Error>> + Send + '_

Create Lobby Channel Invite for Self: a single-use invite to the guild of the lobby’s linked channel for the player, valid for one hour. Needs the player’s access token with the sdk.social_layer scope.

discord.js counterpart: none.

§Errors

See Rest::request; an error when the lobby has no linked channel.

Source

pub fn create_lobby_channel_invite_for_user( &self, lobby_id: LobbyId, user_id: UserId, ) -> impl Future<Output = Result<LobbyInvite, Error>> + Send + '_

Create Lobby Channel Invite for User: a single-use invite to the guild of the lobby’s linked channel for a member, valid for one hour.

discord.js counterpart: none.

§Errors

See Rest::request; an error when the lobby has no linked channel.

Source§

impl Rest

Lobby messages.

Source

pub fn send_lobby_message<'a>( &'a self, lobby_id: LobbyId, body: &'a SendLobbyMessage, ) -> impl Future<Output = Result<LobbyMessage, Error>> + Send + 'a

Send Lobby Message: sends a message to the lobby (and its linked channel). Needs the access token of a member with the sdk.social_layer scope.

discord.js counterpart: none.

§Errors

See Rest::request.

Source

pub fn get_lobby_messages<'a>( &'a self, lobby_id: LobbyId, query: &'a GetLobbyMessages, ) -> impl Future<Output = Result<Vec<LobbyMessage>, Error>> + Send + 'a

Get Lobby Messages: returns the lobby’s most recent messages (50 by default). Needs the access token of a member with the sdk.social_layer scope.

discord.js counterpart: none.

§Errors

See Rest::request.

Source

pub fn update_lobby_message_moderation_metadata<'a>( &'a self, lobby_id: LobbyId, message_id: MessageId, metadata: &'a LobbyMetadata, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Update Lobby Message Moderation Metadata: sets the app’s moderation decision for a message (up to 5 keys of at most 1024 characters, values of at most 2000), delivered to Social SDK clients as an update.

discord.js counterpart: none.

§Errors

See Rest::request.

Source§

impl Rest

Source

pub fn get_channel_messages<'a>( &'a self, channel_id: ChannelId, query: &'a GetChannelMessages, ) -> impl Future<Output = Result<Vec<Message>, Error>> + Send + 'a

Get Channel Messages: returns messages of a channel, newest first.

Needs VIEW_CHANNEL (and CONNECT in voice channels); without READ_MESSAGE_HISTORY the list is empty.

discord.js counterpart: MessageManager#fetch with options.

§Examples
use djs_model::rest::GetChannelMessages;

let mut query = GetChannelMessages::default();
query.limit = Some(10);
for message in rest.get_channel_messages(channel_id, &query).await? {
    println!("{}: {}", message.author.username, message.content);
}
§Errors

See Rest::request.

Source

pub fn search_guild_messages<'a>( &'a self, guild_id: GuildId, query: &'a SearchGuildMessages, ) -> impl Future<Output = Result<MessageSearchResults, Error>> + Send + 'a

Search Guild Messages: searches the messages of a guild (without their reactions).

Needs READ_MESSAGE_HISTORY, and depends on the MESSAGE_CONTENT privileged intent. The search may return fewer messages than the limit, so page with offset or the IDs rather than by counting.

discord.js counterpart: none (discord.js does not wrap this endpoint).

§Examples
use djs_model::rest::SearchGuildMessages;
use djs_rest::ErrorKind;

let mut query = SearchGuildMessages::default();
query.content = Some("release notes".into());
let results = loop {
    match rest.search_guild_messages(guild_id, &query).await {
        Err(error) => match error.kind() {
            ErrorKind::NotYetIndexed { retry_after, .. } => {
                tokio::time::sleep((*retry_after).max(std::time::Duration::from_secs(1))).await;
            }
            _ => return Err(error),
        },
        Ok(results) => break results,
    }
};
println!("{} matching messages", results.total_results);
§Errors

ErrorKind::NotYetIndexed while the guild is not indexed yet (D-104); otherwise see Rest::request.

Source

pub fn get_channel_message( &self, channel_id: ChannelId, message_id: MessageId, ) -> impl Future<Output = Result<Message, Error>> + Send + '_

Get Channel Message: returns one message.

Needs VIEW_CHANNEL and READ_MESSAGE_HISTORY (and CONNECT in voice channels).

discord.js counterpart: MessageManager#fetch with an ID.

§Errors

See Rest::request; 10008 Unknown Message if it does not exist.

Source

pub fn create_message<'a>( &'a self, channel_id: ChannelId, body: &'a CreateMessage, ) -> impl Future<Output = Result<Message, Error>> + Send + 'a

Create Message: sends a message to a channel and returns it. With files, the request is sent as multipart/form-data.

Requires the SEND_MESSAGES permission in guild channels (and SEND_MESSAGES_IN_THREADS in threads); replies need READ_MESSAGE_HISTORY, TTS messages SEND_TTS_MESSAGES.

discord.js counterpart: TextChannel#send.

§Errors

See Rest::request. Common API errors: 50001 Missing Access, 50013 Missing Permissions, 50035 Invalid Form Body.

Source

pub fn crosspost_message( &self, channel_id: ChannelId, message_id: MessageId, ) -> impl Future<Output = Result<Message, Error>> + Send + '_

Crosspost Message: publishes a message of an announcement channel to the channels following it.

Needs SEND_MESSAGES for the bot’s own messages, plus MANAGE_MESSAGES for others’.

discord.js counterpart: Message#crosspost.

§Errors

See Rest::request; 40033 if the message was already published.

Source

pub fn create_reaction<'a>( &'a self, channel_id: ChannelId, message_id: MessageId, emoji: ReactionEmoji<'a>, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Create Reaction: reacts to a message as the bot.

Needs READ_MESSAGE_HISTORY, and ADD_REACTIONS when nobody has reacted with this emoji yet.

discord.js counterpart: Message#react.

§Examples
use djs_rest::ReactionEmoji;

rest.create_reaction(channel_id, message_id, ReactionEmoji::Unicode("👍"))
    .await?;
§Errors

See Rest::request; 10014 Unknown Emoji for an emoji the bot cannot use.

Source

pub fn delete_own_reaction<'a>( &'a self, channel_id: ChannelId, message_id: MessageId, emoji: ReactionEmoji<'a>, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Delete Own Reaction: removes the bot’s reaction.

discord.js counterpart: ReactionUserManager#remove for the client user.

§Errors

See Rest::request.

Source

pub fn delete_user_reaction<'a>( &'a self, channel_id: ChannelId, message_id: MessageId, emoji: ReactionEmoji<'a>, user_id: UserId, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Delete User Reaction: removes another user’s reaction. Needs MANAGE_MESSAGES.

discord.js counterpart: ReactionUserManager#remove.

§Errors

See Rest::request.

Source

pub fn get_reactions<'a>( &'a self, channel_id: ChannelId, message_id: MessageId, emoji: ReactionEmoji<'a>, query: &'a GetReactions, ) -> impl Future<Output = Result<Vec<User>, Error>> + Send + 'a

Get Reactions: returns the users who reacted with an emoji.

discord.js counterpart: ReactionUserManager#fetch.

§Errors

See Rest::request.

Source

pub fn delete_all_reactions( &self, channel_id: ChannelId, message_id: MessageId, ) -> impl Future<Output = Result<(), Error>> + Send + '_

Delete All Reactions: removes every reaction of a message. Needs MANAGE_MESSAGES.

discord.js counterpart: ReactionManager#removeAll.

§Errors

See Rest::request.

Source

pub fn delete_all_reactions_for_emoji<'a>( &'a self, channel_id: ChannelId, message_id: MessageId, emoji: ReactionEmoji<'a>, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Delete All Reactions for Emoji: removes every reaction with one emoji. Needs MANAGE_MESSAGES.

discord.js counterpart: MessageReaction#remove.

§Errors

See Rest::request.

Source

pub fn edit_message<'a>( &'a self, channel_id: ChannelId, message_id: MessageId, body: &'a EditMessage, ) -> impl Future<Output = Result<Message, Error>> + Send + 'a

Edit Message: changes a message and returns it. With files, the request is sent as multipart/form-data; see [EditMessage] for how attachments are kept.

The author can edit everything; others with MANAGE_MESSAGES only the flags.

discord.js counterpart: Message#edit.

§Errors

See Rest::request; 50005 when editing someone else’s content.

Source

pub fn delete_message( &self, channel_id: ChannelId, message_id: MessageId, ) -> impl Future<Output = Result<(), Error>> + Send + '_

Delete Message: deletes a message; others’ messages need MANAGE_MESSAGES in guild channels.

Messages older than two weeks are deleted under a separate, stricter rate limit, which the client tracks on its own.

discord.js counterpart: Message#delete.

§Errors

See Rest::request.

Source

pub fn bulk_delete_messages<'a>( &'a self, channel_id: ChannelId, body: &'a BulkDeleteMessages, reason: Option<&'a str>, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Bulk Delete Messages: deletes 2 to 100 messages at once (guild channels only, none older than two weeks). Needs MANAGE_MESSAGES.

reason is shown in the audit log (D-086).

discord.js counterpart: TextChannel#bulkDelete.

§Errors

See Rest::request; 50034 if a message is too old, 50016 for fewer than 2 or more than 100 messages.

Source

pub fn get_channel_pins<'a>( &'a self, channel_id: ChannelId, query: &'a GetChannelPins, ) -> impl Future<Output = Result<ChannelPins, Error>> + Send + 'a

Get Channel Pins: returns a page of the pinned messages, newest first.

Needs VIEW_CHANNEL; without READ_MESSAGE_HISTORY the list is empty.

discord.js counterpart: MessageManager#fetchPins.

§Errors

See Rest::request.

Source

pub fn pin_message<'a>( &'a self, channel_id: ChannelId, message_id: MessageId, reason: Option<&'a str>, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Pin Message: pins a message. Needs PIN_MESSAGES.

reason is shown in the audit log (D-086).

discord.js counterpart: Message#pin.

§Errors

See Rest::request; 30003 when the channel has the maximum number of pins.

Source

pub fn unpin_message<'a>( &'a self, channel_id: ChannelId, message_id: MessageId, reason: Option<&'a str>, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Unpin Message: unpins a message. Needs PIN_MESSAGES.

reason is shown in the audit log (D-086).

discord.js counterpart: Message#unpin.

§Errors

See Rest::request.

Source§

impl Rest

Source

pub fn get_current_bot_application_information( &self, ) -> impl Future<Output = Result<Application, Error>> + Send + '_

Get Current Bot Application Information: returns the bot’s application, like get_current_application.

discord.js counterpart: ClientApplication#fetch.

§Errors

See Rest::request.

Source

pub fn get_current_authorization_information( &self, ) -> impl Future<Output = Result<CurrentAuthorizationInformation, Error>> + Send + '_

Get Current Authorization Information: returns what the client’s access token is authorized for, when it expires and — with the identify scope — who authorized it. Needs a client built with bearer_token.

discord.js counterpart: none.

§Errors

See Rest::request; 401 for a bot token or an invalid access token.

Source

pub fn exchange_code<'a>( &'a self, credentials: &'a OAuth2Credentials, code: &'a str, redirect_uri: &'a str, ) -> impl Future<Output = Result<AccessTokenResponse, Error>> + Send + 'a

Exchanges the code of an authorization code grant redirect for the user’s access token. redirect_uri must be the one of the authorization URL.

discord.js counterpart: none.

§Examples

See the oauth2 module.

§Errors

See Rest::request; 400 for an invalid, expired or already used code or a mismatched redirect URI, 401 for wrong credentials. Discord’s OAuth2 error bodies ({"error": "invalid_grant", …}) are not parsed into an ApiError.

Source

pub fn refresh_access_token<'a>( &'a self, credentials: &'a OAuth2Credentials, refresh_token: &'a str, ) -> impl Future<Output = Result<AccessTokenResponse, Error>> + Send + 'a

Refreshes an access token: returns a new access token and a new refresh token.

discord.js counterpart: none.

§Errors

See Rest::request; 400 for an invalid or revoked refresh token.

Source

pub fn client_credentials_grant<'a>( &'a self, credentials: &'a OAuth2Credentials, scopes: &'a [Scope], ) -> impl Future<Output = Result<AccessTokenResponse, Error>> + Send + 'a

The client credentials grant: an access token of the application’s owner for scopes, without a refresh token — mostly for testing. Team applications may only request identify and applications.commands.update.

discord.js counterpart: none.

§Errors

See Rest::request; 400 for a scope that is not allowed.

Source

pub fn revoke_token<'a>( &'a self, credentials: &'a OAuth2Credentials, token: &'a str, hint: Option<TokenTypeHint>, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Revokes an access or refresh token. Discord revokes every token of the authorization, whichever is passed.

discord.js counterpart: none.

§Errors

See Rest::request.

Source§

impl Rest

Source

pub fn get_answer_voters<'a>( &'a self, channel_id: ChannelId, message_id: MessageId, answer_id: u32, query: &'a GetAnswerVoters, ) -> impl Future<Output = Result<Vec<User>, Error>> + Send + 'a

Get Answer Voters: returns a page of the users who voted for an answer, sorted by user ID (25 by default).

answer_id is the answer’s answer_id.

discord.js counterpart: PollAnswerVoterManager#fetch (PollAnswer#voters).

§Examples
use djs_model::rest::GetAnswerVoters;

let mut query = GetAnswerVoters::default();
query.limit = Some(100);
let voters = rest.get_answer_voters(channel_id, message_id, 1, &query).await?;
println!("{} users voted for the first answer", voters.len());
§Errors

See Rest::request; 10008 Unknown Message.

Source

pub fn end_poll( &self, channel_id: ChannelId, message_id: MessageId, ) -> impl Future<Output = Result<Message, Error>> + Send + '_

End Poll: ends a poll now and returns its message. Only polls the bot created can be ended.

discord.js counterpart: Poll#end, MessageManager#endPoll.

§Errors

See Rest::request; 10008 Unknown Message; 520001 for a poll that has already ended.

Source§

impl Rest

Source

pub fn list_skus( &self, application_id: ApplicationId, ) -> impl Future<Output = Result<Vec<Sku>, Error>> + Send + '_

List SKUs: returns the application’s SKUs. A subscription appears as two SKUs; entitlements and tests use the one of type Subscription.

discord.js counterpart: ClientApplication#fetchSKUs.

§Errors

See Rest::request.

Source§

impl Rest

Playing sounds and the default sounds.

Source

pub fn send_soundboard_sound<'a>( &'a self, channel_id: ChannelId, body: &'a SendSoundboardSound, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Send Soundboard Sound: plays a sound in a voice channel.

The bot must be connected to the channel, neither muted, deafened nor suppressed, and needs SPEAK and USE_SOUNDBOARD (plus USE_EXTERNAL_SOUNDS for a sound of another guild).

discord.js counterpart: VoiceChannel#sendSoundboardSound.

§Examples
use djs_model::rest::SendSoundboardSound;

let sounds = rest.list_default_soundboard_sounds().await?;
if let Some(sound) = sounds.iter().find(|sound| sound.name == "quack") {
    rest.send_soundboard_sound(channel_id, &SendSoundboardSound::new(sound.sound_id))
        .await?;
}
§Errors

See Rest::request; 10097 Unknown Sound; 50013 Missing Permissions.

Source

pub fn list_default_soundboard_sounds( &self, ) -> impl Future<Output = Result<Vec<SoundboardSound>, Error>> + Send + '_

List Default Soundboard Sounds: returns the sounds every user can play.

discord.js counterpart: Client#fetchDefaultSoundboardSounds.

§Errors

See Rest::request.

Source§

impl Rest

Guild soundboard sounds.

Source

pub fn list_guild_soundboard_sounds( &self, guild_id: GuildId, ) -> impl Future<Output = Result<Vec<SoundboardSound>, Error>> + Send + '_

List Guild Soundboard Sounds: returns every custom sound of a guild. [SoundboardSound::user] is included with the CREATE_GUILD_EXPRESSIONS or MANAGE_GUILD_EXPRESSIONS permission. Discord wraps the list in an object; it is unwrapped.

discord.js counterpart: GuildSoundboardSoundManager#fetch().

§Errors

See Rest::request.

Source

pub fn get_guild_soundboard_sound( &self, guild_id: GuildId, sound_id: SoundboardSoundId, ) -> impl Future<Output = Result<SoundboardSound, Error>> + Send + '_

Get Guild Soundboard Sound: returns one custom sound of a guild.

discord.js counterpart: GuildSoundboardSoundManager#fetch(id).

§Errors

See Rest::request; 10097 Unknown Sound.

Source

pub fn create_guild_soundboard_sound<'a>( &'a self, guild_id: GuildId, body: &'a CreateGuildSoundboardSound, reason: Option<&'a str>, ) -> impl Future<Output = Result<SoundboardSound, Error>> + Send + 'a

Create Guild Soundboard Sound: uploads a custom sound (MP3 or Ogg, at most 512 KB and 5.2 seconds). Needs CREATE_GUILD_EXPRESSIONS.

reason is shown in the audit log (D-086).

discord.js counterpart: GuildSoundboardSoundManager#create.

§Examples
use djs_model::{rest::CreateGuildSoundboardSound, util::SoundData};

let sound = SoundData::new(std::fs::read("tada.mp3")?)?;
let mut body = CreateGuildSoundboardSound::new("tada", sound);
body.emoji_name = Some("🎉".into());
rest.create_guild_soundboard_sound(guild_id, &body, None).await?;
§Errors

See Rest::request; 30045 when the guild has no free sound slot.

Source

pub fn modify_guild_soundboard_sound<'a>( &'a self, guild_id: GuildId, sound_id: SoundboardSoundId, body: &'a ModifyGuildSoundboardSound, reason: Option<&'a str>, ) -> impl Future<Output = Result<SoundboardSound, Error>> + Send + 'a

Modify Guild Soundboard Sound: changes a sound’s name, volume or emoji. Needs MANAGE_GUILD_EXPRESSIONS, or CREATE_GUILD_EXPRESSIONS for sounds the bot created.

reason is shown in the audit log (D-086).

discord.js counterpart: SoundboardSound#edit, GuildSoundboardSoundManager#edit.

§Errors

See Rest::request; 10097 Unknown Sound.

Source

pub fn delete_guild_soundboard_sound<'a>( &'a self, guild_id: GuildId, sound_id: SoundboardSoundId, reason: Option<&'a str>, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Delete Guild Soundboard Sound: deletes a custom sound. Needs MANAGE_GUILD_EXPRESSIONS, or CREATE_GUILD_EXPRESSIONS for sounds the bot created.

reason is shown in the audit log (D-086).

discord.js counterpart: SoundboardSound#delete, GuildSoundboardSoundManager#delete.

§Errors

See Rest::request; 10097 Unknown Sound.

Source§

impl Rest

Source

pub fn create_stage_instance<'a>( &'a self, body: &'a CreateStageInstance, reason: Option<&'a str>, ) -> impl Future<Output = Result<StageInstance, Error>> + Send + 'a

Create Stage Instance: opens a stage in a stage channel.

reason is shown in the audit log (D-086).

discord.js counterpart: StageInstanceManager#create.

§Examples
use djs_model::rest::CreateStageInstance;

rest.create_stage_instance(&CreateStageInstance::new(stage, "Weekly Q&A"), None)
    .await?;
§Errors

See Rest::request; 150006 when the stage is already open.

Source

pub fn get_stage_instance( &self, channel_id: ChannelId, ) -> impl Future<Output = Result<StageInstance, Error>> + Send + '_

Get Stage Instance: returns the open stage of a stage channel.

discord.js counterpart: StageInstanceManager#fetch.

§Errors

See Rest::request; 10067 Unknown Stage Instance when no stage is open.

Source

pub fn modify_stage_instance<'a>( &'a self, channel_id: ChannelId, body: &'a ModifyStageInstance, reason: Option<&'a str>, ) -> impl Future<Output = Result<StageInstance, Error>> + Send + 'a

Modify Stage Instance: changes the topic or privacy of an open stage.

reason is shown in the audit log (D-086).

discord.js counterpart: StageInstance#edit, #setTopic, StageInstanceManager#edit.

§Errors

See Rest::request; 10067 Unknown Stage Instance.

Source

pub fn delete_stage_instance<'a>( &'a self, channel_id: ChannelId, reason: Option<&'a str>, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Delete Stage Instance: closes a stage.

reason is shown in the audit log (D-086).

discord.js counterpart: StageInstance#delete, StageInstanceManager#delete.

§Errors

See Rest::request; 10067 Unknown Stage Instance.

Source§

impl Rest

Stickers and sticker packs.

Source

pub fn get_sticker( &self, sticker_id: StickerId, ) -> impl Future<Output = Result<Sticker, Error>> + Send + '_

Get Sticker: returns any sticker by ID — a standard sticker of a pack or a guild sticker.

discord.js counterpart: Client#fetchSticker.

§Errors

See Rest::request; 10060 Unknown Sticker.

Source

pub fn list_sticker_packs( &self, ) -> impl Future<Output = Result<Vec<StickerPack>, Error>> + Send + '_

List Sticker Packs: returns Discord’s standard sticker packs. Discord wraps the list in an object; it is unwrapped.

discord.js counterpart: Client#fetchStickerPacks().

§Errors

See Rest::request.

Source

pub fn get_sticker_pack( &self, pack_id: StickerPackId, ) -> impl Future<Output = Result<StickerPack, Error>> + Send + '_

Get Sticker Pack: returns one of Discord’s standard sticker packs.

discord.js counterpart: Client#fetchStickerPacks({ packId }).

§Errors

See Rest::request; 10061 Unknown Sticker Pack.

Source§

impl Rest

Guild stickers.

Source

pub fn list_guild_stickers( &self, guild_id: GuildId, ) -> impl Future<Output = Result<Vec<Sticker>, Error>> + Send + '_

List Guild Stickers: returns every custom sticker of a guild. [Sticker::user] is included with the CREATE_GUILD_EXPRESSIONS or MANAGE_GUILD_EXPRESSIONS permission.

discord.js counterpart: GuildStickerManager#fetch().

§Errors

See Rest::request.

Source

pub fn get_guild_sticker( &self, guild_id: GuildId, sticker_id: StickerId, ) -> impl Future<Output = Result<Sticker, Error>> + Send + '_

Get Guild Sticker: returns one custom sticker of a guild.

discord.js counterpart: GuildStickerManager#fetch(id).

§Errors

See Rest::request; 10060 Unknown Sticker.

Source

pub fn create_guild_sticker<'a>( &'a self, guild_id: GuildId, body: &'a CreateGuildSticker, reason: Option<&'a str>, ) -> impl Future<Output = Result<Sticker, Error>> + Send + 'a

Create Guild Sticker: uploads a custom sticker. Needs CREATE_GUILD_EXPRESSIONS; a guild has 5 sticker slots, and more with each boost level.

The body is sent as multipart/form-data fields (name, description, tags, file). reason is shown in the audit log (D-086).

discord.js counterpart: GuildStickerManager#create.

§Examples
use djs_model::rest::{CreateGuildSticker, FileUpload};

let file = FileUpload::new("wave.png", std::fs::read("wave.png")?);
let mut body = CreateGuildSticker::new("Wave", "wave", file);
body.description = "Say hello".into();
let sticker = rest.create_guild_sticker(guild_id, &body, None).await?;
println!("Created sticker {}", sticker.id);
§Errors

See Rest::request; 30039 when the guild has no free sticker slot; 50045 when the file is too large; 50081 for an invalid file.

Source

pub fn modify_guild_sticker<'a>( &'a self, guild_id: GuildId, sticker_id: StickerId, body: &'a ModifyGuildSticker, reason: Option<&'a str>, ) -> impl Future<Output = Result<Sticker, Error>> + Send + 'a

Modify Guild Sticker: changes a sticker’s name, description or tags. Needs MANAGE_GUILD_EXPRESSIONS, or CREATE_GUILD_EXPRESSIONS for stickers the bot created.

reason is shown in the audit log (D-086).

discord.js counterpart: Sticker#edit, GuildStickerManager#edit.

§Errors

See Rest::request; 10060 Unknown Sticker.

Source

pub fn delete_guild_sticker<'a>( &'a self, guild_id: GuildId, sticker_id: StickerId, reason: Option<&'a str>, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Delete Guild Sticker: deletes a custom sticker. Needs MANAGE_GUILD_EXPRESSIONS, or CREATE_GUILD_EXPRESSIONS for stickers the bot created.

reason is shown in the audit log (D-086).

discord.js counterpart: Sticker#delete, GuildStickerManager#delete.

§Errors

See Rest::request; 10060 Unknown Sticker.

Source§

impl Rest

Source

pub fn list_sku_subscriptions<'a>( &'a self, sku_id: SkuId, query: &'a ListSkuSubscriptions, ) -> impl Future<Output = Result<Vec<Subscription>, Error>> + Send + 'a

List SKU Subscriptions: returns a page of the subscriptions that include the SKU (50 by default). With a bot token, user_id is required.

discord.js counterpart: SubscriptionManager#fetch.

§Examples
use djs_model::rest::ListSkuSubscriptions;

let mut query = ListSkuSubscriptions::default();
query.user_id = Some(user_id);
for subscription in rest.list_sku_subscriptions(sku_id, &query).await? {
    println!("{:?} until {}", subscription.status, subscription.current_period_end);
}
§Errors

See Rest::request; 10027 Unknown SKU.

Source

pub fn get_sku_subscription( &self, sku_id: SkuId, subscription_id: SubscriptionId, ) -> impl Future<Output = Result<Subscription, Error>> + Send + '_

Get SKU Subscription: returns one subscription.

discord.js counterpart: SubscriptionManager#fetch({ subscriptionId }).

§Errors

See Rest::request; 10027 Unknown SKU.

Source§

impl Rest

Source

pub fn get_current_user( &self, ) -> impl Future<Output = Result<CurrentUser, Error>> + Send + '_

Get Current User: returns the bot’s own user (or, with a bearer token, the authorizing user’s; the email needs the email scope).

discord.js counterpart: Client#user (from the READY event).

§Errors

See Rest::request; 401 Unauthorized for an invalid token.

Source

pub fn get_user( &self, user_id: UserId, ) -> impl Future<Output = Result<User, Error>> + Send + '_

Get User: returns any user by ID.

discord.js counterpart: UserManager#fetch.

§Errors

See Rest::request; 10013 Unknown User.

Source

pub fn modify_current_user<'a>( &'a self, body: &'a ModifyCurrentUser, ) -> impl Future<Output = Result<CurrentUser, Error>> + Send + 'a

Modify Current User: changes the bot’s username, avatar or banner.

discord.js counterpart: ClientUser#edit, #setUsername, #setAvatar.

§Examples
use djs_model::{rest::ModifyCurrentUser, util::{ImageData, Patch}};

let mut body = ModifyCurrentUser::default();
body.avatar = Patch::Set(ImageData::new(std::fs::read("avatar.png")?)?);
rest.modify_current_user(&body).await?;
§Errors

See Rest::request; 50035 when the username is taken or changed too often.

Source

pub fn get_current_user_guilds<'a>( &'a self, query: &'a GetCurrentUserGuilds, ) -> impl Future<Output = Result<Vec<CurrentUserGuild>, Error>> + Send + 'a

Get Current User Guilds: returns a page of the current user’s guilds (200 by default), sorted by ID. With a bearer token, needs the guilds scope.

Bots with large bot sharding must set shard.

discord.js counterpart: GuildManager#fetch().

§Errors

See Rest::request.

Source

pub fn get_current_user_guild_member( &self, guild_id: GuildId, ) -> impl Future<Output = Result<Member, Error>> + Send + '_

Get Current User Guild Member: returns the authorizing user’s membership of a guild. Needs a bearer token with the guilds.members.read scope.

discord.js counterpart: none (REST#get(Routes.userGuildMember(guildId))).

§Errors

See Rest::request; 10004 Unknown Guild when the user is not in it.

Source

pub fn leave_guild( &self, guild_id: GuildId, ) -> impl Future<Output = Result<(), Error>> + Send + '_

Leave Guild: makes the bot leave a guild.

discord.js counterpart: Guild#leave.

§Errors

See Rest::request; 10004 Unknown Guild.

Source

pub fn create_dm<'a>( &'a self, body: &'a CreateDm, ) -> impl Future<Output = Result<Channel, Error>> + Send + 'a

Create DM: opens (or returns the existing) DM channel with a user. Send messages to it with create_message.

DMs should follow a user action; opening many quickly gets the bot rate limited or blocked from opening more.

discord.js counterpart: User#createDM.

§Examples
use djs_model::rest::{CreateDm, CreateMessage};

let dm = rest.create_dm(&CreateDm::new(user_id)).await?;
rest.create_message(dm.id(), &CreateMessage::from("Your report was received."))
    .await?;
§Errors

See Rest::request; 50007 when the user does not accept DMs from the bot (on the message, not here).

Source

pub fn create_group_dm<'a>( &'a self, body: &'a CreateGroupDm, ) -> impl Future<Output = Result<Channel, Error>> + Send + 'a

Create Group DM: creates a group DM with users who granted the application gdm.join (max 10 active group DMs; meant for the deprecated GameBridge SDK).

discord.js counterpart: none.

§Errors

See Rest::request.

Source

pub fn get_current_user_connections( &self, ) -> impl Future<Output = Result<Vec<Connection>, Error>> + Send + '_

Get Current User Connections: returns the accounts the authorizing user connected (Twitch, GitHub, …). Needs a bearer token with the connections scope.

discord.js counterpart: none (REST#get(Routes.userConnections())).

§Errors

See Rest::request.

Source

pub fn get_current_user_application_role_connection( &self, application_id: ApplicationId, ) -> impl Future<Output = Result<ApplicationRoleConnection, Error>> + Send + '_

Get Current User Application Role Connection: returns the role connection (linked-roles data) the application stored for the authorizing user. Needs a bearer token with the role_connections.write scope.

discord.js counterpart: none.

§Errors

See Rest::request.

Source

pub fn update_current_user_application_role_connection<'a>( &'a self, application_id: ApplicationId, body: &'a ApplicationRoleConnection, ) -> impl Future<Output = Result<ApplicationRoleConnection, Error>> + Send + 'a

Update Current User Application Role Connection: replaces the role connection of the authorizing user and returns it. Needs a bearer token with the role_connections.write scope.

The metadata values are stringified ("1" for true, ISO 8601 for dates), keyed by the application’s role connection metadata keys.

discord.js counterpart: none.

§Examples
use djs_model::user::ApplicationRoleConnection;

let mut connection = ApplicationRoleConnection::default();
connection.platform_name = Some("Chess Club".into());
connection.metadata.insert("rating".into(), "1850".into());
user.update_current_user_application_role_connection(application_id, &connection)
    .await?;
§Errors

See Rest::request.

Source

pub fn delete_current_user_application_role_connection( &self, application_id: ApplicationId, ) -> impl Future<Output = Result<(), Error>> + Send + '_

Delete Current User Application Role Connection: removes the role connection of the authorizing user. Needs a bearer token with the role_connections.write scope.

discord.js counterpart: none.

§Errors

See Rest::request.

Source§

impl Rest

Source

pub fn list_voice_regions( &self, ) -> impl Future<Output = Result<Vec<VoiceRegion>, Error>> + Send + '_

List Voice Regions: returns the regions a voice or stage channel’s rtc_region can be set to.

discord.js counterpart: Client#fetchVoiceRegions.

§Errors

See Rest::request.

Source

pub fn get_current_user_voice_state( &self, guild_id: GuildId, ) -> impl Future<Output = Result<VoiceState, Error>> + Send + '_

Get Current User Voice State: returns the bot’s voice state in a guild.

discord.js counterpart: VoiceStateManager#fetch('@me').

§Errors

See Rest::request; 10065 Unknown Voice State when the bot is not in a voice channel of the guild.

Source

pub fn get_user_voice_state( &self, guild_id: GuildId, user_id: UserId, ) -> impl Future<Output = Result<VoiceState, Error>> + Send + '_

Get User Voice State: returns a member’s voice state. If they are in a voice channel, the bot needs the permission to connect to it.

discord.js counterpart: VoiceStateManager#fetch.

§Errors

See Rest::request; 10065 Unknown Voice State when the user is not in a voice channel of the guild.

Source

pub fn modify_current_user_voice_state<'a>( &'a self, guild_id: GuildId, body: &'a ModifyCurrentUserVoiceState, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Modify Current User Voice State: makes the bot a speaker or audience member of the stage it is in, or requests to speak.

discord.js counterpart: VoiceState#edit, #setSuppressed, #setRequestToSpeak.

§Examples
use djs_model::rest::ModifyCurrentUserVoiceState;

// Become a speaker (needs MUTE_MEMBERS).
let mut body = ModifyCurrentUserVoiceState::default();
body.channel_id = Some(stage);
body.suppress = Some(false);
rest.modify_current_user_voice_state(guild_id, &body).await?;
§Errors

See Rest::request.

Source

pub fn modify_user_voice_state<'a>( &'a self, guild_id: GuildId, user_id: UserId, body: &'a ModifyUserVoiceState, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Modify User Voice State: makes a member a speaker or audience member of the stage they are in. Needs MUTE_MEMBERS.

discord.js counterpart: VoiceState#edit, #setSuppressed.

§Errors

See Rest::request.

Source§

impl Rest

Managing webhooks.

Source

pub fn create_webhook<'a>( &'a self, channel_id: ChannelId, body: &'a CreateWebhook, reason: Option<&'a str>, ) -> impl Future<Output = Result<Webhook, Error>> + Send + 'a

Create Webhook: creates a webhook in a channel; its token is in the response. Needs MANAGE_WEBHOOKS.

reason is shown in the audit log (D-086).

discord.js counterpart: TextChannel#createWebhook.

§Errors

See Rest::request; 30007 at the maximum number of webhooks (15), 50035 for an invalid name.

Source

pub fn get_channel_webhooks( &self, channel_id: ChannelId, ) -> impl Future<Output = Result<Vec<Webhook>, Error>> + Send + '_

Get Channel Webhooks: returns the webhooks of a channel. Needs MANAGE_WEBHOOKS.

discord.js counterpart: TextChannel#fetchWebhooks.

§Errors

See Rest::request.

Source

pub fn get_guild_webhooks( &self, guild_id: GuildId, ) -> impl Future<Output = Result<Vec<Webhook>, Error>> + Send + '_

Get Guild Webhooks: returns the webhooks of a guild. Needs MANAGE_WEBHOOKS.

discord.js counterpart: Guild#fetchWebhooks.

§Errors

See Rest::request.

Source

pub fn get_webhook( &self, webhook_id: WebhookId, ) -> impl Future<Output = Result<Webhook, Error>> + Send + '_

Get Webhook: returns a webhook. Needs MANAGE_WEBHOOKS, unless the application owns the webhook.

discord.js counterpart: Client#fetchWebhook(id).

§Errors

See Rest::request; 10015 Unknown Webhook.

Source

pub fn get_webhook_with_token<'a>( &'a self, webhook_id: WebhookId, webhook_token: &'a str, ) -> impl Future<Output = Result<Webhook, Error>> + Send + 'a

Get Webhook with Token: returns a webhook (without its user), authenticated by its token.

discord.js counterpart: Client#fetchWebhook(id, token).

§Errors

See Rest::request; 50027 Invalid Webhook Token.

Source

pub fn modify_webhook<'a>( &'a self, webhook_id: WebhookId, body: &'a ModifyWebhook, reason: Option<&'a str>, ) -> impl Future<Output = Result<Webhook, Error>> + Send + 'a

Modify Webhook: changes a webhook’s default name or avatar, or moves it to another channel. Needs MANAGE_WEBHOOKS.

reason is shown in the audit log (D-086).

discord.js counterpart: Webhook#edit.

§Errors

See Rest::request.

Source

pub fn modify_webhook_with_token<'a>( &'a self, webhook_id: WebhookId, webhook_token: &'a str, body: &'a ModifyWebhook, ) -> impl Future<Output = Result<Webhook, Error>> + Send + 'a

Modify Webhook with Token: like modify_webhook, authenticated by the token; the channel_id cannot be changed.

discord.js counterpart: WebhookClient#edit.

§Errors

See Rest::request.

Source

pub fn delete_webhook<'a>( &'a self, webhook_id: WebhookId, reason: Option<&'a str>, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Delete Webhook: deletes a webhook for good. Needs MANAGE_WEBHOOKS.

reason is shown in the audit log (D-086).

discord.js counterpart: Webhook#delete.

§Errors

See Rest::request; 10015 Unknown Webhook.

Source

pub fn delete_webhook_with_token<'a>( &'a self, webhook_id: WebhookId, webhook_token: &'a str, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Delete Webhook with Token: deletes a webhook, authenticated by its token.

discord.js counterpart: WebhookClient#delete.

§Errors

See Rest::request.

Source§

impl Rest

Executing webhooks and their messages.

Source

pub fn execute_webhook<'a>( &'a self, webhook_id: WebhookId, webhook_token: &'a str, body: &'a ExecuteWebhook, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Execute Webhook: sends a message through a webhook without waiting for it to be saved. Files of the body are uploaded with it.

To get the created message (and errors of messages that could not be saved), use execute_webhook_and_wait (D-119, like D-106).

discord.js counterpart: WebhookClient#send / Webhook#send.

§Examples
use djs_model::rest::ExecuteWebhook;
use djs_rest::Rest;

// Webhook routes need no bot token (D-121).
let rest = Rest::builder().build();
let body = ExecuteWebhook::from("Deploy finished").username("CI");
rest.execute_webhook(webhook_id, token, &body).await?;
§Errors

See Rest::request; 50027 Invalid Webhook Token.

Source

pub fn execute_webhook_and_wait<'a>( &'a self, webhook_id: WebhookId, webhook_token: &'a str, body: &'a ExecuteWebhook, ) -> impl Future<Output = Result<Message, Error>> + Send + 'a

Execute Webhook with wait=true: sends a message through a webhook and returns it once saved.

discord.js counterpart: WebhookClient#send (which always waits).

§Errors

See Rest::request; 50006 for an empty message, 50027 Invalid Webhook Token.

Source

pub fn get_webhook_message<'a>( &'a self, webhook_id: WebhookId, webhook_token: &'a str, message_id: MessageId, thread_id: Option<ChannelId>, ) -> impl Future<Output = Result<Message, Error>> + Send + 'a

Get Webhook Message: returns a message the webhook sent (thread_id: the thread it is in).

discord.js counterpart: WebhookClient#fetchMessage.

§Errors

See Rest::request; 10008 Unknown Message.

Source

pub fn edit_webhook_message<'a>( &'a self, webhook_id: WebhookId, webhook_token: &'a str, message_id: MessageId, body: &'a EditWebhookMessage, ) -> impl Future<Output = Result<Message, Error>> + Send + 'a

Edit Webhook Message: edits a message the webhook sent; new files are uploaded and added to the kept attachments.

discord.js counterpart: WebhookClient#editMessage.

§Errors

See Rest::request; 10008 Unknown Message.

Source

pub fn delete_webhook_message<'a>( &'a self, webhook_id: WebhookId, webhook_token: &'a str, message_id: MessageId, thread_id: Option<ChannelId>, ) -> impl Future<Output = Result<(), Error>> + Send + 'a

Delete Webhook Message: deletes a message the webhook sent (thread_id: the thread it is in).

discord.js counterpart: WebhookClient#deleteMessage.

§Errors

See Rest::request; 10008 Unknown Message.

Source§

impl Rest

Source

pub fn get_gateway( &self, ) -> impl Future<Output = Result<Gateway, Error>> + Send + '_

Get Gateway: returns the gateway URL. Needs no token; bots should use get_gateway_bot, which also returns the shard count and the session start limit.

discord.js counterpart: none.

§Errors

See Rest::request.

Source

pub fn get_gateway_bot( &self, ) -> impl Future<Output = Result<GatewayBot, Error>> + Send + '_

Get Gateway Bot: returns the gateway URL, the recommended shard count and the session start limit.

discord.js counterpart: REST#get(Routes.gatewayBot()).

§Errors

See Rest::request.

Trait Implementations§

Source§

impl Clone for Rest

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Rest

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Rest

§

impl !UnwindSafe for Rest

§

impl Freeze for Rest

§

impl Send for Rest

§

impl Sync for Rest

§

impl Unpin for Rest

§

impl UnsafeUnpin for Rest

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more