🎒
TouchGuild Guide
Get back Home
  • TouchGuild's Docs
  • Introduction
  • Privacy Policy
  • 📝Installation & Preparation
  • âš’ī¸Setting up an application
  • 🤖Creating your application
  • Intents
  • Application Commands
    • Registering
    • Command Interactions
    • Components
  • đŸ“ŦManaging messages
    • â„šī¸Tips
    • Original Message concept & how it works
    • Creating embeds
  • Permissions & Roles
  • 😰Reactions
  • Data & Analytics
  • Managing members
    • đŸ’¯Award experience to server members
    • đŸĻĩBan, unban & kick server members
Powered by GitBook
On this page
  • Get interaction data
  • Simple example

Was this helpful?

  1. Application Commands

Command Interactions

Interaction that is triggered when executing an application command.

To detect triggered command interactions, use the "interactionCreate" event, that way you can get each interaction including Command Interactions that are executed by users.

client.on("interactionCreate", async interaction => {
    // Perform actions here
});

Get interaction data

Interaction Data are located inside CommandIntreraction#data.

Some data include the interaction name, options, and more.

interaction.data.name
interaction.data.applicationCommand
interaction.data.options

Simple example

client.on("interactionCreate", async interaction => {
    if (interaction.data.name === "say") {
        // context: "text" option is required, and should'nt return undefined.
        const textInput = interaction.data.options.getStringOption("text", true);
        await interaction.createMessage({ 
            content: "Your text input:", textInput
        });
    }
});
PreviousRegisteringNextComponents

Last updated 8 months ago

Was this helpful?