Struct twilight_http::client::InteractionClient
source · [−]pub struct InteractionClient<'a> { /* private fields */ }Expand description
Client interface for using interactions.
Examples
Retrieve the application ID and then use an interaction request:
use std::env;
use twilight_http::Client;
use twilight_model::id::Id;
let client = Client::new(env::var("DISCORD_TOKEN")?);
let application_id = Id::new(123);
let interaction_client = client.interaction(application_id);
let commands = interaction_client
.global_commands()
.exec()
.await?
.models()
.await?;
println!("there are {} global commands", commands.len());Implementations
sourceimpl<'a> InteractionClient<'a>
impl<'a> InteractionClient<'a>
sourcepub const fn create_response(
&'a self,
interaction_id: Id<InteractionMarker>,
interaction_token: &'a str,
response: &'a InteractionResponse
) -> CreateResponse<'a>
pub const fn create_response(
&'a self,
interaction_id: Id<InteractionMarker>,
interaction_token: &'a str,
response: &'a InteractionResponse
) -> CreateResponse<'a>
Respond to an interaction, by its ID and token.
For variants of InteractionResponse that contain
InteractionResponseData, there is an associated builder in the
twilight-util crate.
sourcepub const fn delete_response(
&'a self,
interaction_token: &'a str
) -> DeleteResponse<'a>
pub const fn delete_response(
&'a self,
interaction_token: &'a str
) -> DeleteResponse<'a>
Delete the original message, by its token.
sourcepub const fn response(&'a self, interaction_token: &'a str) -> GetResponse<'a>
pub const fn response(&'a self, interaction_token: &'a str) -> GetResponse<'a>
Get the original message, by its token.
sourcepub const fn update_response(
&'a self,
interaction_token: &'a str
) -> UpdateResponse<'a>
pub const fn update_response(
&'a self,
interaction_token: &'a str
) -> UpdateResponse<'a>
Edit the original message, by its token.
sourcepub const fn create_followup(
&'a self,
interaction_token: &'a str
) -> CreateFollowup<'a>
pub const fn create_followup(
&'a self,
interaction_token: &'a str
) -> CreateFollowup<'a>
Create a followup message to an interaction, by its token.
The message must include at least one of attachments, content,
or embeds.
Examples
use std::env;
use twilight_http::Client;
use twilight_model::id::Id;
let client = Client::new(env::var("DISCORD_TOKEN")?);
let application_id = Id::new(1);
client
.interaction(application_id)
.create_followup("webhook token")
.content("Pinkie...")?
.exec()
.await?;sourcepub const fn delete_followup(
&'a self,
interaction_token: &'a str,
message_id: Id<MessageMarker>
) -> DeleteFollowup<'a>
pub const fn delete_followup(
&'a self,
interaction_token: &'a str,
message_id: Id<MessageMarker>
) -> DeleteFollowup<'a>
Delete a followup message to an interaction, by its token and message ID.
sourcepub const fn followup(
&'a self,
interaction_token: &'a str,
message_id: Id<MessageMarker>
) -> GetFollowup<'a>
pub const fn followup(
&'a self,
interaction_token: &'a str,
message_id: Id<MessageMarker>
) -> GetFollowup<'a>
Get a followup message of an interaction, by its token and the message ID.
sourcepub const fn update_followup(
&'a self,
interaction_token: &'a str,
message_id: Id<MessageMarker>
) -> UpdateFollowup<'a>
pub const fn update_followup(
&'a self,
interaction_token: &'a str,
message_id: Id<MessageMarker>
) -> UpdateFollowup<'a>
Edit a followup message of an interaction, by its token and the message ID.
sourcepub const fn create_global_command(&'a self) -> CreateGlobalCommand<'a>
pub const fn create_global_command(&'a self) -> CreateGlobalCommand<'a>
Create a new global command.
sourcepub const fn delete_global_command(
&self,
command_id: Id<CommandMarker>
) -> DeleteGlobalCommand<'_>
pub const fn delete_global_command(
&self,
command_id: Id<CommandMarker>
) -> DeleteGlobalCommand<'_>
Delete a global command, by ID.
sourcepub const fn global_command(
&self,
command_id: Id<CommandMarker>
) -> GetGlobalCommand<'_>
pub const fn global_command(
&self,
command_id: Id<CommandMarker>
) -> GetGlobalCommand<'_>
Fetch a global command for your application.
sourcepub const fn global_commands(&self) -> GetGlobalCommands<'_>
pub const fn global_commands(&self) -> GetGlobalCommands<'_>
Fetch all global commands for your application.
sourcepub const fn set_global_commands(
&'a self,
commands: &'a [Command]
) -> SetGlobalCommands<'a>
pub const fn set_global_commands(
&'a self,
commands: &'a [Command]
) -> SetGlobalCommands<'a>
Set global commands.
This method is idempotent: it can be used on every start, without being ratelimited if there aren’t changes to the commands.
The Command struct has an associated builder in the
twilight-util crate.
sourcepub const fn update_global_command(
&self,
command_id: Id<CommandMarker>
) -> UpdateGlobalCommand<'_>
pub const fn update_global_command(
&self,
command_id: Id<CommandMarker>
) -> UpdateGlobalCommand<'_>
Edit a global command, by ID.
You must specify a name and description. See Discord Docs/Edit Global Application Command.
sourcepub const fn create_guild_command(
&'a self,
guild_id: Id<GuildMarker>
) -> CreateGuildCommand<'a>
pub const fn create_guild_command(
&'a self,
guild_id: Id<GuildMarker>
) -> CreateGuildCommand<'a>
Create a new command in a guild.
sourcepub const fn delete_guild_command(
&self,
guild_id: Id<GuildMarker>,
command_id: Id<CommandMarker>
) -> DeleteGuildCommand<'_>
pub const fn delete_guild_command(
&self,
guild_id: Id<GuildMarker>,
command_id: Id<CommandMarker>
) -> DeleteGuildCommand<'_>
Delete a command in a guild, by ID.
sourcepub const fn guild_command(
&self,
guild_id: Id<GuildMarker>,
command_id: Id<CommandMarker>
) -> GetGuildCommand<'_>
pub const fn guild_command(
&self,
guild_id: Id<GuildMarker>,
command_id: Id<CommandMarker>
) -> GetGuildCommand<'_>
Fetch a guild command for your application.
sourcepub const fn guild_commands(
&self,
guild_id: Id<GuildMarker>
) -> GetGuildCommands<'_>
pub const fn guild_commands(
&self,
guild_id: Id<GuildMarker>
) -> GetGuildCommands<'_>
Fetch all commands for a guild, by ID.
sourcepub const fn set_guild_commands(
&'a self,
guild_id: Id<GuildMarker>,
commands: &'a [Command]
) -> SetGuildCommands<'a>
pub const fn set_guild_commands(
&'a self,
guild_id: Id<GuildMarker>,
commands: &'a [Command]
) -> SetGuildCommands<'a>
Set a guild’s commands.
This method is idempotent: it can be used on every start, without being ratelimited if there aren’t changes to the commands.
The Command struct has an associated builder in the
twilight-util crate.
sourcepub const fn update_guild_command(
&self,
guild_id: Id<GuildMarker>,
command_id: Id<CommandMarker>
) -> UpdateGuildCommand<'_>
pub const fn update_guild_command(
&self,
guild_id: Id<GuildMarker>,
command_id: Id<CommandMarker>
) -> UpdateGuildCommand<'_>
Edit a command in a guild, by ID.
You must specify a name and description. See Discord Docs/Edit Guild Application Command.
sourcepub const fn command_permissions(
&self,
guild_id: Id<GuildMarker>,
command_id: Id<CommandMarker>
) -> GetCommandPermissions<'_>
pub const fn command_permissions(
&self,
guild_id: Id<GuildMarker>,
command_id: Id<CommandMarker>
) -> GetCommandPermissions<'_>
Fetch command permissions for a command from the current application in a guild.
sourcepub const fn guild_command_permissions(
&self,
guild_id: Id<GuildMarker>
) -> GetGuildCommandPermissions<'_>
pub const fn guild_command_permissions(
&self,
guild_id: Id<GuildMarker>
) -> GetGuildCommandPermissions<'_>
Fetch command permissions for all commands from the current application in a guild.
sourcepub fn set_command_permissions(
&'a self,
guild_id: Id<GuildMarker>,
permissions: &'a [(Id<CommandMarker>, CommandPermissions)]
) -> Result<SetCommandPermissions<'a>, CommandValidationError>
pub fn set_command_permissions(
&'a self,
guild_id: Id<GuildMarker>,
permissions: &'a [(Id<CommandMarker>, CommandPermissions)]
) -> Result<SetCommandPermissions<'a>, CommandValidationError>
Update command permissions for all commands in a guild.
This overwrites the command permissions so the full set of permissions have to be sent every time.
Returns an error of type CountInvalid if too many commands have been
provided. The maximum amount is defined by GUILD_COMMAND_LIMIT.
sourcepub fn update_command_permissions(
&'a self,
guild_id: Id<GuildMarker>,
command_id: Id<CommandMarker>,
permissions: &'a [CommandPermissions]
) -> Result<UpdateCommandPermissions<'a>, CommandValidationError>
pub fn update_command_permissions(
&'a self,
guild_id: Id<GuildMarker>,
command_id: Id<CommandMarker>,
permissions: &'a [CommandPermissions]
) -> Result<UpdateCommandPermissions<'a>, CommandValidationError>
Update command permissions for a single command in a guild.
This overwrites the command permissions so the full set of permissions have to be sent every time.
Trait Implementations
Auto Trait Implementations
impl<'a> !RefUnwindSafe for InteractionClient<'a>
impl<'a> Send for InteractionClient<'a>
impl<'a> Sync for InteractionClient<'a>
impl<'a> Unpin for InteractionClient<'a>
impl<'a> !UnwindSafe for InteractionClient<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more