dev sync attempt 2
This commit is contained in:
parent
c7b54b0ed5
commit
991feb82a1
6 changed files with 329 additions and 163 deletions
|
@ -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,"")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue