gitspartv / discordia-slash Goto Github PK
View Code? Open in Web Editor NEWDiscordia application commands extension
License: MIT License
Discordia application commands extension
License: MIT License
discordia-slash/Application.lua
Line 49 in bb36215
data.options is optional according to the interaction data structure spec
https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data-structure
Uncaught Error: ...uff/ACCOUNT TRACKER/deps/discordia-slash/Application.lua:26: bad argument #1 to 'ipairs' (table expected, got nil)
stack traceback:
[C]: in function 'ipairs'
...uff/ACCOUNT TRACKER/deps/discordia-slash/Application.lua:26: in function 'makeParams'
...uff/ACCOUNT TRACKER/deps/discordia-slash/Application.lua:48: in function <...uff/ACCOUNT TRACKER/deps/discordia-slash/Application.lua:42>
https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-structure
Uses default_permission instead of default_member_permissions and there's no function to use/set the one that isn't being deprecated (default_member_permissions)
If you pass a user that's not in the server to a slash command with a user option, it will error. Seems to be because it checks resolved.members which is actually resolved.users when the user isn't in the server.
https://github.com/GitSparTV/discordia-slash/blob/master/libs/client/Client.lua#L171
local dis = require("discordia")
local slash = require("discordia-slash")
slash.constructor()
local client = dis.Client()
client:useSlashCommands()
client:on("slashCommandsReady", function()
client:slashCommand({
name = "test2",
description = "description",
options = {
{
name = "arg",
description = "argdesc",
type = slash.enums.optionType.string,
required = true
}
},
callback = function(ia, params, cmd)
end
})
end)
Ran this code (Basically straight from the readme docs) and got this error
I'm new to Discordia and this addon so sorry If I'm being dumb
So, when I tried to reply to interaction, this showed up :
This is my code :
client:on("slashCommandsReady", function()
for _,i in pairs(fs.readdirSync("./commands")) do
local fileName = string.sub(i, 1, #i - 4)
local commandModule = require("./commands/" .. i)
print("Loading " .. fileName)
local commandSlash = client:slashCommand({
name = fileName,
description = commandModule.desc,
options = commandModule.options,
callback = function(ia, params, cmd)
ia:reply("yes")
--commandModule.execute(client, ia, params)
end
})
print("Loaded " .. fileName)
local succes, error = pcall(function()
commandSlash:publish()
end)
if not succes then
print("Failed to publish " .. fileName)
print(error)
else
print("Published " .. fileName)
end
end
end)
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?
Can a video tutorial be made about this? I'm super confused about how I should be doing this. I tried to use:
client:slashCommand()
using the example. It doesn't show up as an error anymore, but I'm not sure what's supposed to happen after. The slash command doesn't appear in Discord, and when I tried to test the example ban command, it came up with an error (yes, I changed "guildid" to the actual guild id). It just errors with "bad request," and I'm stumped on how to fix this. Slash commands for my bot aren't THAT important to me, but I'd like to have them.
A believe there is a missing not in discordia-slash -> util -> tools.lua line 236.
For some users, the v.type (subCommand) returns nil.
Uncaught Error: /home/santa/deps/discordia-slash/Application.lua:33: attempt to call a nil value
Uncaught Error: discordia-slash/Application.lua:115: bad argument #1 to 'pairs' (table expected, got nil)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.