|
|
@ -92,13 +92,56 @@ local warn = command("warn",{ |
|
|
|
end |
|
|
|
}) |
|
|
|
plugin:add_command(warn) |
|
|
|
--[[ |
|
|
|
|
|
|
|
local infractions = command("infractions", { |
|
|
|
help = { embed = { |
|
|
|
title = "List user infractions", |
|
|
|
description = "Infractions include kicks, bans, mutes and warnings." |
|
|
|
description = "Infractions include kicks, bans, mutes and warnings.", |
|
|
|
fields = { |
|
|
|
{name = "Usage: ", value = "infractions <user> [<page>]"}, |
|
|
|
{name = "Perms: ", value = "kick_members"}, |
|
|
|
]] |
|
|
|
{name = "Options: ", value = "--type=(warn default,ban,kick)"} |
|
|
|
} |
|
|
|
}}, |
|
|
|
perms = { |
|
|
|
"kick_members" |
|
|
|
}, |
|
|
|
args = { |
|
|
|
"member", |
|
|
|
}, |
|
|
|
exec = function(msg,args,opts) |
|
|
|
-- Parse args and set defaults |
|
|
|
local dtype = "warn" |
|
|
|
if opts["type"] and type(opts["type"]) ~= "boolean" then |
|
|
|
dtype = opts["type"] |
|
|
|
end |
|
|
|
local page = tonumber(args[2]) or 0 |
|
|
|
-- Get a total count |
|
|
|
local countst = db:prepare("SELECT COUNT(*) FROM infractions WHERE user=? AND action = ?") |
|
|
|
local v = countst:reset():bind(tostring(args[1].id),dtype):step() |
|
|
|
local message = {embed = { |
|
|
|
title = "Infractions list for "..args[1].name, |
|
|
|
fields = {}, |
|
|
|
footer = { |
|
|
|
text = "Total: "..tostring(tonumber(v[1])).." | Page: "..tostring(page) |
|
|
|
|
|
|
|
} |
|
|
|
}} |
|
|
|
-- Prepare a statement to match infractions |
|
|
|
local pagedb = db:prepare("SELECT * FROM infractions WHERE action = ? AND user = ? AND id > ? ORDER BY id LIMIT 5") |
|
|
|
local pagecomm = pagedb:reset():bind(dtype,tostring(args[1].id),5*page) |
|
|
|
-- Keep matching infractions as long as something is returned |
|
|
|
local pagedata = pagecomm:step() |
|
|
|
while pagedata ~= nil do |
|
|
|
table.insert(message.embed.fields,{ |
|
|
|
name = tostring(tonumber(pagedata[1])), |
|
|
|
value = pagedata[3] |
|
|
|
}) |
|
|
|
pagedata = pagecomm:step() |
|
|
|
end |
|
|
|
msg:reply(message) |
|
|
|
end |
|
|
|
}) |
|
|
|
plugin:add_command(infractions) |
|
|
|
|
|
|
|
return plugin |