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
const{ SlashCommandBuilder }=require('discord.js');module.exports={data: newSlashCommandBuilder().setName('command_Name').setDescription('Description'),asyncexecute(interaction){//what does the command do},};
let's say we want our command to respond to our message:
asyncexecute(interaction){interaction.reply('Hi!');//interaction is an object with multiple methods and attributes},
final command with a required string option:
const{ SlashCommandBuilder }=require('discord.js');module.exports={data: newSlashCommandBuilder().setName('Greet').setDescription('Says hi to someone!'),.addStringOption(option=>option.setName('Name').setDescription('Who am i saying Hi to?').setRequired(true)),asyncexecute(interaction){//interaction is an object with multiple methods and attributes, you can for example obtain the parameters given when the slash command was launchedletname=interaction.options.getString('Name')//by doing this I'm getting the string parameter identified with 'Name'interaction.reply('Hi '+name+'!');},};