Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined as args for Slash commands with Sub Commands #219

Open
Supernalboot opened this issue May 2, 2022 · 1 comment
Open

Undefined as args for Slash commands with Sub Commands #219

Supernalboot opened this issue May 2, 2022 · 1 comment

Comments

@Supernalboot
Copy link

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 added a commit to mcdaddytalk/WOKCommands that referenced this issue May 6, 2022
@mcdaddytalk
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants