You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{SlashCommandBuilder}from'@discordjs/builders';// Create a slash command builderconstpingCommand=newSlashCommandBuilder().setName('ping').setDescription('Check if this interaction is responsive');// Get the raw data that can be sent to DiscordconstrawData=pingCommand.toJSON();
Arguments
import{SlashCommandBuilder}from'@discordjs/builders';// Creates a boop commandconstboopCommand=newSlashCommandBuilder().setName('boop').setDescription('Boops the specified user, as many times as you want');// Adds a user argument to the commandboopCommand.addUserOption((option)=>option.setName('user').setDescription('The user to boop').setRequired(true));// Adds an integer optionboopCommand.addIntegerOption((option)=>option.setName('boop_amount').setDescription('How many times should the user be booped (defaults to 1)'),);// Supports choices too!boopCommand.addIntegerOption((option)=>option.setName('boop_reminder').setDescription('How often should we remind you to boop the user').addChoice('Every day',1).addChoice('Weekly',7)// Or, if you prefer adding more choices at once, you can use an array.addChoices([['Every three months',90],['Yearly',365],]),);// Get the final raw data that can be sent to DiscordconstrawData=boopCommand.toJSON();
Sub commands and sub command groups
import{SlashCommandBuilder}from'@discordjs/builders';constpointsCommand=newSlashCommandBuilder().setName('points').setDescription('Lists or manages user points');// Add a manage grouppointsCommand.addSubCommandGroup((group)=>group.setName('manage').setDescription('Shows or manages points in the server').addSubCommand((subCommand)=>subCommand.setName('user_points').setDescription("Alters a user's points").addUserOption((option)=>option.setName('user').setDescription('The user whose points to alter').setRequired(true),).addStringOption((option)=>option.setName('action').setDescription('What action should be taken with the users points?').addChoices([['Add points','add'],['Remove points','remove'],['Reset points','reset'],]).setRequired(true),).addIntegerOption((option)=>option.setName('points').setDescription('Points to add or remove')),),);// Add an information grouppointsCommand.addSubCommandGroup((group)=>group.setName('info').setDescription('Shows information about points in the guild').addSubCommand((subCommand)=>subCommand.setName('total').setDescription('Tells you the total amount of points given in the guild'),).addSubCommand((subCommand)=>subCommand.setName('user').setDescription("Lists a user's points").addUserOption((option)=>option.setName('user').setDescription('The user whose points to list').setRequired(true),),),);// Get the final raw data that can be sent to DiscordconstrawData=pointsCommand.toJSON();