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
module.exports = {
category: 'Testing', // Required for slash commands
description: 'Displays your name and age', // Required for slash commands
slash: 'both', // Support both legacy and slash command syntax
testOnly: true, // Ensure you have test servers setup
minArgs: 2,
expectedArgs: '<name> <age>',
callback: ({ message, interaction, args }) => {
// Destructure the name and age from the args array
const [name, age] = args
// Create a string that is used in either command syntax
const reply = `Hello my name is ${name} and I am ${age} years old.`
// The message property will be undefined if the command is ran
// as a slash command. It is encouraged to check if 'message' or
// 'interaction' exists before interacting with them.
if (message) {
message.reply({
content: reply
})
}
// The interaction property will be undefined if the command is
// ran as a legacy command. It is encouraged to check if 'message' or
// 'interaction' exists before interacting with them.
if (interaction) {
interaction.reply({
content: reply
})
}
}
}
Which is really weird bcs the last example in the docs works
The text was updated successfully, but these errors were encountered:
Ran into this issue as well, my workaround was to use interaction.options.getString('argument value').
So for the above it would be something like.
callback: ({ message, interaction, args })=>{// Destructure the name and age from the args arrayconstname=interaction.options.getString('name');constage=interaction.options.getString('age');// Create a string that is used in either command syntaxconstreply=`Hello my name is ${name} and I am ${age} years old.`// The message property will be undefined if the command is ran// as a slash command. It is encouraged to check if 'message' or// 'interaction' exists before interacting with them.if(message){message.reply({content: reply})}
to get this to work you need to add this to your code for example here is what I used for my kick command
options: [
{
name: 'user',// This has to be lowercase
description: 'The User you want to kick',
required: true,
type: 6,
}, {
name: 'reason',// This has to be lowercase
description: 'The reason for the kick',
required: true,
type: 3,
}],
The same exact command works diferently between legacy and slash options.
https://cdn.discordapp.com/attachments/818363058656509993/895043214933893171/unknown.png
The code is copied from the docs and it's as follows:
Which is really weird bcs the last example in the docs works
The text was updated successfully, but these errors were encountered: