Ain't afraid of no bed
This commit is contained in:
parent
ca17b716ba
commit
f9bb6824f3
|
@ -10,106 +10,94 @@ local table_utils = import("table-utils")
|
||||||
local purify = import("purify")
|
local purify = import("purify")
|
||||||
function command_handler:__init(parent_server)
|
function command_handler:__init(parent_server)
|
||||||
self.server_handler = assert(parent_server,"parent server handler not provided")
|
self.server_handler = assert(parent_server,"parent server handler not provided")
|
||||||
self.command_pool = {}
|
self.pool = {}
|
||||||
self.prefixes = {}
|
self.prefixes = {}
|
||||||
self.command_meta = {
|
self.meta = {
|
||||||
plugins = {},
|
plugins = {},
|
||||||
categories = {}
|
categories = {}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
function command_handler:add_prefix(prefix)
|
function command_handler:add_prefix(prefix)
|
||||||
local purified_prefix = purify.purify_escapes(prefix)
|
self.prefixes[prefix] = purify.purify_escapes(prefix)
|
||||||
self.prefixes[purified_prefix] = purified_prefix
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
function command_handler:remove_prefix(prefix)
|
function command_handler:remove_prefix(prefix)
|
||||||
local purified_prefix = purify.purify_escapes(prefix)
|
local prefix = purify_escapes(prefix)
|
||||||
if self.prefixes[purified_prefix] or table_utils.count(self.prefixes) <= 1 then
|
if self.prefixes[prefix] and table_utils.count(self.prefixes) > 1 then
|
||||||
self.prefix[purified_prefix] = nil
|
self.prefixes[prefix] = nil
|
||||||
return true
|
return true
|
||||||
else
|
|
||||||
return false, (
|
|
||||||
(self.prefixes[purified_prefix] and "No such prefix") or
|
|
||||||
"Cannot remove the last remaining prefix"
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
if not self.prefixes[prefix] then
|
||||||
|
return false, "Prefix not found"
|
||||||
|
end
|
||||||
|
return false, "Cannot remove last remaining prefix!"
|
||||||
end
|
end
|
||||||
function command_handler:get_prefixes()
|
function command_handler:get_prefixes()
|
||||||
return table_utils.deepcopy(self.prefixes)
|
return table_utils.deepcopy(self.prefixes)
|
||||||
end
|
end
|
||||||
function command_handler:add_command(command)
|
function command_handler:add_command(command)
|
||||||
assert(type(command) == "table","command object expected")
|
assert(type(command) == "table","command object expected")
|
||||||
local purified_name = purify.purify_escapes(command.name)
|
if self.pool[command.name] then
|
||||||
self.command_pool[purified_name] = command
|
return false, "Already have a command with the same name"
|
||||||
if not self.command_meta.plugins[command.parent.name] then
|
|
||||||
self.command_meta.plugins[command.parent.name] = {}
|
|
||||||
end
|
end
|
||||||
if not self.command_meta.categories[command.options.category] then
|
self.pool[command.name] = command
|
||||||
self.command_meta.categories[command.options.category] = {}
|
if not self.meta.plugins[command.parent.name] then
|
||||||
|
self.meta.plugins[command.parent.name] = {}
|
||||||
end
|
end
|
||||||
table.insert(self.command_meta.categories[command.options.category],command.name)
|
self.meta.plugins[command.parent.name][command.name] = command.name
|
||||||
table.insert(self.command_meta.plugins[command.parent.name],command.name)
|
if not self.meta.categories[command.category] then
|
||||||
|
self.meta.categories[command.category] = {}
|
||||||
|
end
|
||||||
|
self.meta.categories[command.category][command.name] = command.name
|
||||||
return command
|
return command
|
||||||
end
|
end
|
||||||
function command_handler:remove_command(command)
|
function command_handler:remove_command(command)
|
||||||
assert(type(command) == "table","command object expected")
|
assert(type(command) == "table","command object expected")
|
||||||
local purified_name = purify.purify_escapes(command.name)
|
if not self.pool[command.name] then
|
||||||
if self.command_pool[purified_name] then
|
|
||||||
local command = self.command_pool[purified_name]
|
|
||||||
--not exactly optimal, but lists are lists. can't do much about them.
|
|
||||||
table_utils.remove_value(self.command_meta.plugins[command.parent.name],command.name)
|
|
||||||
if #self.command_meta.plugins[command.parent.name] == 0 then
|
|
||||||
self.command_meta.plugins[command.parent.name] = nil
|
|
||||||
end
|
|
||||||
table_utils.remove_value(self.command_meta.categories[command.options.category],command.name)
|
|
||||||
if #self.command_meta.categories[command.options.category] == 0 then
|
|
||||||
self.command_meta.categories[command.options.category] = nil
|
|
||||||
end
|
|
||||||
self.command_pool[purified_name] = nil
|
|
||||||
return true
|
|
||||||
else
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
self.pool[command.name] = nil
|
||||||
|
self.meta.categories[command.category][command.name] = nil
|
||||||
|
self.meta.plugins[command.parent.name][command.name] = nil
|
||||||
end
|
end
|
||||||
function command_handler:get_command(name)
|
function command_handler:get_command(name)
|
||||||
local purified_name = purify.purify_escapes(assert(type(name) == "string") and name)
|
return self.pool[name]
|
||||||
if self.command_pool[purified_name] then
|
|
||||||
return self.command_pool[purified_name]
|
|
||||||
else
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
function command_handler:get_commands(name)
|
function command_handler:get_commands(name)
|
||||||
local list = {}
|
local list = {}
|
||||||
for k,v in pairs(self.command_pool) do
|
for k,v in pairs(self.pool) do
|
||||||
table.insert(list,k)
|
table.insert(list,k)
|
||||||
end
|
end
|
||||||
return list
|
return list
|
||||||
end
|
end
|
||||||
function command_handler:get_commands_metadata()
|
function command_handler:get_metadata()
|
||||||
return table_utils.deepcopy(self.command_meta)
|
local plugins,categories = {},{}
|
||||||
|
for k,v in pairs(self.meta.plugins) do
|
||||||
|
plugins[k] = table_utils.listcopy(v)
|
||||||
|
end
|
||||||
|
for k,v in pairs(self.meta.categories) do
|
||||||
|
categories[k] = table_utils.listcopy(v)
|
||||||
|
end
|
||||||
|
return {
|
||||||
|
plugins = plugins,
|
||||||
|
categories = categories
|
||||||
|
}
|
||||||
end
|
end
|
||||||
function command_handler:handle(message)
|
function command_handler:handle(message)
|
||||||
for name,command in pairs(self.command_pool) do
|
local content = message.content
|
||||||
if command.options.regex then
|
local prefix = ""
|
||||||
if message.content:match(command.options.regex) then
|
local command
|
||||||
command:exec(message)
|
for k,v in pairs(self.prefixes) do
|
||||||
return
|
if content:match("^"..v) then
|
||||||
end
|
prefix = v
|
||||||
else
|
|
||||||
if command.options.prefix then
|
|
||||||
for _,prefix in pairs(self.prefixes) do
|
|
||||||
if message.content:match("^"..prefix..name.."$") or message.content:match("^"..prefix..name.."%s") then
|
|
||||||
command:exec(message)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if message.content:match("^"..name.."$") or message.content:match("^"..name.."%s") then
|
|
||||||
command:exec(message)
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
command = content:sub(prefix:len()+1,-1):match("^[%-_%w]+")
|
||||||
|
if self.pool[command] then
|
||||||
|
if (prefix == "") and self.pool[command].options.prefix == false then
|
||||||
|
self.pool[command]:exec(message)
|
||||||
|
elseif (prefix ~= "") and self.pool[command].options.prefix == true then
|
||||||
|
self.pool[command]:exec(message)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,10 +11,10 @@ function command:__init(name,callback)
|
||||||
self.rules = acl()
|
self.rules = acl()
|
||||||
self.name = name
|
self.name = name
|
||||||
self.timer = discordia.Date():toMilliseconds()
|
self.timer = discordia.Date():toMilliseconds()
|
||||||
|
self.category = "None"
|
||||||
self.options = {
|
self.options = {
|
||||||
allow_bots = false, --allow bots to execute the command
|
allow_bots = false, --allow bots to execute the command
|
||||||
typing_decorator = false, --set if the bot should be "typing" while the command executes
|
typing_decorator = false, --set if the bot should be "typing" while the command executes
|
||||||
category = "None", --set category for the command
|
|
||||||
prefix = true, --if true check for prefix at the start. if not, don't check for prefix
|
prefix = true, --if true check for prefix at the start. if not, don't check for prefix
|
||||||
no_parsing = false, --check if you want to disable the message argument parsing process
|
no_parsing = false, --check if you want to disable the message argument parsing process
|
||||||
timeout = 1000, --set the timeout for a command
|
timeout = 1000, --set the timeout for a command
|
||||||
|
|
|
@ -56,4 +56,27 @@ function plugin:remove_command(command_object)
|
||||||
self.command_handler:remove_command(command_object)
|
self.command_handler:remove_command(command_object)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function plugin:load_helpdb(path)
|
||||||
|
local helpdb_file = io.open(path,r)
|
||||||
|
local helpdb,err = load(helpdb_file:read("*a") or "","helpdb "..path,nil,
|
||||||
|
setmetatable({
|
||||||
|
require = require,
|
||||||
|
import = import
|
||||||
|
},{
|
||||||
|
__index = _G
|
||||||
|
})
|
||||||
|
)
|
||||||
|
helpdb_file:close()
|
||||||
|
if not helpdb then
|
||||||
|
error(err)
|
||||||
|
end
|
||||||
|
helpdb = helpdb()
|
||||||
|
self:for_all_commands(function(command)
|
||||||
|
if helpdb[command.name] then
|
||||||
|
command:set_help(helpdb[command.name])
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
return plugin
|
return plugin
|
||||||
|
|
|
@ -38,8 +38,8 @@ function server_handler:__init(client,guild,options)
|
||||||
self.autosave = options.path or true
|
self.autosave = options.path or true
|
||||||
self.autosave_frequency = options.autosave_frequency or 10
|
self.autosave_frequency = options.autosave_frequency or 10
|
||||||
self.plugin_search_paths = options.plugin_search_paths or {"./plugins/"}
|
self.plugin_search_paths = options.plugin_search_paths or {"./plugins/"}
|
||||||
self.default_plugins = options.default_plugins or {"test"}
|
self.default_plugins = options.default_plugins or {"plugins"}
|
||||||
self.default_prefixes = options.default_prefixes or {"&","<@!"..self.client.user.id..">"}
|
self.default_prefixes = options.default_prefixes or {"&","<@"..self.client.user.id.."> "}
|
||||||
self.config = {}
|
self.config = {}
|
||||||
self.config_path = self.config_path:gsub("%%id",self.id)
|
self.config_path = self.config_path:gsub("%%id",self.id)
|
||||||
self:load_config()
|
self:load_config()
|
||||||
|
|
|
@ -28,7 +28,7 @@ return function(reqfunc)
|
||||||
import = import,
|
import = import,
|
||||||
},{__index = _G}))
|
},{__index = _G}))
|
||||||
if err then
|
if err then
|
||||||
error("[import: "..filname.."] "..tostring(err))
|
error("[import: "..filename.."] "..tostring(err))
|
||||||
end
|
end
|
||||||
return f()
|
return f()
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,6 +21,8 @@ purify.purify_pings = function(msg,input)
|
||||||
end
|
end
|
||||||
text = text:gsub("<@(%D*)"..id..">",substitution)
|
text = text:gsub("<@(%D*)"..id..">",substitution)
|
||||||
end
|
end
|
||||||
|
text = text:gsub("@everyone","")
|
||||||
|
text = text:gsub("@here","")
|
||||||
return text
|
return text
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,14 @@ utilities.shallowcopy = function(orig)
|
||||||
end
|
end
|
||||||
return copy
|
return copy
|
||||||
end
|
end
|
||||||
|
|
||||||
|
utilities.listcopy = function(orig)
|
||||||
|
local list = {}
|
||||||
|
for k,v in pairs(orig) do
|
||||||
|
table.insert(list,v)
|
||||||
|
end
|
||||||
|
return list
|
||||||
|
end
|
||||||
--overwrite the original table's properties with new properties
|
--overwrite the original table's properties with new properties
|
||||||
utilities.overwrite = function(original,overwrite)
|
utilities.overwrite = function(original,overwrite)
|
||||||
local new = utilities.shallowcopy(original)
|
local new = utilities.shallowcopy(original)
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
return {
|
||||||
|
["event"] = {embed={
|
||||||
|
title = "Add a cron event",
|
||||||
|
description = "https://github.com/512mb-org/512mb.org-bot/wiki/Events-and-cronjobs",
|
||||||
|
fields = {
|
||||||
|
{name = "Usage:",value = "event ..."},
|
||||||
|
{name = "Perms:",value = "administrator"},
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
["delay"] = {embed={
|
||||||
|
title = "Delay a command",
|
||||||
|
description = "Delay fromat is <number><unit>, where unit is one of the follwing:\n\"h\" - hour,\n\"m\" - minute,\n\"d\" - day,\n\"w\" - week,\n\"y\" - year",
|
||||||
|
fields = {
|
||||||
|
{name = "Usage:",value = "delay <delayformat> <command>"},
|
||||||
|
{name = "Perms:",value = "any"},
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
["events"] = {embed={
|
||||||
|
title = "View your running events",
|
||||||
|
description = "nuff said.",
|
||||||
|
fields = {
|
||||||
|
{name = "Usage:",value = "events <page>"},
|
||||||
|
{name = "Perms:",value = "any"},
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
["user-events"] = {embed={
|
||||||
|
title = "View running events of a certain user",
|
||||||
|
description = "nuff said.",
|
||||||
|
fields = {
|
||||||
|
{name = "Usage:",value = "user-events <user> <page>"},
|
||||||
|
{name = "Perms:",value = "administrator"},
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
["remove-event"] = {embed={
|
||||||
|
title = "Remove an event",
|
||||||
|
description = "nuff said.",
|
||||||
|
fields = {
|
||||||
|
{name = "Usage:",value = "remove-event <id>"},
|
||||||
|
{name = "Perms:",value = "any"},
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
["remove-user-event"] = {embed={
|
||||||
|
title = "Remove an event from a user",
|
||||||
|
description = "nuff said.",
|
||||||
|
fields = {
|
||||||
|
{name = "Usage:",value = "remove-user-event <user> <id>"},
|
||||||
|
{name = "Perms:",value = "administrator"},
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
}
|
|
@ -195,20 +195,8 @@ for _,evtype in pairs(config.events.event) do
|
||||||
end
|
end
|
||||||
|
|
||||||
local event = command("event",{
|
local event = command("event",{
|
||||||
help = {embed={
|
perms = {"administrator"},
|
||||||
title = "Add a cron event",
|
args = {"string"},
|
||||||
description = "https://github.com/512mb-org/512mb.org-bot/wiki/Events-and-cronjobs",
|
|
||||||
fields = {
|
|
||||||
{name = "Usage:",value = "event ..."},
|
|
||||||
{name = "Perms:",value = "administrator"},
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
perms = {
|
|
||||||
"administrator"
|
|
||||||
},
|
|
||||||
args = {
|
|
||||||
"string"
|
|
||||||
},
|
|
||||||
exec = function(msg,args,opts)
|
exec = function(msg,args,opts)
|
||||||
return create_event(msg,table.concat(args," "))
|
return create_event(msg,table.concat(args," "))
|
||||||
end
|
end
|
||||||
|
@ -216,14 +204,6 @@ local event = command("event",{
|
||||||
plugin:add_command(event)
|
plugin:add_command(event)
|
||||||
|
|
||||||
local delay = command("delay",{
|
local delay = command("delay",{
|
||||||
help = {embed={
|
|
||||||
title = "Delay a command",
|
|
||||||
description = "Delay fromat is <number><unit>, where unit is one of the follwing:\n\"h\" - hour,\n\"m\" - minute,\n\"d\" - day,\n\"w\" - week,\n\"y\" - year",
|
|
||||||
fields = {
|
|
||||||
{name = "Usage:",value = "delay <delayformat> <command>"},
|
|
||||||
{name = "Perms:",value = "any"},
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
args = {
|
args = {
|
||||||
"string",
|
"string",
|
||||||
"string"
|
"string"
|
||||||
|
@ -238,14 +218,6 @@ local delay = command("delay",{
|
||||||
plugin:add_command(delay)
|
plugin:add_command(delay)
|
||||||
|
|
||||||
local events_comm = command("events",{
|
local events_comm = command("events",{
|
||||||
help = {embed={
|
|
||||||
title = "View your running events",
|
|
||||||
description = "nuff said.",
|
|
||||||
fields = {
|
|
||||||
{name = "Usage:",value = "events <page>"},
|
|
||||||
{name = "Perms:",value = "any"},
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
exec = function(msg,args,opts)
|
exec = function(msg,args,opts)
|
||||||
args[1] = tonumber(args[1]) or 1
|
args[1] = tonumber(args[1]) or 1
|
||||||
local upto = args[1]*5
|
local upto = args[1]*5
|
||||||
|
@ -269,20 +241,8 @@ local events_comm = command("events",{
|
||||||
plugin:add_command(events_comm)
|
plugin:add_command(events_comm)
|
||||||
|
|
||||||
local user_events_comm = command("user-events",{
|
local user_events_comm = command("user-events",{
|
||||||
help = {embed={
|
args = {"member"},
|
||||||
title = "View running events of a certain user",
|
perms = {"administrator"},
|
||||||
description = "nuff said.",
|
|
||||||
fields = {
|
|
||||||
{name = "Usage:",value = "user-events <user> <page>"},
|
|
||||||
{name = "Perms:",value = "administrator"},
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
args = {
|
|
||||||
"member"
|
|
||||||
},
|
|
||||||
perms = {
|
|
||||||
"administrator"
|
|
||||||
},
|
|
||||||
exec = function(msg,args,opts)
|
exec = function(msg,args,opts)
|
||||||
args[2] = tonumber(args[2]) or 1
|
args[2] = tonumber(args[2]) or 1
|
||||||
local upto = args[2]*5
|
local upto = args[2]*5
|
||||||
|
@ -306,17 +266,7 @@ local user_events_comm = command("user-events",{
|
||||||
plugin:add_command(user_events_comm)
|
plugin:add_command(user_events_comm)
|
||||||
|
|
||||||
local remove_event= command("remove-event",{
|
local remove_event= command("remove-event",{
|
||||||
help = {embed={
|
args = {"string"},
|
||||||
title = "Remove an event",
|
|
||||||
description = "nuff said.",
|
|
||||||
fields = {
|
|
||||||
{name = "Usage:",value = "remove-event <id>"},
|
|
||||||
{name = "Perms:",value = "any"},
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
args = {
|
|
||||||
"string"
|
|
||||||
},
|
|
||||||
exec = function(msg,args,opts)
|
exec = function(msg,args,opts)
|
||||||
return remove_user_event(msg.author.id,args[1])
|
return remove_user_event(msg.author.id,args[1])
|
||||||
end
|
end
|
||||||
|
@ -324,14 +274,6 @@ local remove_event= command("remove-event",{
|
||||||
plugin:add_command(remove_event)
|
plugin:add_command(remove_event)
|
||||||
|
|
||||||
local remove_user_event_c = command("remove-user-event",{
|
local remove_user_event_c = command("remove-user-event",{
|
||||||
help = {embed={
|
|
||||||
title = "Remove an event from a user",
|
|
||||||
description = "nuff said.",
|
|
||||||
fields = {
|
|
||||||
{name = "Usage:",value = "remove-user-event <user> <id>"},
|
|
||||||
{name = "Perms:",value = "administrator"},
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
args = {
|
args = {
|
||||||
"member",
|
"member",
|
||||||
"string"
|
"string"
|
||||||
|
@ -360,10 +302,10 @@ timer:on("min",function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--load events file
|
--load events file
|
||||||
local fhandler = io.open("./plugins/cron/events.lua","r")
|
local fhandler = io.open(plugin_path.."/events.lua","r")
|
||||||
local data = fhandler:read("*a")
|
local data = fhandler:read("*a")
|
||||||
fhandler:close()
|
fhandler:close()
|
||||||
local eventfunc = load(data,"event loader: ./plugins/cron/events.lua",nil,setmetatable({
|
local eventfunc = load(data,"event loader: "..plugin_path.."/events.lua",nil,setmetatable({
|
||||||
id = id,
|
id = id,
|
||||||
client = client,
|
client = client,
|
||||||
exec = exec,
|
exec = exec,
|
||||||
|
@ -371,6 +313,7 @@ local eventfunc = load(data,"event loader: ./plugins/cron/events.lua",nil,setmet
|
||||||
config = config
|
config = config
|
||||||
},{__index = _G}))
|
},{__index = _G}))
|
||||||
eventfunc()
|
eventfunc()
|
||||||
|
|
||||||
timer:start(true)
|
timer:start(true)
|
||||||
|
|
||||||
|
plugin:load_helpdb(plugin_path.."help.lua")
|
||||||
return plugin
|
return plugin
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
return {
|
||||||
|
["save"] = "Force-save config data",
|
||||||
|
["error"] = "Force error",
|
||||||
|
["permerror"] = "Force permission error",
|
||||||
|
["return_error"] = "Force a return value error",
|
||||||
|
}
|
|
@ -1,21 +1,18 @@
|
||||||
local plugin = import("classes.plugin")("debug")
|
local plugin = import("classes.plugin")("debug")
|
||||||
local command = import("classes.command")
|
local command = import("classes.command")
|
||||||
local save = command("save",{
|
local save = command("save",{
|
||||||
help = "Force-save config data",
|
|
||||||
exec = function()
|
exec = function()
|
||||||
server:save_config()
|
server:save_config()
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
plugin:add_command(save)
|
plugin:add_command(save)
|
||||||
local err = command("error",{
|
local err = command("error",{
|
||||||
help = "Force error",
|
|
||||||
exec = function()
|
exec = function()
|
||||||
error("Errored successfully!")
|
error("Errored successfully!")
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
plugin:add_command(err)
|
plugin:add_command(err)
|
||||||
local perm_error = command("permerror",{
|
local perm_error = command("permerror",{
|
||||||
help = "Force permission error",
|
|
||||||
users = {
|
users = {
|
||||||
["245973168257368076"] = -1
|
["245973168257368076"] = -1
|
||||||
},
|
},
|
||||||
|
@ -25,11 +22,11 @@ local perm_error = command("permerror",{
|
||||||
})
|
})
|
||||||
plugin:add_command(perm_error)
|
plugin:add_command(perm_error)
|
||||||
local return_error = command("return_error",{
|
local return_error = command("return_error",{
|
||||||
help = "Force a return value error",
|
|
||||||
exec = function(msg)
|
exec = function(msg)
|
||||||
msg:reply("nono :)")
|
msg:reply("nono :)")
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
plugin:add_command(return_error)
|
plugin:add_command(return_error)
|
||||||
|
plugin:load_helpdb(plugin_path.."help.lua")
|
||||||
return plugin
|
return plugin
|
||||||
|
|
|
@ -107,9 +107,5 @@ c_befunge = command("befunge",{
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
plugin:add_command(c_befunge)
|
plugin:add_command(c_befunge)
|
||||||
local helpdb = import(plugin_path:sub(3,-1).."help")
|
plugin:load_helpdb(plugin_path.."help.lua")
|
||||||
plugin:for_all_commands(function(command)
|
|
||||||
command:set_help(helpdb[command.name])
|
|
||||||
end)
|
|
||||||
|
|
||||||
return plugin
|
return plugin
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
return {
|
||||||
|
["help"] = {embed={
|
||||||
|
title = "View help embeds for commands and plugins",
|
||||||
|
description = "To specify if it's a plugin or a command, simply add the option accordingly",
|
||||||
|
fields = {
|
||||||
|
{name = "Usage:",value = "help [<command> or --plugin <plugin>]"},
|
||||||
|
{name = "Perms:",value = "any"},
|
||||||
|
{name = "Options:",value = "--plugin"}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
}
|
|
@ -1,92 +1,42 @@
|
||||||
local pluginc = import("classes.plugin")
|
local pluginc = import("classes.plugin")
|
||||||
local command = import("classes.command")
|
local command = import("classes.command")
|
||||||
local plugin = pluginc("help")
|
local plugin = pluginc("help")
|
||||||
math.randomseed(os.time()+os.clock())
|
local color = discordia.Color.fromHex
|
||||||
local help_message
|
|
||||||
local function randomize_stuff()
|
|
||||||
local chance = math.random(1,100)
|
|
||||||
if chance < 10 then
|
|
||||||
help_message = [[
|
|
||||||
This button here, builds Teleporters. This button, builds Dispensers.
|
|
||||||
And this little button makes them enemy sum-bitches wish they'd never been born!
|
|
||||||
|
|
||||||
--the inspiration behind this bot's design ]]
|
|
||||||
elseif chance >= 10 and chance < 90 then
|
|
||||||
help_message = [[
|
|
||||||
This plugin provides the help command, which can view help messages for plugins and commands
|
|
||||||
]]
|
|
||||||
else
|
|
||||||
help_message = [[
|
|
||||||
see the invisible
|
|
||||||
do the impossible
|
|
||||||
row row
|
|
||||||
fight da powah
|
|
||||||
]]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function count(tab)
|
|
||||||
local count = 0
|
|
||||||
for k,v in pairs(tab) do
|
|
||||||
count = count+1
|
|
||||||
end
|
|
||||||
return count
|
|
||||||
end
|
|
||||||
|
|
||||||
local function concatenate_keys(tab)
|
|
||||||
local key_list = {}
|
|
||||||
for k,v in pairs(tab) do
|
|
||||||
table.insert(key_list,k)
|
|
||||||
end
|
|
||||||
return "``"..table.concat(key_list,"``,\n``").."``"
|
|
||||||
end
|
|
||||||
|
|
||||||
local help_command = command("help",{
|
local help_command = command("help",{
|
||||||
help = {embed={
|
|
||||||
title = "View help embeds for commands and plugins",
|
|
||||||
description = "To specify if it's a plugin or a command, simply add the option accordingly",
|
|
||||||
fields = {
|
|
||||||
{name = "Usage:",value = "help [<command> or --plugin <plugin>]"},
|
|
||||||
{name = "Perms:",value = "any"},
|
|
||||||
{name = "Options:",value = "--plugin"}
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
exec = function(msg,args,opts)
|
exec = function(msg,args,opts)
|
||||||
randomize_stuff()
|
|
||||||
local embed = {
|
local embed = {
|
||||||
color = discordia.Color.fromHex("32b3bc").value
|
color = color("32b3bc").value
|
||||||
}
|
}
|
||||||
if args[1] then
|
if args[1] then
|
||||||
if count(opts) < 1 then
|
if not opts["plugin"] then
|
||||||
if command_handler:get_command(args[1]) then
|
if command_handler:get_command(args[1]) then
|
||||||
local command = command_handler:get_command(args[1])
|
local command = command_handler:get_command(args[1])
|
||||||
embed = command:get_help().embed
|
embed = command:get_help().embed
|
||||||
else
|
else
|
||||||
embed.description = "No such command"
|
embed.description = "No such command: "..args[1]
|
||||||
end
|
embed.color = color("990000").value
|
||||||
elseif (opts["plugin"]) then
|
|
||||||
--[[ if plugin_data["plugins"] [args[1] ] then
|
|
||||||
embed.title = "Plugin ``"..args[1].."``:"
|
|
||||||
embed.description = plugin_data["plugins"] [args[1] ]["_help"]
|
|
||||||
embed.fields = {{
|
|
||||||
name = "Commands:",
|
|
||||||
value ="``"..table.concat(plugin_data["plugins"] [args[1] ],"``,\n``").."``"
|
|
||||||
}}
|
|
||||||
else
|
|
||||||
embed.description = "No such plugin"
|
|
||||||
end
|
|
||||||
--]]
|
|
||||||
embed.title = "Not yet implemented"
|
|
||||||
embed.description = "Check again later"
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
local meta = command_handler:get_metadata()
|
||||||
|
local comms = meta.plugins[args[1]]
|
||||||
|
if not comms then
|
||||||
|
embed.description = "Unable to find plugin: "..args[1]
|
||||||
|
embed.color = color("990000").value
|
||||||
|
else
|
||||||
|
embed.title = "Plugin ``"..args[1].."``"
|
||||||
|
embed.description = "``"..table.concat(comms,"``,``").."``"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
local meta = command_handler:get_metadata()
|
||||||
embed.title = "512mb.org commands:"
|
embed.title = "512mb.org commands:"
|
||||||
embed.description = "use ``help <command>`` to view help messages. (type ``help help`` for more info)"
|
embed.description = "use ``help <command>`` to view help messages. (type ``help help`` for more info)"
|
||||||
embed.fields = {}
|
embed.fields = {}
|
||||||
for k,v in pairs(command_handler:get_commands_metadata().plugins) do
|
for name,category in pairs(meta.categories) do
|
||||||
table.insert(embed.fields,{
|
table.insert(embed.fields,{
|
||||||
name = k,
|
name = name,
|
||||||
value = "``"..table.concat(v,"``, ``").."``"
|
value = "``"..table.concat(category,"``,``").."``"
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -94,4 +44,5 @@ local help_command = command("help",{
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
plugin:add_command(help_command)
|
plugin:add_command(help_command)
|
||||||
|
plugin:load_helpdb(plugin_path.."help.lua")
|
||||||
return plugin
|
return plugin
|
||||||
|
|
|
@ -4,6 +4,7 @@ local last_message_arrived = discordia.Stopwatch()
|
||||||
local unixToString = import("unixToString")
|
local unixToString = import("unixToString")
|
||||||
local command = import("classes.command")
|
local command = import("classes.command")
|
||||||
local plugin = import("classes.plugin")("meta")
|
local plugin = import("classes.plugin")("meta")
|
||||||
|
local purify = import("purify")
|
||||||
if not config.aliases then
|
if not config.aliases then
|
||||||
config.aliases = {}
|
config.aliases = {}
|
||||||
end
|
end
|
||||||
|
@ -63,32 +64,6 @@ local function remove_alias(name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function purify_strings(msg,input)
|
|
||||||
local text = input
|
|
||||||
while text:match("<@(%D*)(%d*)>") do
|
|
||||||
local obj,id = text:match("<@(%D*)(%d*)>")
|
|
||||||
local substitution = ""
|
|
||||||
if obj:match("!") then
|
|
||||||
local member = msg.guild:getMember(id)
|
|
||||||
if member then
|
|
||||||
substitution = "@"..member.name
|
|
||||||
end
|
|
||||||
elseif obj:match("&") then
|
|
||||||
local role = msg.guild:getRole(id)
|
|
||||||
if role then
|
|
||||||
substitution = "@"..role.name
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if substitution == "" then
|
|
||||||
substitution = "<\\@"..obj..id..">"
|
|
||||||
end
|
|
||||||
text = text:gsub("<@(%D*)"..id..">",substitution)
|
|
||||||
end
|
|
||||||
text = text:gsub("@everyone","")
|
|
||||||
text = text:gsub("@here","")
|
|
||||||
return text
|
|
||||||
end
|
|
||||||
|
|
||||||
for k,v in pairs(config.aliases) do
|
for k,v in pairs(config.aliases) do
|
||||||
commdata = v
|
commdata = v
|
||||||
if type(v) == "string" then --legacy format conversion
|
if type(v) == "string" then --legacy format conversion
|
||||||
|
@ -100,12 +75,6 @@ end
|
||||||
local prefix = command("prefix",{
|
local prefix = command("prefix",{
|
||||||
help = "Set prefix",
|
help = "Set prefix",
|
||||||
usage = "prefix [(add | remove | list (default)) [<new prefix>]]",
|
usage = "prefix [(add | remove | list (default)) [<new prefix>]]",
|
||||||
users = {
|
|
||||||
[client.owner.id] = 1
|
|
||||||
},
|
|
||||||
roles = {
|
|
||||||
["747042157185073182"] = 1
|
|
||||||
},
|
|
||||||
perms = {
|
perms = {
|
||||||
"administrator"
|
"administrator"
|
||||||
},
|
},
|
||||||
|
@ -291,10 +260,7 @@ local c_speak = command("speak", {
|
||||||
"string"
|
"string"
|
||||||
},
|
},
|
||||||
exec = function(msg,args,opts)
|
exec = function(msg,args,opts)
|
||||||
local text = purify_strings(msg, table.concat(args," "))
|
local text = purify.purify_pings(msg, table.concat(args," "))
|
||||||
if opts["unescape"] or opts["u"] then
|
|
||||||
text = text:gsub("\\","")
|
|
||||||
end
|
|
||||||
msg:reply(text)
|
msg:reply(text)
|
||||||
msg:delete()
|
msg:delete()
|
||||||
end,
|
end,
|
||||||
|
@ -307,9 +273,6 @@ local c_adminSpeak = command("adminSpeak", {
|
||||||
},
|
},
|
||||||
exec = function(msg,args,opts)
|
exec = function(msg,args,opts)
|
||||||
local text = table.concat(args," ")
|
local text = table.concat(args," ")
|
||||||
if opts["unescape"] or opts["u"] then
|
|
||||||
text = text:gsub("\\","")
|
|
||||||
end
|
|
||||||
msg:reply(text)
|
msg:reply(text)
|
||||||
msg:delete()
|
msg:delete()
|
||||||
end,
|
end,
|
||||||
|
@ -324,10 +287,7 @@ local c_echo = command("echo",{
|
||||||
"string"
|
"string"
|
||||||
},
|
},
|
||||||
exec = function(msg,args,opts)
|
exec = function(msg,args,opts)
|
||||||
local text = purify_strings(msg, table.concat(args," "))
|
local text = purify.purify_pings(msg, table.concat(args," "))
|
||||||
if opts["unescape"] or opts["u"] then
|
|
||||||
text = text:gsub("\\","")
|
|
||||||
end
|
|
||||||
msg:reply(text)
|
msg:reply(text)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
@ -338,10 +298,7 @@ local c_pingself = command("pingself",{
|
||||||
"string"
|
"string"
|
||||||
},
|
},
|
||||||
exec = function(msg,args,opts)
|
exec = function(msg,args,opts)
|
||||||
local text = purify_strings(msg, table.concat(args," "))
|
local text = purify.purify_pings(msg, table.concat(args," "))
|
||||||
if opts["unescape"] or opts["u"] then
|
|
||||||
text = text:gsub("\\","")
|
|
||||||
end
|
|
||||||
msg:reply("<@"..tostring(msg.member.id).."> "..text)
|
msg:reply("<@"..tostring(msg.member.id).."> "..text)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
@ -353,11 +310,5 @@ plugin.removal_callback = function()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local helpdb = import(plugin_path:sub(3,-1).."help")
|
plugin:load_helpdb(plugin_path.."help.lua")
|
||||||
plugin:for_all_commands(function(command)
|
|
||||||
if helpdb[command.name] then
|
|
||||||
command:set_help(helpdb[command.name])
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
return plugin
|
return plugin
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
local discordia = require('discordia')
|
||||||
|
return {
|
||||||
|
["enable"] = {embed = {
|
||||||
|
title = "Enable plugin",
|
||||||
|
description = [[This command loads a plugin,
|
||||||
|
addng its commands to the command pool]],
|
||||||
|
fields = {
|
||||||
|
{name = "Usage:",value = "load <plugin-name>"},
|
||||||
|
{name = "Perms:",value = "Administrator, other (via ``rules --allow``)"}
|
||||||
|
},
|
||||||
|
color = discordia.Color.fromHex("ff5100").value
|
||||||
|
}},
|
||||||
|
["disable"] = {embed = {
|
||||||
|
title = "Disable a loaded plugin",
|
||||||
|
description = [[This commands unloads a previously loaded plugin,
|
||||||
|
removing its commands from the command pool]],
|
||||||
|
fields = {
|
||||||
|
{name = "Usage:",value = "unload <plugin-name>"},
|
||||||
|
{name = "Perms:",value = "Administrator, other (via ``rules --allow``)"}
|
||||||
|
},
|
||||||
|
color = discordia.Color.fromHex("ff5100").value
|
||||||
|
}},
|
||||||
|
["plugins"] = {embed = {
|
||||||
|
title = "View all known plugins",
|
||||||
|
description = [[This commmand prints info on loaded and unloaded plugins]],
|
||||||
|
fields = {
|
||||||
|
{name = "Usage:",value = "plugins"},
|
||||||
|
{name = "Perms:",value = "Administrator, other (via ``rules --allow``)"}
|
||||||
|
},
|
||||||
|
color = discordia.Color.fromHex("ff5100").value
|
||||||
|
}},
|
||||||
|
}
|
|
@ -11,19 +11,9 @@ local generic_admin_template = {
|
||||||
}
|
}
|
||||||
|
|
||||||
local enable = command("enable",utilities.overwrite(generic_admin_template,{
|
local enable = command("enable",utilities.overwrite(generic_admin_template,{
|
||||||
help = {embed = {
|
|
||||||
title = "Enable plugin",
|
|
||||||
description = [[This command loads a plugin,
|
|
||||||
adding its commands to the command pool]],
|
|
||||||
fields = {
|
|
||||||
{name = "Usage:",value = "load <plugin-name>"},
|
|
||||||
{name = "Perms:",value = "Administrator, other (via ``rules --allow``)"}
|
|
||||||
},
|
|
||||||
color = discordia.Color.fromHex("ff5100").value
|
|
||||||
}},
|
|
||||||
exec = function(msg,args,opts)
|
exec = function(msg,args,opts)
|
||||||
local status,message = plugin_handler:load(args[1])
|
local status,message = plugin_handler:load(args[1])
|
||||||
local plugin_data = command_handler:get_commands_metadata().plugins
|
local plugin_data = command_handler:get_metadata().plugins
|
||||||
local embed = {
|
local embed = {
|
||||||
description = message,
|
description = message,
|
||||||
color = discordia.Color.fromHex("ff5100").value,
|
color = discordia.Color.fromHex("ff5100").value,
|
||||||
|
@ -40,18 +30,8 @@ adding its commands to the command pool]],
|
||||||
}))
|
}))
|
||||||
plugin:add_command(enable)
|
plugin:add_command(enable)
|
||||||
local disable = command("disable",utilities.overwrite(generic_admin_template,{
|
local disable = command("disable",utilities.overwrite(generic_admin_template,{
|
||||||
help = {embed = {
|
|
||||||
title = "Disable a loaded plugin",
|
|
||||||
description = [[This commands unloads a previously loaded plugin,
|
|
||||||
removing its commands from the command pool]],
|
|
||||||
fields = {
|
|
||||||
{name = "Usage:",value = "unload <plugin-name>"},
|
|
||||||
{name = "Perms:",value = "Administrator, other (via ``rules --allow``)"}
|
|
||||||
},
|
|
||||||
color = discordia.Color.fromHex("ff5100").value
|
|
||||||
}},
|
|
||||||
exec = function(msg,args,opts)
|
exec = function(msg,args,opts)
|
||||||
local plugin_data = command_handler:get_commands_metadata().plugins
|
local plugin_data = command_handler:get_metadata().plugins
|
||||||
if not (args[1] == "plugins") then
|
if not (args[1] == "plugins") then
|
||||||
local status,message = plugin_handler:unload(args[1])
|
local status,message = plugin_handler:unload(args[1])
|
||||||
local embed = {
|
local embed = {
|
||||||
|
@ -73,14 +53,6 @@ removing its commands from the command pool]],
|
||||||
}))
|
}))
|
||||||
plugin:add_command(disable)
|
plugin:add_command(disable)
|
||||||
local plugins = command("plugins",utilities.overwrite(generic_admin_template,{
|
local plugins = command("plugins",utilities.overwrite(generic_admin_template,{
|
||||||
help = {embed = {
|
|
||||||
title = "View all known plugins",
|
|
||||||
description = [[This commmand prints info on loaded and unloaded plugins]],
|
|
||||||
fields = {
|
|
||||||
{name = "Usage:",value = "plugins"},
|
|
||||||
{name = "Perms:",value = "Administrator, other (via ``rules --allow``)"}
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
args = {},
|
args = {},
|
||||||
exec = function(msg,args,opts)
|
exec = function(msg,args,opts)
|
||||||
local all_plugins = plugin_handler:list_loadable()
|
local all_plugins = plugin_handler:list_loadable()
|
||||||
|
@ -106,5 +78,6 @@ local plugins = command("plugins",utilities.overwrite(generic_admin_template,{
|
||||||
end
|
end
|
||||||
}))
|
}))
|
||||||
plugin:add_command(plugins)
|
plugin:add_command(plugins)
|
||||||
|
plugin:load_helpdb(plugin_path.."help.lua")
|
||||||
return plugin
|
return plugin
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
return {
|
||||||
|
["pivot"] = {embed={
|
||||||
|
title = "Select a pivot message to manipulate",
|
||||||
|
description = "Pivot is like a message selector which allows easy reaction manipulations",
|
||||||
|
fields = {
|
||||||
|
{name = "Usage: ",value = "pivot <message link>"},
|
||||||
|
{name = "Perms: ",valeu = "Administartor"}
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
["role-toggle"] = {embed={
|
||||||
|
title = "Add a simple role switch to the pivot",
|
||||||
|
description = "Note: you cannot assign more than one role to a single reaction",
|
||||||
|
fields = {
|
||||||
|
{name = "Usage: ",value = "role-toggle <emoji> <role ping or role id>"},
|
||||||
|
{name = "Perms: ",value = "administrator"}
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
["remove-reaction"] = {embed={
|
||||||
|
title = "Remove a reaction from a pivot",
|
||||||
|
description = "If you don't specify a reaction to remove, the entire pivot for the message is removed automatically",
|
||||||
|
fields = {
|
||||||
|
{name = "Usage: ",value = "remove-reaction <emoji>"},
|
||||||
|
{name = "Perms: ",value = "Administrator"}
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
["toggle"] = {embed={
|
||||||
|
title = "Add a toggle that runs specific commands",
|
||||||
|
description = "Note: you cannot assign more than one action to a single reaction \n``$user`` gets replaced with the id of the user that interacted with the reaction.",
|
||||||
|
fields = {
|
||||||
|
{name = "Usage: ",value = "toggle <emoji> <command-on> <command-off>"},
|
||||||
|
{name = "Perms: ",value = "administrator"}
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
["button"] = {embed={
|
||||||
|
title = "Add a button that runs specific command when pressed",
|
||||||
|
description = "Note: you cannot assign more than one action to a single reaction \n``$user`` gets replaced with the id of the user that interacted with the reaction.",
|
||||||
|
fields = {
|
||||||
|
{name = "Usage: ",value = "button <emoji> <command>"},
|
||||||
|
{name = "Perms: ",value = "administrator"}
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
}
|
|
@ -24,14 +24,6 @@ local function count(tab)
|
||||||
end
|
end
|
||||||
|
|
||||||
local pivot = command("pivot",{
|
local pivot = command("pivot",{
|
||||||
help = {embed={
|
|
||||||
title = "Select a pivot message to manipulate",
|
|
||||||
description = "Pivot is like a message selector which allows easy reaction manipulations",
|
|
||||||
fields = {
|
|
||||||
{name = "Usage: ",value = "pivot <message link>"},
|
|
||||||
{name = "Perms: ",valeu = "Administartor"}
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
args = {
|
args = {
|
||||||
"messageLink"
|
"messageLink"
|
||||||
},
|
},
|
||||||
|
@ -62,14 +54,6 @@ local pivot = command("pivot",{
|
||||||
plugin:add_command(pivot)
|
plugin:add_command(pivot)
|
||||||
|
|
||||||
local role_toggle = command("role-toggle",{
|
local role_toggle = command("role-toggle",{
|
||||||
help = {embed={
|
|
||||||
title = "Add a simple role switch to the pivot",
|
|
||||||
description = "Note: you cannot assign more than one role to a single reaction",
|
|
||||||
fields = {
|
|
||||||
{name = "Usage: ",value = "role-toggle <emoji> <role ping or role id>"},
|
|
||||||
{name = "Perms: ",value = "administrator"}
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
args = {
|
args = {
|
||||||
"string",
|
"string",
|
||||||
"role",
|
"role",
|
||||||
|
@ -113,14 +97,6 @@ local role_toggle = command("role-toggle",{
|
||||||
})
|
})
|
||||||
plugin:add_command(role_toggle)
|
plugin:add_command(role_toggle)
|
||||||
local remove_reaction = command("remove-reaction",{
|
local remove_reaction = command("remove-reaction",{
|
||||||
help = {embed={
|
|
||||||
title = "Remove a reaction from a pivot",
|
|
||||||
description = "If you don't specify a reaction to remove, the entire pivot for the message is removed automatically",
|
|
||||||
fields = {
|
|
||||||
{name = "Usage: ",value = "remove-reaction <emoji>"},
|
|
||||||
{name = "Perms: ",value = "Administrator"}
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
perms = {
|
perms = {
|
||||||
"administrator"
|
"administrator"
|
||||||
},
|
},
|
||||||
|
@ -151,14 +127,6 @@ local remove_reaction = command("remove-reaction",{
|
||||||
})
|
})
|
||||||
plugin:add_command(remove_reaction)
|
plugin:add_command(remove_reaction)
|
||||||
local toggle = command("toggle",{
|
local toggle = command("toggle",{
|
||||||
help = {embed={
|
|
||||||
title = "Add a toggle that runs specific commands",
|
|
||||||
description = "Note: you cannot assign more than one action to a single reaction \n``$user`` gets replaced with the id of the user that interacted with the reaction.",
|
|
||||||
fields = {
|
|
||||||
{name = "Usage: ",value = "toggle <emoji> <command-on> <command-off>"},
|
|
||||||
{name = "Perms: ",value = "administrator"}
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
args = {
|
args = {
|
||||||
"string",
|
"string",
|
||||||
"string",
|
"string",
|
||||||
|
@ -204,14 +172,6 @@ local toggle = command("toggle",{
|
||||||
})
|
})
|
||||||
plugin:add_command(toggle)
|
plugin:add_command(toggle)
|
||||||
local button = command("button",{
|
local button = command("button",{
|
||||||
help = {embed={
|
|
||||||
title = "Add a button that runs specific command when pressed",
|
|
||||||
description = "Note: you cannot assign more than one action to a single reaction \n``$user`` gets replaced with the id of the user that interacted with the reaction.",
|
|
||||||
fields = {
|
|
||||||
{name = "Usage: ",value = "button <emoji> <command>"},
|
|
||||||
{name = "Perms: ",value = "administrator"}
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
args = {
|
args = {
|
||||||
"string",
|
"string",
|
||||||
"string",
|
"string",
|
||||||
|
@ -337,4 +297,5 @@ events:on("reactionRemoveUncached",function(channelId,messageId,hash,userId)
|
||||||
buttonOff(message,hash,userId)
|
buttonOff(message,hash,userId)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
plugin:load_helpdb(plugin_path.."help.lua")
|
||||||
return plugin
|
return plugin
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
return {
|
||||||
|
["droleadd"] = "Add a default role to assign for new users",
|
||||||
|
["droledel"] = "Remove a role from the list of default roles",
|
||||||
|
["drolelist"] = "List all default roles",
|
||||||
|
}
|
|
@ -9,7 +9,6 @@ client:on("memberJoin",function(member)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local droleadd = command("droleadd",{
|
local droleadd = command("droleadd",{
|
||||||
help = "Add a default role to assign for new users",
|
|
||||||
usage = "droleadd <role>",
|
usage = "droleadd <role>",
|
||||||
perms = {"administrator"},
|
perms = {"administrator"},
|
||||||
args = {
|
args = {
|
||||||
|
@ -21,7 +20,6 @@ local droleadd = command("droleadd",{
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
local droledel = command("droledel",{
|
local droledel = command("droledel",{
|
||||||
help = "Remove a role from the list of default roles",
|
|
||||||
usage = "droledel <role>",
|
usage = "droledel <role>",
|
||||||
perms = {"administrator"},
|
perms = {"administrator"},
|
||||||
args = {
|
args = {
|
||||||
|
@ -37,7 +35,6 @@ local droledel = command("droledel",{
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
local drolelist = command("drolelist", {
|
local drolelist = command("drolelist", {
|
||||||
help = "List all default roles",
|
|
||||||
usage = "drolelist",
|
usage = "drolelist",
|
||||||
perms = {"administrator"},
|
perms = {"administrator"},
|
||||||
exec = function(msg,args,opts)
|
exec = function(msg,args,opts)
|
||||||
|
@ -56,5 +53,6 @@ local drolelist = command("drolelist", {
|
||||||
plugin:add_command(droleadd)
|
plugin:add_command(droleadd)
|
||||||
plugin:add_command(droledel)
|
plugin:add_command(droledel)
|
||||||
plugin:add_command(drolelist)
|
plugin:add_command(drolelist)
|
||||||
|
plugin:load_helpdb(plugin_path.."help.lua")
|
||||||
return plugin
|
return plugin
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
return {
|
||||||
|
["grant-role"] = {embed={
|
||||||
|
title = "Grant a role to the user",
|
||||||
|
description = "If <user> is not provided, the caller is assumed as the <user> argument.",
|
||||||
|
fields = {
|
||||||
|
{name = "Usage:",value = "grant-role <role id> [<user>]"},
|
||||||
|
{name = "Perms:",value = "administrator"},
|
||||||
|
{name = "Options:",value = "-q - quiet (don't print the result)"}
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
["revoke-role"] = {embed={
|
||||||
|
title = "Revoke a role from the user",
|
||||||
|
description = "If <user> is not provided, the caller is assumed as the <user> argument.",
|
||||||
|
fields = {
|
||||||
|
{name = "Usage:",value = "revoke-role <role id> [<user>]"},
|
||||||
|
{name = "Perms:",value = "administrator"},
|
||||||
|
{name = "Options:",value = "-q - quiet (don't print the result)"}
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
["warn"] = {embed={
|
||||||
|
title = "Warn a user",
|
||||||
|
description = "nuff said.",
|
||||||
|
fields = {
|
||||||
|
{name = "Usage:",value = "warn <user> <reason>"},
|
||||||
|
{name = "Perms:",value = "kickMembers"},
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
["infractions"] = { embed = {
|
||||||
|
title = "List user infractions",
|
||||||
|
description = "Infractions include kicks, bans, mutes and warnings.",
|
||||||
|
fields = {
|
||||||
|
{name = "Usage: ", value = "infractions <user> [<startfrom>]"},
|
||||||
|
{name = "Perms: ", value = "kickMembers"},
|
||||||
|
{name = "Options: ", value = "--type=(warn default,ban,kick)"}
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
["purge"] = { embed = {
|
||||||
|
title = "Purge a number of messages",
|
||||||
|
description = "nuff said.",
|
||||||
|
fields = {
|
||||||
|
{name = "Usage: ", value = "purge <number>"},
|
||||||
|
{name = "Perms: ", value = "manageMessages"},
|
||||||
|
{name = "Options: ", value = "`--regex (regex)` - match content against regex; \n`--user (user)` - match user against id/name; \n`-w` - match webhook messages"}
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
}
|
|
@ -17,15 +17,6 @@ CREATE TABLE infractions(id INTEGER PRIMARY KEY AUTOINCREMENT, user TEXT, desc T
|
||||||
end
|
end
|
||||||
|
|
||||||
local grantrole = command("grant-role",{
|
local grantrole = command("grant-role",{
|
||||||
help = {embed={
|
|
||||||
title = "Grant a role to the user",
|
|
||||||
description = "If <user> is not provided, the caller is assumed as the <user> argument.",
|
|
||||||
fields = {
|
|
||||||
{name = "Usage:",value = "grant-role <role id> [<user>]"},
|
|
||||||
{name = "Perms:",value = "administrator"},
|
|
||||||
{name = "Options:",value = "-q - quiet (don't print the result)"}
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
perms = {
|
perms = {
|
||||||
"administrator"
|
"administrator"
|
||||||
},
|
},
|
||||||
|
@ -41,15 +32,6 @@ local grantrole = command("grant-role",{
|
||||||
plugin:add_command(grantrole)
|
plugin:add_command(grantrole)
|
||||||
|
|
||||||
local revokerole = command("revoke-role",{
|
local revokerole = command("revoke-role",{
|
||||||
help = {embed={
|
|
||||||
title = "Revoke a role from the user",
|
|
||||||
description = "If <user> is not provided, the caller is assumed as the <user> argument.",
|
|
||||||
fields = {
|
|
||||||
{name = "Usage:",value = "revoke-role <role id> [<user>]"},
|
|
||||||
{name = "Perms:",value = "administrator"},
|
|
||||||
{name = "Options:",value = "-q - quiet (don't print the result)"}
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
perms = {
|
perms = {
|
||||||
"administrator"
|
"administrator"
|
||||||
},
|
},
|
||||||
|
@ -65,14 +47,6 @@ local revokerole = command("revoke-role",{
|
||||||
plugin:add_command(revokerole)
|
plugin:add_command(revokerole)
|
||||||
|
|
||||||
local warn = command("warn",{
|
local warn = command("warn",{
|
||||||
help = {embed={
|
|
||||||
title = "Warn a user",
|
|
||||||
description = "nuff said.",
|
|
||||||
fields = {
|
|
||||||
{name = "Usage:",value = "warn <user> <reason>"},
|
|
||||||
{name = "Perms:",value = "kickMembers"},
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
perms = {
|
perms = {
|
||||||
"kickMembers"
|
"kickMembers"
|
||||||
},
|
},
|
||||||
|
@ -99,15 +73,6 @@ local warn = command("warn",{
|
||||||
plugin:add_command(warn)
|
plugin:add_command(warn)
|
||||||
|
|
||||||
local infractions = command("infractions", {
|
local infractions = command("infractions", {
|
||||||
help = { embed = {
|
|
||||||
title = "List user infractions",
|
|
||||||
description = "Infractions include kicks, bans, mutes and warnings.",
|
|
||||||
fields = {
|
|
||||||
{name = "Usage: ", value = "infractions <user> [<startfrom>]"},
|
|
||||||
{name = "Perms: ", value = "kickMembers"},
|
|
||||||
{name = "Options: ", value = "--type=(warn default,ban,kick)"}
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
perms = {
|
perms = {
|
||||||
"kickMembers"
|
"kickMembers"
|
||||||
},
|
},
|
||||||
|
@ -150,15 +115,6 @@ local infractions = command("infractions", {
|
||||||
plugin:add_command(infractions)
|
plugin:add_command(infractions)
|
||||||
|
|
||||||
local purge = command("purge",{
|
local purge = command("purge",{
|
||||||
help = { embed = {
|
|
||||||
title = "Purge a number of messages",
|
|
||||||
description = "nuff said.",
|
|
||||||
fields = {
|
|
||||||
{name = "Usage: ", value = "purge <number>"},
|
|
||||||
{name = "Perms: ", value = "manageMessages"},
|
|
||||||
{name = "Options: ", value = "`--regex (regex)` - match content against regex; \n`--user (user)` - match user against id/name; \n`-w` - match webhook messages"}
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
perms = {
|
perms = {
|
||||||
"manageMessages"
|
"manageMessages"
|
||||||
},
|
},
|
||||||
|
@ -210,5 +166,5 @@ local purge = command("purge",{
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
plugin:add_command(purge)
|
plugin:add_command(purge)
|
||||||
|
plugin:load_helpdb(plugin_path.."help.lua")
|
||||||
return plugin
|
return plugin
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
return {
|
||||||
|
["dice"] = "Simulates a dice throw, prints the value of each die",
|
||||||
|
["cards"] = "Draw a specific amount of playing cards and display them",
|
||||||
|
["calculate"] = {embed={
|
||||||
|
title = "Calculate an expression",
|
||||||
|
description = "Calculates maths using libqalculate. https://qalculate.github.io/ for more info",
|
||||||
|
fields = {
|
||||||
|
{name = "Usage",value = [[calculate "<expression>"]]},
|
||||||
|
{name = "Perms: ",value = "All"},
|
||||||
|
{name = "Options",value = "`-e` - exact mode"}
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
["pfp"] = "Show the profile picture of a user, or if none is specified, of yourself",
|
||||||
|
["markpov"] = { embed = {
|
||||||
|
title = "Generate some text using markov chains",
|
||||||
|
description = "Generates text using the markov chain rule applied to a predefined set of words",
|
||||||
|
fields = {
|
||||||
|
{name = "Usage: ", value = "markov <text to start with>"},
|
||||||
|
{name = "Options: ", value = [[
|
||||||
|
--preseteset> - Select a text preset. Currently available:
|
||||||
|
``defaul- Generated from a wikipedia page on markov chains
|
||||||
|
``freud`The largest one, generated from a page on Sigmund Freud
|
||||||
|
``reddit Generated from reddit comments
|
||||||
|
``travist`` - Generated from transcript of a video by PlasticPills on travis scott burger
|
||||||
|
]] },
|
||||||
|
{name = "Perms: ", value = "any"}
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
["embed"] = {embed={
|
||||||
|
title = "Convert JSON objects into embeds",
|
||||||
|
description = "If you've worked with discord.js before, this might be simple. If you haven't, then check out https://github.com/yessiest/SuppaBot/wiki/Embeds",
|
||||||
|
fields = {
|
||||||
|
{name = "Usage",value = [[embed {code}]]},
|
||||||
|
{name = "Perms: ",value = "All"},
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
}
|
|
@ -41,7 +41,6 @@ local flip = command("flip",{
|
||||||
})
|
})
|
||||||
plugin:add_command(flip)
|
plugin:add_command(flip)
|
||||||
local dice = command("dice",{
|
local dice = command("dice",{
|
||||||
help = "Simulates a dice throw, prints the value of each die",
|
|
||||||
usage = "dice <2d6,d30,d20+4,etc>",
|
usage = "dice <2d6,d30,d20+4,etc>",
|
||||||
exec = function(msg,args,opts)
|
exec = function(msg,args,opts)
|
||||||
local out = {embed = {
|
local out = {embed = {
|
||||||
|
@ -77,7 +76,6 @@ local dice = command("dice",{
|
||||||
})
|
})
|
||||||
plugin:add_command(dice)
|
plugin:add_command(dice)
|
||||||
local cards = command("cards",{
|
local cards = command("cards",{
|
||||||
help = "Draw a specific amount of playing cards and display them",
|
|
||||||
usage = "cards <amount>",
|
usage = "cards <amount>",
|
||||||
args = {"number"},
|
args = {"number"},
|
||||||
exec = function(msg,args,opts)
|
exec = function(msg,args,opts)
|
||||||
|
@ -98,11 +96,6 @@ local cards = command("cards",{
|
||||||
})
|
})
|
||||||
plugin:add_command(cards)
|
plugin:add_command(cards)
|
||||||
local calculate = command("calculate",{
|
local calculate = command("calculate",{
|
||||||
help = "Calculates maths using libqalculate. https://qalculate.github.io/ for more info",
|
|
||||||
usage = [[
|
|
||||||
calculate "<expression>"
|
|
||||||
``-e`` - exact mode
|
|
||||||
]],
|
|
||||||
args = {
|
args = {
|
||||||
"string"
|
"string"
|
||||||
},
|
},
|
||||||
|
@ -112,8 +105,6 @@ calculate "<expression>"
|
||||||
})
|
})
|
||||||
plugin:add_command(calculate)
|
plugin:add_command(calculate)
|
||||||
local pfp = command("pfp",{
|
local pfp = command("pfp",{
|
||||||
help = "Show the profile picture of a user, or if none is specified, of yourself",
|
|
||||||
usage = "pfp <user or none>",
|
|
||||||
exec = function(msg,args,opts)
|
exec = function(msg,args,opts)
|
||||||
local user = client:getUser((args[1] or ""):match("%d+"))
|
local user = client:getUser((args[1] or ""):match("%d+"))
|
||||||
if user then
|
if user then
|
||||||
|
@ -125,21 +116,6 @@ local pfp = command("pfp",{
|
||||||
})
|
})
|
||||||
plugin:add_command(pfp)
|
plugin:add_command(pfp)
|
||||||
local markov = command("markov",{
|
local markov = command("markov",{
|
||||||
help = { embed = {
|
|
||||||
title = "Generate some text using markov chains",
|
|
||||||
description = "Generates text using the markov chain rule applied to a predefined set of words",
|
|
||||||
fields = {
|
|
||||||
{name = "Usage: ", value = "markov <text to start with>"},
|
|
||||||
{name = "Options: ", value = [[
|
|
||||||
--preset=<preset> - Select a text preset. Currently available:
|
|
||||||
``default`` - Generated from a wikipedia page on markov chains
|
|
||||||
``freud`` - The largest one, generated from a page on Sigmund Freud
|
|
||||||
``reddit`` - Generated from reddit comments
|
|
||||||
``travisscott`` - Generated from transcript of a video by PlasticPills on travis scott burger
|
|
||||||
]] },
|
|
||||||
{name = "Perms: ", value = "any"}
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
exec = function(msg,args,opts)
|
exec = function(msg,args,opts)
|
||||||
local preset,code,err = import("file").readJSON("./resources/"..(opts["preset"] or "default"):match("%w+")..".json",{system_failed = true})
|
local preset,code,err = import("file").readJSON("./resources/"..(opts["preset"] or "default"):match("%w+")..".json",{system_failed = true})
|
||||||
if preset.system_failed then
|
if preset.system_failed then
|
||||||
|
@ -153,8 +129,6 @@ local markov = command("markov",{
|
||||||
})
|
})
|
||||||
plugin:add_command(markov)
|
plugin:add_command(markov)
|
||||||
local embed = command("embed",{
|
local embed = command("embed",{
|
||||||
help = "Convert JSON objects into embeds",
|
|
||||||
usage = "If you've worked with discord.js before, this might be simple. If you haven't, then check out https://github.com/yessiest/SuppaBot/wiki/Embeds",
|
|
||||||
args = {
|
args = {
|
||||||
"string"
|
"string"
|
||||||
},
|
},
|
||||||
|
@ -176,4 +150,5 @@ local embed = command("embed",{
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
plugin:add_command(embed)
|
plugin:add_command(embed)
|
||||||
|
plugin:load_helpdb(plugin_path.."help.lua")
|
||||||
return plugin
|
return plugin
|
||||||
|
|
Loading…
Reference in New Issue