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

attempt to index local 'args' (a nil value) error when the only optional argument is not provided #15

Open
error4OA opened this issue Aug 22, 2023 · 4 comments

Comments

@error4OA
Copy link

whenever a slash command option is optional and not provided, it returns this error:

attempt to index local 'args' (a nil value)

this is my code:

local slashCommand = {}
local option = {}

slashCommand = tools.slashCommand("amount", "see amount of flops you/user have/has said")
option = tools.user("member", "the member")

option = option:setRequired(false)

slashCommand = slashCommand:addOption(option)

client:createGlobalApplicationCommand(slashCommand)
client:on("slashCommand", function(interaction, command, args)
    if command.name == "amount" then
        if db[ tostring( args.member.id ) ] then
            interaction:reply( args.member.name .. " has said flop " .. tostring( db[ tostring( args.member.id ) ] ) .. " times" )
        else
            interaction:reply( args.member.name .. " hasn't said flop" )
        end
    end
end)

any help?

@GitSparTV
Copy link
Owner

Are you using lit or GitHub version?

@error4OA
Copy link
Author

github version

@GitSparTV
Copy link
Owner

I didn't support global commands by default. Someone made a commit, but I can't tell if this is related.

Is "member" a required parameter?

@error4OA
Copy link
Author

no

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