AlexzanderFlores / WOKCommands

132 stars 61 forks source link

Undefined as args for Slash commands with Sub Commands #219

Open Supernalboot opened 2 years ago

Supernalboot commented 2 years ago

Recently (or possibly forever now) the args command has been returning an array value with undefined as the first array value. Upon further delving into your code (SlashCommands.js) at line 65 is where it seems to pass the arguments through as strings, this is returning undefined as it cannot convert an object into a string. My code is a bit long but ill post a small snippet that should be able to replicate the problem

module.exports = {
    name: "initials",
    slash: true,
    options:
        [{
            name: 'initials', description: 'provide your first and last name', type: Discord.Constants.ApplicationCommandOptionTypes.SUB_COMMAND, required: false, options: [
                { name: 'firstname', description: 'Your first name', type: Discord.Constants.ApplicationCommandOptionTypes.STRING, required: true, options: null },
                { name: 'lastname', description: 'Your last name', type: Discord.Constants.ApplicationCommandOptionTypes.STRING, required: false, options: null }],
        }],

    callback: async ({ interaction, args, client }) => {
        firstname = args[0];
        lastname = args[1];
        interaction.reply(`Your firstname is ${firstname} and your lastname is ${lastname}`)
    }
}

Running this command returns "Your firstname is undefined and your lastname is undefined"

mcdaddytalk commented 2 years ago

@Supernalboot I put in a PR to fix this, so you are capable of updating yourself, you can grab the code and replace in yours until it is merged.