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().await?.models().await?;
println!("there are {} global commands", commands.len());
Implementations§
source§impl<'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.
This endpoint is not bound to the application’s global rate limit.
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.
This endpoint is not bound to the application’s global rate limit.
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.
This endpoint is not bound to the application’s global rate limit.
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.
The update must include at least one of attachments
, components
,
content
or embeds
.
This endpoint is not bound to the application’s global rate limit.
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
, components
content
or embeds
.
This endpoint is not bound to the application’s global rate limit.
§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...")
.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.
This endpoint is not bound to the application’s global rate limit.
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.
This endpoint is not bound to the application’s global rate limit.
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.
This endpoint is not bound to the application’s global rate limit.
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 update_command_permissions(
&'a self,
guild_id: Id<GuildMarker>,
command_id: Id<CommandMarker>,
permissions: &'a [CommandPermission],
) -> UpdateCommandPermissions<'a>
pub fn update_command_permissions( &'a self, guild_id: Id<GuildMarker>, command_id: Id<CommandMarker>, permissions: &'a [CommandPermission], ) -> UpdateCommandPermissions<'a>
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.
This request requires that the client was configured with an OAuth2 Bearer token.
§Errors
Returns an error of type PermissionsCountInvalid
if the permissions
are invalid.