code
stringlengths
40
729k
docstring
stringlengths
22
46.3k
func_name
stringlengths
1
97
language
stringclasses
1 value
repo
stringlengths
6
48
path
stringlengths
8
176
url
stringlengths
47
228
license
stringclasses
7 values
pub const fn channel(&self, channel_id: Id<ChannelMarker>) -> GetChannel<'_> { GetChannel::new(self, channel_id) }
Get a channel by its ID. # Examples Get channel `100`: ```no_run # use twilight_http::Client; # use twilight_model::id::Id; # # #[tokio::main] # async fn main() -> Result<(), Box<dyn std::error::Error>> { # let client = Client::new("my token".to_owned()); # let channel_id = Id::new(100); # let channel = client.channel(channel_id).await?; # Ok(()) } ```
channel
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn follow_news_channel( &self, channel_id: Id<ChannelMarker>, webhook_channel_id: Id<ChannelMarker>, ) -> FollowNewsChannel<'_> { FollowNewsChannel::new(self, channel_id, webhook_channel_id) }
Follows a news channel by [`Id<ChannelMarker>`]. The type returned is [`FollowedChannel`]. [`FollowedChannel`]: ::twilight_model::channel::FollowedChannel
follow_news_channel
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn channel_invites(&self, channel_id: Id<ChannelMarker>) -> GetChannelInvites<'_> { GetChannelInvites::new(self, channel_id) }
Get the invites for a guild channel. Requires the [`MANAGE_CHANNELS`] permission. This method only works if the channel is a guild channel. [`MANAGE_CHANNELS`]: twilight_model::guild::Permissions::MANAGE_CHANNELS
channel_invites
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn update_channel_permission( &self, channel_id: Id<ChannelMarker>, permission_overwrite: &PermissionOverwrite, ) -> UpdateChannelPermission<'_> { UpdateChannelPermission::new(self, channel_id, permission_overwrite) }
Update the permissions for a role or a user in a channel. # Examples: Create permission overrides for a role to view the channel, but not send messages: ```no_run # #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { # use twilight_http::Client; # let client = Client::new("my token".to_owned()); # use twilight_model::{ guild::Permissions, http::permission_overwrite::{PermissionOverwrite, PermissionOverwriteType}, id::{marker::RoleMarker, Id}, }; let channel_id = Id::new(123); let role_id: Id<RoleMarker> = Id::new(432); let permission_overwrite = PermissionOverwrite { allow: Some(Permissions::VIEW_CHANNEL), deny: Some(Permissions::SEND_MESSAGES), id: role_id.cast(), kind: PermissionOverwriteType::Role, }; client .update_channel_permission(channel_id, &permission_overwrite) .await?; # Ok(()) } ```
update_channel_permission
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn channel_webhooks(&self, channel_id: Id<ChannelMarker>) -> GetChannelWebhooks<'_> { GetChannelWebhooks::new(self, channel_id) }
Get all the webhooks of a channel.
channel_webhooks
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn current_user_guild_member( &self, guild_id: Id<GuildMarker>, ) -> GetCurrentUserGuildMember<'_> { GetCurrentUserGuildMember::new(self, guild_id) }
Get information about the current user in a guild.
current_user_guild_member
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn current_user_voice_state( &self, guild_id: Id<GuildMarker>, ) -> GetCurrentUserVoiceState<'_> { GetCurrentUserVoiceState::new(self, guild_id) }
Get voice state of the current user in a guild. # Caveats - Current user must already have joined a voice/stage channel in this guild.
current_user_voice_state
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn update_current_user_voice_state( &self, guild_id: Id<GuildMarker>, ) -> UpdateCurrentUserVoiceState<'_> { UpdateCurrentUserVoiceState::new(self, guild_id) }
Update the current user's voice state. All parameters are optional. # Caveats - `channel_id` must currently point to a stage channel. - Current user must have already joined `channel_id`.
update_current_user_voice_state
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn emojis(&self, guild_id: Id<GuildMarker>) -> GetEmojis<'_> { GetEmojis::new(self, guild_id) }
Get the emojis for a guild, by the guild's id. # Examples Get the emojis for guild `100`: ```no_run # use twilight_http::Client; # use twilight_model::id::Id; # # #[tokio::main] # async fn main() -> Result<(), Box<dyn std::error::Error>> { # let client = Client::new("my token".to_owned()); # let guild_id = Id::new(100); client.emojis(guild_id).await?; # Ok(()) } ```
emojis
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn entitlements(&self, application_id: Id<ApplicationMarker>) -> GetEntitlements<'_> { GetEntitlements::new(self, application_id) }
Get the entitlements for an application. # Examples Get emojis for the application `100`: ```no_run # use twilight_http::Client; # use twilight_model::id::Id; # #[tokio::main] # async fn main() -> Result<(), Box<dyn std::error::Error>> { # let client = Client::new("my token".to_owned()); # let application_id = Id::new(100); client.entitlements(application_id).await?; # Ok(()) } ```
entitlements
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn emoji( &self, guild_id: Id<GuildMarker>, emoji_id: Id<EmojiMarker>, ) -> GetEmoji<'_> { GetEmoji::new(self, guild_id, emoji_id) }
Get an emoji for a guild by the the guild's ID and emoji's ID. # Examples Get emoji `100` from guild `50`: ```no_run # use twilight_http::Client; # use twilight_model::id::Id; # # #[tokio::main] # async fn main() -> Result<(), Box<dyn std::error::Error>> { # let client = Client::new("my token".to_owned()); # let guild_id = Id::new(50); let emoji_id = Id::new(100); client.emoji(guild_id, emoji_id).await?; # Ok(()) } ```
emoji
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn create_emoji<'a>( &'a self, guild_id: Id<GuildMarker>, name: &'a str, image: &'a str, ) -> CreateEmoji<'a> { CreateEmoji::new(self, guild_id, name, image) }
Create an emoji in a guild. The emoji must be a Data URI, in the form of `data:image/{type};base64,{data}` where `{type}` is the image MIME type and `{data}` is the base64-encoded image. See [Discord Docs/Image Data]. [Discord Docs/Image Data]: https://discord.com/developers/docs/reference#image-data
create_emoji
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn delete_emoji( &self, guild_id: Id<GuildMarker>, emoji_id: Id<EmojiMarker>, ) -> DeleteEmoji<'_> { DeleteEmoji::new(self, guild_id, emoji_id) }
Delete an emoji in a guild, by id.
delete_emoji
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn update_emoji( &self, guild_id: Id<GuildMarker>, emoji_id: Id<EmojiMarker>, ) -> UpdateEmoji<'_> { UpdateEmoji::new(self, guild_id, emoji_id) }
Update an emoji in a guild, by id.
update_emoji
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub fn create_guild(&self, name: String) -> CreateGuild<'_> { CreateGuild::new(self, name) }
Create a new request to create a guild. The minimum length of the name is 2 UTF-16 characters and the maximum is 100 UTF-16 characters. This endpoint can only be used by bots in less than 10 guilds. # Errors Returns a [`CreateGuildErrorType::NameInvalid`] error type if the name length is too short or too long. [`CreateGuildErrorType::NameInvalid`]: crate::request::guild::create_guild::CreateGuildErrorType::NameInvalid
create_guild
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn delete_guild(&self, guild_id: Id<GuildMarker>) -> DeleteGuild<'_> { DeleteGuild::new(self, guild_id) }
Delete a guild permanently. The user must be the owner.
delete_guild
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn update_guild(&self, guild_id: Id<GuildMarker>) -> UpdateGuild<'_> { UpdateGuild::new(self, guild_id) }
Update a guild. All endpoints are optional. See [Discord Docs/Modify Guild]. [Discord Docs/Modify Guild]: https://discord.com/developers/docs/resources/guild#modify-guild
update_guild
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn update_guild_channel_positions<'a>( &'a self, guild_id: Id<GuildMarker>, channel_positions: &'a [Position], ) -> UpdateGuildChannelPositions<'a> { UpdateGuildChannelPositions::new(self, guild_id, channel_positions) }
Modify the positions of the channels. The minimum amount of channels to modify, is a swap between two channels.
update_guild_channel_positions
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn guild_widget(&self, guild_id: Id<GuildMarker>) -> GetGuildWidget<'_> { GetGuildWidget::new(self, guild_id) }
Get a guild's widget. See [Discord Docs/Get Guild Widget]. [Discord Docs/Get Guild Widget]: https://discord.com/developers/docs/resources/guild#get-guild-widget
guild_widget
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn guild_widget_settings( &self, guild_id: Id<GuildMarker>, ) -> GetGuildWidgetSettings<'_> { GetGuildWidgetSettings::new(self, guild_id) }
Get a guild's widget settings. See [Discord Docs/Get Guild Widget Settings]. [Discord Docs/Get Guild Widget]: https://discord.com/developers/docs/resources/guild#get-guild-widget-settings
guild_widget_settings
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn update_guild_widget_settings( &self, guild_id: Id<GuildMarker>, ) -> UpdateGuildWidgetSettings<'_> { UpdateGuildWidgetSettings::new(self, guild_id) }
Modify a guild's widget. See [Discord Docs/Modify Guild Widget]. [Discord Docs/Modify Guild Widget]: https://discord.com/developers/docs/resources/guild#modify-guild-widget
update_guild_widget_settings
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn delete_guild_integration( &self, guild_id: Id<GuildMarker>, integration_id: Id<IntegrationMarker>, ) -> DeleteGuildIntegration<'_> { DeleteGuildIntegration::new(self, guild_id, integration_id) }
Delete an integration for a guild, by the integration's id.
delete_guild_integration
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn guild_invites(&self, guild_id: Id<GuildMarker>) -> GetGuildInvites<'_> { GetGuildInvites::new(self, guild_id) }
Get information about the invites of a guild. Requires the [`MANAGE_GUILD`] permission. [`MANAGE_GUILD`]: twilight_model::guild::Permissions::MANAGE_GUILD
guild_invites
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn guild_member( &self, guild_id: Id<GuildMarker>, user_id: Id<UserMarker>, ) -> GetMember<'_> { GetMember::new(self, guild_id, user_id) }
Get a member of a guild, by their id.
guild_member
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn add_guild_member<'a>( &'a self, guild_id: Id<GuildMarker>, user_id: Id<UserMarker>, access_token: &'a str, ) -> AddGuildMember<'a> { AddGuildMember::new(self, guild_id, user_id, access_token) }
Add a user to a guild. An access token for the user with `guilds.join` scope is required. All other fields are optional. See [Discord Docs/Add Guild Member]. # Errors Returns an error of type [`ValidationErrorType::Nickname`] if the nickname is too short or too long. [`ValidationErrorType::Nickname`]: twilight_validate::request::ValidationErrorType::Nickname [Discord Docs/Add Guild Member]: https://discord.com/developers/docs/resources/guild#add-guild-member
add_guild_member
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn update_guild_member( &self, guild_id: Id<GuildMarker>, user_id: Id<UserMarker>, ) -> UpdateGuildMember<'_> { UpdateGuildMember::new(self, guild_id, user_id) }
Update a guild member. All fields are optional. See [Discord Docs/Modify Guild Member]. # Examples Update a member's nickname to "pinky pie" and server mute them: ```no_run use std::env; use twilight_http::Client; use twilight_model::id::Id; # #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let client = Client::new(env::var("DISCORD_TOKEN")?); let member = client .update_guild_member(Id::new(1), Id::new(2)) .mute(true) .nick(Some("pinkie pie")) .await? .model() .await?; println!( "user {} now has the nickname '{:?}'", member.user.id, member.nick, ); # Ok(()) } ``` # Errors Returns an error of type [`ValidationErrorType::Nickname`] if the nickname length is too short or too long. [`ValidationErrorType::Nickname`]: twilight_validate::request::ValidationErrorType::Nickname [Discord Docs/Modify Guild Member]: https://discord.com/developers/docs/resources/guild#modify-guild-member
update_guild_member
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn update_current_member( &self, guild_id: Id<GuildMarker>, ) -> UpdateCurrentMember<'_> { UpdateCurrentMember::new(self, guild_id) }
Update the user's member in a guild.
update_current_member
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn add_guild_member_role( &self, guild_id: Id<GuildMarker>, user_id: Id<UserMarker>, role_id: Id<RoleMarker>, ) -> AddRoleToMember<'_> { AddRoleToMember::new(self, guild_id, user_id, role_id) }
Add a role to a member in a guild. # Examples In guild `1`, add role `2` to user `3`, for the reason `"test"`: ```no_run # use twilight_http::{request::AuditLogReason, Client}; use twilight_model::id::Id; # # #[tokio::main] # async fn main() -> Result<(), Box<dyn std::error::Error>> { # let client = Client::new("my token".to_owned()); # let guild_id = Id::new(1); let role_id = Id::new(2); let user_id = Id::new(3); client .add_guild_member_role(guild_id, user_id, role_id) .reason("test") .await?; # Ok(()) } ```
add_guild_member_role
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn remove_guild_member_role( &self, guild_id: Id<GuildMarker>, user_id: Id<UserMarker>, role_id: Id<RoleMarker>, ) -> RemoveRoleFromMember<'_> { RemoveRoleFromMember::new(self, guild_id, user_id, role_id) }
Remove a role from a member in a guild, by id.
remove_guild_member_role
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn guild_onboarding(&self, guild_id: Id<GuildMarker>) -> GetGuildOnboarding<'_> { GetGuildOnboarding::new(self, guild_id) }
Retrieves the onboarding data for a guild.
guild_onboarding
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn guild_preview(&self, guild_id: Id<GuildMarker>) -> GetGuildPreview<'_> { GetGuildPreview::new(self, guild_id) }
For public guilds, get the guild preview. This works even if the user is not in the guild.
guild_preview
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn guild_prune_count(&self, guild_id: Id<GuildMarker>) -> GetGuildPruneCount<'_> { GetGuildPruneCount::new(self, guild_id) }
Get the counts of guild members to be pruned.
guild_prune_count
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn create_guild_prune(&self, guild_id: Id<GuildMarker>) -> CreateGuildPrune<'_> { CreateGuildPrune::new(self, guild_id) }
Begin a guild prune. See [Discord Docs/Begin Guild Prune]. [Discord Docs/Begin Guild Prune]: https://discord.com/developers/docs/resources/guild#begin-guild-prune
create_guild_prune
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn guild_vanity_url(&self, guild_id: Id<GuildMarker>) -> GetGuildVanityUrl<'_> { GetGuildVanityUrl::new(self, guild_id) }
Get a guild's vanity url, if there is one.
guild_vanity_url
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn guild_voice_regions(&self, guild_id: Id<GuildMarker>) -> GetGuildVoiceRegions<'_> { GetGuildVoiceRegions::new(self, guild_id) }
Get voice region data for the guild. Can return VIP servers if the guild is VIP-enabled.
guild_voice_regions
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn guild_welcome_screen( &self, guild_id: Id<GuildMarker>, ) -> GetGuildWelcomeScreen<'_> { GetGuildWelcomeScreen::new(self, guild_id) }
Get the guild's welcome screen. If the welcome screen is not enabled, this requires the [`MANAGE_GUILD`] permission. [`MANAGE_GUILD`]: twilight_model::guild::Permissions::MANAGE_GUILD
guild_welcome_screen
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn update_guild_welcome_screen( &self, guild_id: Id<GuildMarker>, ) -> UpdateGuildWelcomeScreen<'_> { UpdateGuildWelcomeScreen::new(self, guild_id) }
Update the guild's welcome screen. Requires the [`MANAGE_GUILD`] permission. [`MANAGE_GUILD`]: twilight_model::guild::Permissions::MANAGE_GUILD
update_guild_welcome_screen
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn invite<'a>(&'a self, code: &'a str) -> GetInvite<'a> { GetInvite::new(self, code) }
Get information about an invite by its code. If [`with_counts`] is called, the returned invite will contain approximate member counts. If [`with_expiration`] is called, it will contain the expiration date. # Examples ```no_run # use twilight_http::Client; # # #[tokio::main] # async fn main() -> Result<(), Box<dyn std::error::Error>> { # let client = Client::new("my token".to_owned()); # let invite = client.invite("code").with_counts().await?; # Ok(()) } ``` [`with_counts`]: crate::request::channel::invite::GetInvite::with_counts [`with_expiration`]: crate::request::channel::invite::GetInvite::with_expiration
invite
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn create_invite(&self, channel_id: Id<ChannelMarker>) -> CreateInvite<'_> { CreateInvite::new(self, channel_id) }
Create an invite, with options. Requires the [`CREATE_INVITE`] permission. # Examples ```no_run # use twilight_http::Client; # use twilight_model::id::Id; # # #[tokio::main] # async fn main() -> Result<(), Box<dyn std::error::Error>> { # let client = Client::new("my token".to_owned()); # let channel_id = Id::new(123); let invite = client.create_invite(channel_id).max_uses(3).await?; # Ok(()) } ``` [`CREATE_INVITE`]: twilight_model::guild::Permissions::CREATE_INVITE
create_invite
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn delete_invite<'a>(&'a self, code: &'a str) -> DeleteInvite<'a> { DeleteInvite::new(self, code) }
Delete an invite by its code. Requires the [`MANAGE_CHANNELS`] permission on the channel this invite belongs to, or [`MANAGE_GUILD`] to remove any invite across the guild. [`MANAGE_CHANNELS`]: twilight_model::guild::Permissions::MANAGE_CHANNELS [`MANAGE_GUILD`]: twilight_model::guild::Permissions::MANAGE_GUILD
delete_invite
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn message( &self, channel_id: Id<ChannelMarker>, message_id: Id<MessageMarker>, ) -> GetMessage<'_> { GetMessage::new(self, channel_id, message_id) }
Get a message by [`Id<ChannelMarker>`] and [`Id<MessageMarker>`].
message
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn create_message(&self, channel_id: Id<ChannelMarker>) -> CreateMessage<'_> { CreateMessage::new(self, channel_id) }
Send a message to a channel. The message must include at least one of [`attachments`], [`components`], [`content`], [`embeds`], or [`sticker_ids`]. # Example ```no_run # #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { use twilight_http::Client; use twilight_model::id::Id; let client = Client::new("my token".to_owned()); let channel_id = Id::new(123); let message = client .create_message(channel_id) .content("Twilight is best pony") .tts(true) .await?; # Ok(()) } ``` [`attachments`]: CreateMessage::attachments [`components`]: CreateMessage::components [`content`]: CreateMessage::content [`embeds`]: CreateMessage::embeds [`sticker_ids`]: CreateMessage::sticker_ids
create_message
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn delete_message( &self, channel_id: Id<ChannelMarker>, message_id: Id<MessageMarker>, ) -> DeleteMessage<'_> { DeleteMessage::new(self, channel_id, message_id) }
Delete a message by [`Id<ChannelMarker>`] and [`Id<MessageMarker>`].
delete_message
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn update_message( &self, channel_id: Id<ChannelMarker>, message_id: Id<MessageMarker>, ) -> UpdateMessage<'_> { UpdateMessage::new(self, channel_id, message_id) }
Update a message by [`Id<ChannelMarker>`] and [`Id<MessageMarker>`]. You can pass [`None`] to any of the methods to remove the associated field. Pass [`None`] to [`content`] to remove the content. You must ensure that the message still contains at least one of [`attachments`], [`components`], [`content`], [`embeds`], or stickers. # Examples Replace the content with `"test update"`: ```no_run # #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { use twilight_http::Client; use twilight_model::id::Id; let client = Client::new("my token".to_owned()); client .update_message(Id::new(1), Id::new(2)) .content(Some("test update")) .await?; # Ok(()) } ``` Remove the message's content: ```no_run # use twilight_http::Client; # use twilight_model::id::Id; # # #[tokio::main] # async fn main() -> Result<(), Box<dyn std::error::Error>> { # let client = Client::new("my token".to_owned()); client .update_message(Id::new(1), Id::new(2)) .content(None) .await?; # Ok(()) } ``` [`attachments`]: UpdateMessage::attachments [`components`]: UpdateMessage::components [`content`]: UpdateMessage::content [`embeds`]: UpdateMessage::embeds
update_message
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn crosspost_message( &self, channel_id: Id<ChannelMarker>, message_id: Id<MessageMarker>, ) -> CrosspostMessage<'_> { CrosspostMessage::new(self, channel_id, message_id) }
Crosspost a message by [`Id<ChannelMarker>`] and [`Id<MessageMarker>`].
crosspost_message
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn create_pin( &self, channel_id: Id<ChannelMarker>, message_id: Id<MessageMarker>, ) -> CreatePin<'_> { CreatePin::new(self, channel_id, message_id) }
Create a new pin in a channel, by ID.
create_pin
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
pub const fn delete_pin( &self, channel_id: Id<ChannelMarker>, message_id: Id<MessageMarker>, ) -> DeletePin<'_> { DeletePin::new(self, channel_id, message_id) }
Delete a pin in a channel, by ID.
delete_pin
rust
twilight-rs/twilight
twilight-http/src/client/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/client/mod.rs
ISC
const fn num_digits(index: u64) -> usize { let mut index = index; let mut len = 0; if index < 10 { return 1; } while index > 0 { index /= 10; len += 1; } len }
Count the number of digits in a given number.
num_digits
rust
twilight-rs/twilight
twilight-http/src/request/attachment.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/attachment.rs
ISC
fn push_digits(mut id: u64, buf: &mut Vec<u8>) { // The largest 64 bit integer is 20 digits. let mut inner_buf = [0_u8; 20]; // Amount of digits written to the inner buffer. let mut i = 0; // While the number have more than one digit we print the last digit by // taking the rest after modulo 10. We then divide with 10 to truncate the // number from the right and then loop while id >= 10 { // To go from the integer to the ascii value we add the ascii value of // '0'. // // (id % 10) will always be less than 10 so truncation cannot happen. #[allow(clippy::cast_possible_truncation)] let ascii = (id % 10) as u8 + ASCII_NUMBER; inner_buf[i] = ascii; id /= 10; i += 1; } // (id % 10) will always be less than 10 so truncation cannot happen. #[allow(clippy::cast_possible_truncation)] let ascii = (id % 10) as u8 + ASCII_NUMBER; inner_buf[i] = ascii; i += 1; // As we have written the digits in reverse we reverse the area of the array // we have been using to get the characters in the correct order. inner_buf[..i].reverse(); buf.extend_from_slice(&inner_buf[..i]); }
Extend the buffer with the digits of the integer `id`. The reason for this is to get around a allocation by for example using `format!("files[{id}]")`.
push_digits
rust
twilight-rs/twilight
twilight-http/src/request/attachment.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/attachment.rs
ISC
pub fn body(mut self, body: Vec<u8>) -> Self { if let Ok(request) = self.0.as_mut() { request.body = Some(body); } self }
Set the contents of the body.
body
rust
twilight-rs/twilight
twilight-http/src/request/base.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/base.rs
ISC
pub fn json(mut self, to: &impl Serialize) -> Self { self.0 = self.0.and_then(|mut request| { let bytes = crate::json::to_vec(to).map_err(Error::json)?; request.body = Some(bytes); Ok(request) }); self }
Set the body, to be serialized as JSON.
json
rust
twilight-rs/twilight
twilight-http/src/request/base.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/base.rs
ISC
pub fn use_authorization_token(mut self, use_authorization_token: bool) -> Self { if let Ok(request) = self.0.as_mut() { request.use_authorization_token = use_authorization_token; } self }
Whether to use the client's authorization token in the request, if one is set. This is primarily useful for executing webhooks.
use_authorization_token
rust
twilight-rs/twilight
twilight-http/src/request/base.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/base.rs
ISC
pub fn from_route(route: &Route<'_>) -> Self { Self { body: None, form: None, headers: None, method: route.method(), path: route.to_string(), ratelimit_path: route.to_path(), use_authorization_token: true, } }
Create a request from only its route information. If you need to set additional configurations like the body then use [`builder`]. # Examples Create a request to get a message with an ID of 2 in a channel with an ID of 1: ``` use twilight_http::{request::Request, routing::Route}; let request = Request::from_route(&Route::GetMessage { channel_id: 1, message_id: 2, }); ``` [`builder`]: Self::builder
from_route
rust
twilight-rs/twilight
twilight-http/src/request/base.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/base.rs
ISC
pub fn build(mut self) -> Vec<u8> { self.buffer.extend(Self::BOUNDARY_TERMINATOR); self.buffer }
Consume the form, returning the buffer's contents.
build
rust
twilight-rs/twilight
twilight-http/src/request/multipart.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/multipart.rs
ISC
pub fn content_type(&self) -> Vec<u8> { const NAME: &str = "multipart/form-data; boundary="; let mut content_type = Vec::with_capacity(NAME.len() + self.boundary.len()); content_type.extend(NAME.as_bytes()); content_type.extend(self.boundary); content_type }
Get the form's appropriate content type for requests.
content_type
rust
twilight-rs/twilight
twilight-http/src/request/multipart.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/multipart.rs
ISC
pub fn random_boundary() -> [u8; 15] { let mut boundary = [0; 15]; for value in &mut boundary { *value = fastrand::alphanumeric() as u8; } boundary }
Generate a random boundary that is 15 characters long.
random_boundary
rust
twilight-rs/twilight
twilight-http/src/request/multipart.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/multipart.rs
ISC
pub const fn cover_image(mut self, cover_image: Option<&'a str>) -> Self { self.fields.cover_image = Some(Nullable(cover_image)); self }
Sets the cover image of the application.
cover_image
rust
twilight-rs/twilight
twilight-http/src/request/update_user_application.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/update_user_application.rs
ISC
pub const fn custom_install_url(mut self, custom_install_url: &'a str) -> Self { self.fields.custom_install_url = Some(custom_install_url); self }
Sets the custom install URL of the application.
custom_install_url
rust
twilight-rs/twilight
twilight-http/src/request/update_user_application.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/update_user_application.rs
ISC
pub const fn description(mut self, description: &'a str) -> Self { self.fields.description = Some(description); self }
Sets the description of the application.
description
rust
twilight-rs/twilight
twilight-http/src/request/update_user_application.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/update_user_application.rs
ISC
pub const fn icon(mut self, icon: Option<&'a str>) -> Self { self.fields.icon = Some(Nullable(icon)); self }
Sets the icon of the application.
icon
rust
twilight-rs/twilight
twilight-http/src/request/update_user_application.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/update_user_application.rs
ISC
pub fn install_params(mut self, install_params: InstallParams) -> Self { self.fields.install_params = Some(install_params); self }
Sets the install params of the application.
install_params
rust
twilight-rs/twilight
twilight-http/src/request/update_user_application.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/update_user_application.rs
ISC
pub const fn interactions_endpoint_url(mut self, interactions_endpoint_url: &'a str) -> Self { self.fields.interactions_endpoint_url = Some(interactions_endpoint_url); self }
Sets the interactions endpoint URL of the application.
interactions_endpoint_url
rust
twilight-rs/twilight
twilight-http/src/request/update_user_application.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/update_user_application.rs
ISC
pub const fn role_connections_verification_url( mut self, role_connections_verification_url: &'a str, ) -> Self { self.fields.role_connections_verification_url = Some(role_connections_verification_url); self }
Sets the role connections verification URL of the application.
role_connections_verification_url
rust
twilight-rs/twilight
twilight-http/src/request/update_user_application.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/update_user_application.rs
ISC
pub fn tags(mut self, tags: Vec<&'a str>) -> Self { self.fields.tags = Some(tags); self }
Sets the tags of the application.
tags
rust
twilight-rs/twilight
twilight-http/src/request/update_user_application.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/update_user_application.rs
ISC
pub const fn with_localizations(mut self, with_localizations: bool) -> Self { self.with_localizations = Some(with_localizations); self }
Whether to include full localization dictionaries in the response. Defaults to [`false`].
with_localizations
rust
twilight-rs/twilight
twilight-http/src/request/application/command/get_global_commands.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/get_global_commands.rs
ISC
pub const fn with_localizations(mut self, with_localizations: bool) -> Self { self.with_localizations = Some(with_localizations); self }
Whether to include full localization dictionaries in the response. Defaults to [`false`].
with_localizations
rust
twilight-rs/twilight
twilight-http/src/request/application/command/get_guild_commands.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/get_guild_commands.rs
ISC
pub const fn name(mut self, name: &'a str) -> Self { self.fields.name = Some(name); self }
Edit the name of the command.
name
rust
twilight-rs/twilight
twilight-http/src/request/application/command/update_global_command.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/update_global_command.rs
ISC
pub const fn description(mut self, description: &'a str) -> Self { self.fields.description = Some(description); self }
Edit the description of the command.
description
rust
twilight-rs/twilight
twilight-http/src/request/application/command/update_global_command.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/update_global_command.rs
ISC
pub const fn command_options(mut self, options: &'a [CommandOption]) -> Self { self.fields.options = Some(options); self }
Edit the command options of the command.
command_options
rust
twilight-rs/twilight
twilight-http/src/request/application/command/update_global_command.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/update_global_command.rs
ISC
pub const fn nsfw(mut self, nsfw: bool) -> Self { self.fields.nsfw = Some(nsfw); self }
Edit whether the command is age-restricted.
nsfw
rust
twilight-rs/twilight
twilight-http/src/request/application/command/update_global_command.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/update_global_command.rs
ISC
pub const fn name(mut self, name: &'a str) -> Self { self.fields.name = Some(name); self }
Edit the name of the command.
name
rust
twilight-rs/twilight
twilight-http/src/request/application/command/update_guild_command.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/update_guild_command.rs
ISC
pub const fn description(mut self, description: &'a str) -> Self { self.fields.description = Some(description); self }
Edit the description of the command.
description
rust
twilight-rs/twilight
twilight-http/src/request/application/command/update_guild_command.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/update_guild_command.rs
ISC
pub const fn command_options(mut self, options: &'a [CommandOption]) -> Self { self.fields.options = Some(options); self }
Edit the command options of the command.
command_options
rust
twilight-rs/twilight
twilight-http/src/request/application/command/update_guild_command.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/update_guild_command.rs
ISC
pub const fn nsfw(mut self, nsfw: bool) -> Self { self.fields.nsfw = Some(nsfw); self }
Edit whether the command is age-restricted.
nsfw
rust
twilight-rs/twilight
twilight-http/src/request/application/command/update_guild_command.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/update_guild_command.rs
ISC
pub fn command_options(mut self, options: &'a [CommandOption]) -> Self { self.fields = self.fields.and_then(|mut fields| { validate_options(options)?; fields.options = Some(options); Ok(fields) }); self }
Add a list of command options. Required command options must be added before optional options. # Errors Returns an error of type [`OptionsRequiredFirst`] if a required option was added after an optional option. The problem option's index is provided. [`OptionsRequiredFirst`]: twilight_validate::command::CommandValidationErrorType::OptionsRequiredFirst
command_options
rust
twilight-rs/twilight
twilight-http/src/request/application/command/create_global_command/chat_input.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/create_global_command/chat_input.rs
ISC
pub fn default_member_permissions(mut self, default: Permissions) -> Self { if let Ok(fields) = self.fields.as_mut() { fields.default_member_permissions = Some(default); } self }
Default permissions required for a member to run the command. Defaults to [`None`].
default_member_permissions
rust
twilight-rs/twilight
twilight-http/src/request/application/command/create_global_command/chat_input.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/create_global_command/chat_input.rs
ISC
pub fn dm_permission(mut self, dm_permission: bool) -> Self { if let Ok(fields) = self.fields.as_mut() { fields.dm_permission = Some(dm_permission); } self }
Set whether the command is available in DMs. Defaults to [`None`].
dm_permission
rust
twilight-rs/twilight
twilight-http/src/request/application/command/create_global_command/chat_input.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/create_global_command/chat_input.rs
ISC
pub fn description_localizations(mut self, localizations: &'a HashMap<String, String>) -> Self { self.fields = self.fields.and_then(|mut fields| { for description in localizations.values() { validate_description(description)?; } fields.description_localizations = Some(localizations); Ok(fields) }); self }
Set the localization dictionary for the command description. Defaults to [`None`]. # Errors Returns an error of type [`DescriptionInvalid`] if the description is invalid. [`DescriptionInvalid`]: twilight_validate::command::CommandValidationErrorType::DescriptionInvalid
description_localizations
rust
twilight-rs/twilight
twilight-http/src/request/application/command/create_global_command/chat_input.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/create_global_command/chat_input.rs
ISC
pub fn name_localizations(mut self, localizations: &'a HashMap<String, String>) -> Self { self.fields = self.fields.and_then(|mut fields| { for name in localizations.values() { validate_chat_input_name(name)?; } fields.name_localizations = Some(localizations); Ok(fields) }); self }
Set the localization dictionary for the command name. Defaults to [`None`]. # Errors Returns an error of type [`NameLengthInvalid`] if the length is invalid. Returns an error of type [`NameCharacterInvalid`] if the name contains a non-alphanumeric character or an uppercase character for which a lowercase variant exists. [`NameLengthInvalid`]: twilight_validate::command::CommandValidationErrorType::NameLengthInvalid [`NameCharacterInvalid`]: twilight_validate::command::CommandValidationErrorType::NameCharacterInvalid
name_localizations
rust
twilight-rs/twilight
twilight-http/src/request/application/command/create_global_command/chat_input.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/create_global_command/chat_input.rs
ISC
pub fn nsfw(mut self, nsfw: bool) -> Self { if let Ok(fields) = self.fields.as_mut() { fields.nsfw = Some(nsfw); } self }
Set whether the command is age-restricted. Defaults to not being specified, which uses Discord's default.
nsfw
rust
twilight-rs/twilight
twilight-http/src/request/application/command/create_global_command/chat_input.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/create_global_command/chat_input.rs
ISC
pub fn default_member_permissions(mut self, default: Permissions) -> Self { if let Ok(fields) = self.fields.as_mut() { fields.default_member_permissions = Some(default); } self }
Default permissions required for a member to run the command. Defaults to [`None`].
default_member_permissions
rust
twilight-rs/twilight
twilight-http/src/request/application/command/create_global_command/message.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/create_global_command/message.rs
ISC
pub fn dm_permission(mut self, dm_permission: bool) -> Self { if let Ok(fields) = self.fields.as_mut() { fields.dm_permission = Some(dm_permission); } self }
Set whether the command is available in DMs. Defaults to [`None`].
dm_permission
rust
twilight-rs/twilight
twilight-http/src/request/application/command/create_global_command/message.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/create_global_command/message.rs
ISC
pub fn name_localizations(mut self, localizations: &'a HashMap<String, String>) -> Self { self.fields = self.fields.and_then(|mut fields| { for name in localizations.values() { validate_name(name)?; } fields.name_localizations = Some(localizations); Ok(fields) }); self }
Set the localization dictionary for the command name. Defaults to [`None`]. # Errors Returns an error of type [`NameLengthInvalid`] if the name is invalid. [`NameLengthInvalid`]: twilight_validate::command::CommandValidationErrorType::NameLengthInvalid
name_localizations
rust
twilight-rs/twilight
twilight-http/src/request/application/command/create_global_command/message.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/create_global_command/message.rs
ISC
pub fn nsfw(mut self, nsfw: bool) -> Self { if let Ok(fields) = self.fields.as_mut() { fields.nsfw = Some(nsfw); } self }
Set whether the command is age-restricted. Defaults to not being specified, which uses Discord's default.
nsfw
rust
twilight-rs/twilight
twilight-http/src/request/application/command/create_global_command/message.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/create_global_command/message.rs
ISC
pub fn chat_input( self, name: &'a str, description: &'a str, ) -> CreateGlobalChatInputCommand<'a> { CreateGlobalChatInputCommand::new(self.http, self.application_id, name, description) }
Create a new chat input global command. The command name must only contain alphanumeric characters and lowercase variants must be used where possible. Special characters `-` and `_` are allowed. The description must be between 1 and 100 characters in length. Creating a command with the same name as an already-existing global command will overwrite the old command. See [Discord Docs/Create Global Application Command]. # Errors Returns an error of type [`NameLengthInvalid`] or [`NameCharacterInvalid`] if the command name is invalid. Returns an error of type [`DescriptionInvalid`] if the command description is not between 1 and 100 characters. [`DescriptionInvalid`]: twilight_validate::command::CommandValidationErrorType::DescriptionInvalid [`NameCharacterInvalid`]: twilight_validate::command::CommandValidationErrorType::NameCharacterInvalid [`NameLengthInvalid`]: twilight_validate::command::CommandValidationErrorType::NameLengthInvalid [Discord Docs/Create Global Application Command]: https://discord.com/developers/docs/interactions/application-commands#create-global-application-command
chat_input
rust
twilight-rs/twilight
twilight-http/src/request/application/command/create_global_command/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/create_global_command/mod.rs
ISC
pub fn message(self, name: &'a str) -> CreateGlobalMessageCommand<'a> { CreateGlobalMessageCommand::new(self.http, self.application_id, name) }
Create a new message global command. Creating a command with the same name as an already-existing global command will overwrite the old command. See [Discord Docs/Create Global Application Command]. # Errors Returns an error of type [`NameLengthInvalid`] if the command name is not between 1 and 32 characters. [`NameLengthInvalid`]: twilight_validate::command::CommandValidationErrorType::NameLengthInvalid [Discord Docs/Create Global Application Command]: https://discord.com/developers/docs/interactions/application-commands#create-global-application-command
message
rust
twilight-rs/twilight
twilight-http/src/request/application/command/create_global_command/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/create_global_command/mod.rs
ISC
pub fn user(self, name: &'a str) -> CreateGlobalUserCommand<'a> { CreateGlobalUserCommand::new(self.http, self.application_id, name) }
Create a new user global command. Creating a command with the same name as an already-existing global command will overwrite the old command. See [Discord Docs/Create Global Application Command]. # Errors Returns an error of type [`NameLengthInvalid`] if the command name is not between 1 and 32 characters. [`NameLengthInvalid`]: twilight_validate::command::CommandValidationErrorType::NameLengthInvalid [Discord Docs/Create Global Application Command]: https://discord.com/developers/docs/interactions/application-commands#create-global-application-command
user
rust
twilight-rs/twilight
twilight-http/src/request/application/command/create_global_command/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/create_global_command/mod.rs
ISC
pub fn default_member_permissions(mut self, default: Permissions) -> Self { if let Ok(fields) = self.fields.as_mut() { fields.default_member_permissions = Some(default); } self }
Default permissions required for a member to run the command. Defaults to [`None`].
default_member_permissions
rust
twilight-rs/twilight
twilight-http/src/request/application/command/create_global_command/user.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/create_global_command/user.rs
ISC
pub fn dm_permission(mut self, dm_permission: bool) -> Self { if let Ok(fields) = self.fields.as_mut() { fields.dm_permission = Some(dm_permission); } self }
Set whether the command is available in DMs. Defaults to [`None`].
dm_permission
rust
twilight-rs/twilight
twilight-http/src/request/application/command/create_global_command/user.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/create_global_command/user.rs
ISC
pub fn name_localizations(mut self, localizations: &'a HashMap<String, String>) -> Self { self.fields = self.fields.and_then(|mut fields| { for name in localizations.values() { validate_name(name)?; } fields.name_localizations = Some(localizations); Ok(fields) }); self }
Set the localization dictionary for the command name. Defaults to [`None`]. # Errors Returns an error of type [`NameLengthInvalid`] if the name is invalid. [`NameLengthInvalid`]: twilight_validate::command::CommandValidationErrorType::NameLengthInvalid
name_localizations
rust
twilight-rs/twilight
twilight-http/src/request/application/command/create_global_command/user.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/create_global_command/user.rs
ISC
pub fn nsfw(mut self, nsfw: bool) -> Self { if let Ok(fields) = self.fields.as_mut() { fields.nsfw = Some(nsfw); } self }
Set whether the command is age-restricted. Defaults to not being specified, which uses Discord's default.
nsfw
rust
twilight-rs/twilight
twilight-http/src/request/application/command/create_global_command/user.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/create_global_command/user.rs
ISC
pub fn command_options(mut self, options: &'a [CommandOption]) -> Self { self.fields = self.fields.and_then(|mut fields| { validate_options(options)?; fields.options = Some(options); Ok(fields) }); self }
Add a list of command options. Required command options must be added before optional options. # Errors Returns an error of type [`OptionsRequiredFirst`] if a required option was added after an optional option. The problem option's index is provided. [`OptionsRequiredFirst`]: twilight_validate::command::CommandValidationErrorType::OptionsRequiredFirst
command_options
rust
twilight-rs/twilight
twilight-http/src/request/application/command/create_guild_command/chat_input.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/create_guild_command/chat_input.rs
ISC
pub fn default_member_permissions(mut self, default: Permissions) -> Self { if let Ok(fields) = self.fields.as_mut() { fields.default_member_permissions = Some(default); } self }
Default permissions required for a member to run the command. Defaults to [`None`].
default_member_permissions
rust
twilight-rs/twilight
twilight-http/src/request/application/command/create_guild_command/chat_input.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/create_guild_command/chat_input.rs
ISC
pub fn description_localizations(mut self, localizations: &'a HashMap<String, String>) -> Self { self.fields = self.fields.and_then(|mut fields| { for description in localizations.values() { validate_description(description)?; } fields.description_localizations = Some(localizations); Ok(fields) }); self }
Set the localization dictionary for the command description. Defaults to [`None`]. # Errors Returns an error of type [`DescriptionInvalid`] if the description is invalid. [`DescriptionInvalid`]: twilight_validate::command::CommandValidationErrorType::DescriptionInvalid
description_localizations
rust
twilight-rs/twilight
twilight-http/src/request/application/command/create_guild_command/chat_input.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/create_guild_command/chat_input.rs
ISC
pub fn name_localizations(mut self, localizations: &'a HashMap<String, String>) -> Self { self.fields = self.fields.and_then(|mut fields| { for name in localizations.values() { validate_chat_input_name(name)?; } fields.name_localizations = Some(localizations); Ok(fields) }); self }
Set the localization dictionary for the command name. Defaults to [`None`]. # Errors Returns an error of type [`NameLengthInvalid`] if the length is invalid. Returns an error of type [`NameCharacterInvalid`] if the name contains a non-alphanumeric character or an uppercase character for which a lowercase variant exists. [`NameLengthInvalid`]: twilight_validate::command::CommandValidationErrorType::NameLengthInvalid [`NameCharacterInvalid`]: twilight_validate::command::CommandValidationErrorType::NameCharacterInvalid
name_localizations
rust
twilight-rs/twilight
twilight-http/src/request/application/command/create_guild_command/chat_input.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/create_guild_command/chat_input.rs
ISC
pub fn nsfw(mut self, nsfw: bool) -> Self { if let Ok(fields) = self.fields.as_mut() { fields.nsfw = Some(nsfw); } self }
Set whether the command is age-restricted. Defaults to not being specified, which uses Discord's default.
nsfw
rust
twilight-rs/twilight
twilight-http/src/request/application/command/create_guild_command/chat_input.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/create_guild_command/chat_input.rs
ISC
pub fn default_member_permissions(mut self, default: Permissions) -> Self { if let Ok(fields) = self.fields.as_mut() { fields.default_member_permissions = Some(default); } self }
Default permissions required for a member to run the command. Defaults to [`None`].
default_member_permissions
rust
twilight-rs/twilight
twilight-http/src/request/application/command/create_guild_command/message.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/create_guild_command/message.rs
ISC
pub fn name_localizations(mut self, localizations: &'a HashMap<String, String>) -> Self { self.fields = self.fields.and_then(|mut fields| { for name in localizations.values() { validate_name(name)?; } fields.name_localizations = Some(localizations); Ok(fields) }); self }
Set the localization dictionary for the command name. Defaults to [`None`]. # Errors Returns an error of type [`NameLengthInvalid`] if the name is invalid. [`NameLengthInvalid`]: twilight_validate::command::CommandValidationErrorType::NameLengthInvalid
name_localizations
rust
twilight-rs/twilight
twilight-http/src/request/application/command/create_guild_command/message.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/create_guild_command/message.rs
ISC
pub fn nsfw(mut self, nsfw: bool) -> Self { if let Ok(fields) = self.fields.as_mut() { fields.nsfw = Some(nsfw); } self }
Set whether the command is age-restricted. Defaults to not being specified, which uses Discord's default.
nsfw
rust
twilight-rs/twilight
twilight-http/src/request/application/command/create_guild_command/message.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/create_guild_command/message.rs
ISC
pub fn chat_input( self, name: &'a str, description: &'a str, ) -> CreateGuildChatInputCommand<'a> { CreateGuildChatInputCommand::new( self.http, self.application_id, self.guild_id, name, description, ) }
Create a chat input command in a guild. The command name must only contain alphanumeric characters and lowercase variants must be used where possible. Special characters `-` and `_` are allowed. The description must be between 1 and 100 characters in length. Creating a guild command with the same name as an already-existing guild command in the same guild will overwrite the old command. See [Discord Docs/Create Guild Application Command]. # Errors Returns an error of type [`NameLengthInvalid`] or [`NameCharacterInvalid`] if the command name is invalid. Returns an error of type [`DescriptionInvalid`] error type if the command description is not between 1 and 100 characters. [`DescriptionInvalid`]: twilight_validate::command::CommandValidationErrorType::DescriptionInvalid [`NameCharacterInvalid`]: twilight_validate::command::CommandValidationErrorType::NameCharacterInvalid [`NameLengthInvalid`]: twilight_validate::command::CommandValidationErrorType::NameLengthInvalid [Discord Docs/Create Guild Application Command]: https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command
chat_input
rust
twilight-rs/twilight
twilight-http/src/request/application/command/create_guild_command/mod.rs
https://github.com/twilight-rs/twilight/blob/master/twilight-http/src/request/application/command/create_guild_command/mod.rs
ISC