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().await?.models().await?;

println!("there are {} global commands", commands.len());

Implementations§

source§

impl<'a> InteractionClient<'a>

source

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.

source

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.

source

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.

source

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.

source

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?;
source

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.

source

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.

source

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.

source

pub const fn create_global_command(&'a self) -> CreateGlobalCommand<'a>

Create a new global command.

source

pub const fn delete_global_command( &self, command_id: Id<CommandMarker> ) -> DeleteGlobalCommand<'_>

Delete a global command, by ID.

source

pub const fn global_command( &self, command_id: Id<CommandMarker> ) -> GetGlobalCommand<'_>

Fetch a global command for your application.

source

pub const fn global_commands(&self) -> GetGlobalCommands<'_>

Fetch all global commands for your application.

source

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.

source

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.

source

pub const fn create_guild_command( &'a self, guild_id: Id<GuildMarker> ) -> CreateGuildCommand<'a>

Create a new command in a guild.

source

pub const fn delete_guild_command( &self, guild_id: Id<GuildMarker>, command_id: Id<CommandMarker> ) -> DeleteGuildCommand<'_>

Delete a command in a guild, by ID.

source

pub const fn guild_command( &self, guild_id: Id<GuildMarker>, command_id: Id<CommandMarker> ) -> GetGuildCommand<'_>

Fetch a guild command for your application.

source

pub const fn guild_commands( &self, guild_id: Id<GuildMarker> ) -> GetGuildCommands<'_>

Fetch all commands for a guild, by ID.

source

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.

source

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.

source

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.

source

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.

source

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.

Trait Implementations§

source§

impl<'a> Debug for InteractionClient<'a>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for InteractionClient<'a>

§

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§

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

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