Open 4Lajf opened 2 years ago
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 array
const name = interaction.options.getString('name');
const age = interaction.options.getString('age');
// 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
})
}
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,
}],
To get the type use this https://discord.com/developers/docs/interactions/application-commands#:~:text=by%20the%20application.-,Application%20Command%20Option%20Type,-NAME
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