dev sync attempt 2

This commit is contained in:
lever1209 2024-10-11 01:46:51 -03:00
commit 991feb82a1
Signed by: lever1209
GPG key ID: AD770D25A908AFF4
6 changed files with 329 additions and 163 deletions

View file

@ -5,17 +5,52 @@ sys.registerCommand({
command_category = commandCategory.info, -- this can be any string, but the bot provides a few categories already
help = "Shows you helpful information for the bot. Seems you already know how to use it. :loafplink:",
timeout = nil, -- time in milliseconds that the user must wait before running the command again
hidden = false, -- whether or not other commands should acknowledge its existance, for example we dont want dev commands showing up in the help info for regular users, regardless if they can use them or not
hidden = false, -- whether or not other commands should acknowledge its existence, for example we dont want dev commands showing up in the help info for regular users, regardless if they can use them or not
permissions = nil, -- which discord permissions they need to run the command
func = function(context, message, guildid)
for k, v in pairs(commands) do
info("Help info for command", k)
arguments = {
{
type = "positional",
position = 0,
optional = true,
data_type = "string",
checker = function(var)
for index, value in ipairs(sys.getCommandTable()) do
if value == var then
return; -- exit normally because the command was found
end
end
-- throw an error to whoever ran this function saying the command does not exist
error("Command `" .. var .. "` does not exist.", 2)
end,
},
},
func = function(context, message, guildid, commandArguments)
if commandArguments.getArgument(0) ~= nil then
log.info("Help info for command `" .. commandArguments.getArgument(0) .. "`")
else
log.info("Here is a list of all commands:")
for index, value in pairs(sys.getCommandTable()) do
if not value.hidden then
log.info("\tCommand pretty name: " .. value.pretty_name)
log.info("\tCommand name: " .. value.name)
log.info("\tCommand aliases: " .. value.aliases)
log.info("\tCommand category: " .. value.category)
log.info("\tCommand help info: " .. value.help)
end
end
end
end
})
sys.executeCommand("help", "E")
sys.executeCommand("help", "help")
sys.executeCommand("help")
-- since the next usage will throw an error, catch the error
log.info(pcall(sys.executeCommand, "help", "invalid_command"))
log.info("end")
-- exit(0)
-- local seen={}
@ -38,3 +73,4 @@ sys.executeCommand("help", "E")
-- end
-- dump(_G,"")