Slash Command

Interaction triggerInteractions

Triggers when a user runs a slash command.

  • Interaction trigger: the flow can reply to the user directly, with messages, modals and more.
  • Each option you add to the command becomes an output, with the value the user entered.

Options

Command NameRequired

The name of the slash command (1-32 chars, lowercase, no spaces).

Example: greet

Command DescriptionRequired

Description shown in Discord's command picker (1-100 chars).

Example: Greets a user

Subcommand Name

If set, this component is a subcommand under the parent command (1-32 chars, lowercase, no spaces).

Example: hello

Subcommand Group

Groups this subcommand under a named group. Requires Subcommand Name to be set.

Example: greetings

Command Options

Configure the arguments (options) for this command.

Set up in the editor. The JSON format is under advanced documentation below.

Required Permissions

Permissions a member needs to use this command. Leave empty to allow everyone.

OptionsAdd ReactionsAdministratorAttach FilesBan MembersBypass SlowmodeChange NicknameConnectCreate EventsCreate ExpressionsCreate Instant InviteCreate Private ThreadsCreate Public ThreadsDeafen MembersEmbed LinksKick MembersManage ChannelsManage EventsManage ExpressionsManage MessagesManage NicknamesManage RolesManage ServerManage ThreadsManage WebhooksMention EveryoneMove MembersMute MembersPin MessagesPriority SpeakerRead Message HistoryRequest to SpeakSend MessagesSend Messages in ThreadsSend PollsSend TTS MessagesSend Voice MessagesSet Voice Channel StatusSpeakStreamTimeout MembersUse Application CommandsUse Embedded ActivitiesUse External AppsUse External EmojisUse External SoundsUse External StickersUse SoundboardUse VADView Audit LogView ChannelView Creator Monetization AnalyticsView Guild Insights
Age Restricted

If true, the command is only available in NSFW channels.

Optionsfalsetrue
Command Availability

Where this command can be used. Defaults to Servers if empty.

OptionsServersDirect MessagesGroup DMs
Integration Type

Where this command can be installed. Defaults to Server Installable if empty.

OptionsServer InstallableUser Installable

Outputs

User ID

ID of the user who ran the command.

Example: 123456789012345678

Username

Username of the invoking user.

Example: johndoe

User Avatar URL

Avatar URL of the invoking user.

Example: https://cdn.discordapp.com/avatars/123/abc.png

Channel ID

Channel where the command was used.

Example: 123456789012345678

Server ID

Server where the command was used.

Example: 123456789012345678

Application ID

ID of the application that received this interaction.

Example: 123456789012345678

Command ID

ID of the slash command that Discord invoked.

Example: 123456789012345678

Interaction ID

Unique interaction ID for this command invocation.

Example: 123456789012345678

Interaction Token

Token for this interaction, useful for webhook follow-up/edit operations.

Example: aW50ZXJhY3Rpb25fdG9rZW4

App Permissions

Permissions the bot/application had in the interaction channel, as a Discord bitfield string.

Example: 274877990912

User Locale

Discord locale of the user who ran the command.

Example: en-US

Server Locale

Preferred locale of the server where the command was used, when available.

Example: en-US

Interaction Context

Where the interaction was used (`server`, `bot_dm`, or `private_channel`).

Example: server

Build a bot using triggers like Slash Command

Use this trigger in our visual flow editor. Bots are hosted 24/7 for free on inventor.bot.

Advanced Documentation

This documentation can be useful when using code mode. View as Markdown

ID: slash_command
  • Interaction trigger: blocks that respond to interactions (replies, modals, ...) can be used in its flows.
  • Each command option is an extra output named opt_<option id>, e.g. trigger.opt_user.

Options

FieldInventScript nameValue
Command Namecommand_namee.g. "greet"
Command Descriptioncommand_descriptione.g. "Greets a user"
Subcommand Namesubcommand_namee.g. "hello"
Subcommand Groupsubcommand_groupe.g. "greetings"
Command Optionscommand_optionsJSON text
Required Permissionsdefault_member_permissions"Add Reactions", "Administrator", "Attach Files", "Ban Members", "Bypass Slowmode", "Change Nickname", "Connect", "Create Events", "Create Expressions", "Create Instant Invite", "Create Private Threads", "Create Public Threads", "Deafen Members", "Embed Links", "Kick Members", "Manage Channels", "Manage Events", "Manage Expressions", "Manage Messages", "Manage Nicknames", "Manage Roles", "Manage Server", "Manage Threads", "Manage Webhooks", "Mention Everyone", "Move Members", "Mute Members", "Pin Messages", "Priority Speaker", "Read Message History", "Request to Speak", "Send Messages", "Send Messages in Threads", "Send Polls", "Send TTS Messages", "Send Voice Messages", "Set Voice Channel Status", "Speak", "Stream", "Timeout Members", "Use Application Commands", "Use Embedded Activities", "Use External Apps", "Use External Emojis", "Use External Sounds", "Use External Stickers", "Use Soundboard", "Use VAD", "View Audit Log", "View Channel", "View Creator Monetization Analytics", "View Guild Insights"
Age Restrictedcommand_nsfw"false", "true"
Command Availabilitycommand_contexts"Servers", "Direct Messages", "Group DMs"
Integration Typecommand_integration_types"Server Installable", "User Installable"
command_options format: JSON text of type SlashCommandOption[]. Fields marked ? are optional.
type SlashCommandOption = {
	id: string // unique; the trigger output is opt_<id>
	name: string // 1-32 chars, lowercase, no spaces
	description: string // 1-100 chars
	type: number // 3=String, 4=Integer, 5=Boolean, 6=User, 7=Channel, 8=Role, 9=Mentionable, 10=Number, 11=Attachment
	required: boolean
	choices?: SlashCommandChoice[] // types 3, 4 and 10 only
	min_value?: number // types 4 and 10 only
	max_value?: number // types 4 and 10 only
	min_length?: number // type 3 only
	max_length?: number // type 3 only
	channel_types?: number[] // Discord channel types, type 7 only
}

type SlashCommandChoice = {
	name: string
	value: any // a string for type 3, a number for types 4 and 10
}

Outputs

FieldInventScript nameValue
User IDuser_ide.g. "123456789012345678"
Usernameusernamee.g. "johndoe"
User Avatar URLuser_avatare.g. "https://cdn.discordapp.com/avatars/123/abc.png"
Channel IDchannel_ide.g. "123456789012345678"
Server IDserver_ide.g. "123456789012345678"
Application IDapplication_ide.g. "123456789012345678"
Command IDcommand_ide.g. "123456789012345678"
Interaction IDinteraction_ide.g. "123456789012345678"
Interaction Tokeninteraction_tokene.g. "aW50ZXJhY3Rpb25fdG9rZW4"
App Permissionsapp_permissionse.g. "274877990912"
User Localeuser_localee.g. "en-US"
Server Localeserver_localee.g. "en-US"
Interaction Contextinteraction_contexte.g. "server"

Example InventScript

var trigger = slash_command(Args{command_name: "greet", command_description: "Greets a user"})

func main() {
	send_text_message(Args{
		channel_id:      trigger.channel_id,
		message_content: "User ID: " + trigger.user_id,
	})
}

More interactions triggers