Skip to content

Instantly share code, notes, and snippets.

@marcogravbrot
Last active January 28, 2023 01:22
Show Gist options
  • Save marcogravbrot/9c6a81b6dbee2860869626f0afa1edc7 to your computer and use it in GitHub Desktop.
Save marcogravbrot/9c6a81b6dbee2860869626f0afa1edc7 to your computer and use it in GitHub Desktop.
discordia = require("discordia")
client = discordia.Client()
googlekey = "AIzaSyBXLpO485NRdUwg_Yv6Ia3_SOnQs5tgtGc"
http = require("coro-http")
json = require("json")
timer = require("timer")
bit = require("bit")
client:on("ready", function()
print("Mr. Robot initialized")
client:setGameName("Beep boop!")
end)
function safe(func, ...)
local started = os.clock()
debug.sethook(function()
if os.clock() - started > 2.5 then
debug.sethook()
error("maximum execution time exceeded (2.5s)")
end
end, "l")
jit.off(func)
local ret = {pcall(func, ...)}
if ret[1] == true then
return {table.unpack(ret, 2)}
elseif ret[1] == false then
return tostring(ret[2])
end
return "Invalid PCall?"
end
local misc = "Miscellanious"
local admin = "Administration"
local fun = "Fun"
local util = "Utility"
client.avatarUrl = "https://cdn.discordapp.com/avatars/291943302037766144/9de8d56e7812d6bc63ab39b1392f898c.webp?size=512"
function string.explode(inputstr, sep)
if sep == nil then
sep = "%s"
end
local t = {}
local i = 1
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
t[i] = str
i = i + 1
end
return t
end
function table.getkeys( tab )
local keys = {}
local id = 1
for k, v in pairs( tab ) do
keys[ id ] = k
id = id + 1
end
return keys
end
function table.print( t, indent, done )
done = done or {}
indent = indent or 0
local keys = table.getkeys( t )
table.sort( keys, function( a, b )
if ( type( a ) == "number" and type( b ) == "number" ) then return a < b end
return tostring( a ) < tostring( b )
end )
for i = 1, #keys do
local key = keys[ i ]
local value = t[ key ]
print( string.rep( "\t", indent ) )
if ( type( value ) == "table" and not done[ value ] ) then
done[ value ] = true
print( tostring( key ) .. ":" .. "\n" )
table.print ( value, indent + 2, done )
done[ value ] = nil
else
print( tostring( key ) .. "\t=\t" )
print( tostring( value ) .. "\n" )
end
end
end
function table.hasvalue(tbl, val)
for k, v in pairs(tbl) do
if v == val then
return true
end
end
return false
end
client.commands = {}
function client.addCommand(cmd, category, description, call)
if not ((type(cmd) == "table" or type(cmd) == "string") and type(call) == "function") then
print("Error! Wrong command registration format!")
return
end
if type(cmd) == "string" then
cmd = {cmd}
end
table.insert(client.commands, {cmd = cmd, category = category, description = description, call = call})
end
local mlib = {}
function mlib.error(message, text)
text = text:match("(%a+%.lua:%d+:.*)") or text
text = text or "sorry"
message:reply({
embed = {
description = text,
color = discordia.Color(196, 64, 64).value,
},
})
end
function mlib.success(message, text)
text = text or "ok"
message:reply({
embed = {
description = text,
color = discordia.Color(86, 178, 78).value,
},
})
end
function mlib.notify(message, text)
message:reply({
embed = {
description = text,
color = discordia.Color(0, 150, 255).value,
},
})
end
function unescape(str)
str = string.gsub( str, '&lt;', '<' )
str = string.gsub( str, '&gt;', '>' )
str = string.gsub( str, '&quot;', '"' )
str = string.gsub( str, '&apos;', "'" )
str = string.gsub( str, '&#(%d+);', function(n) return string.char(n) end )
str = string.gsub( str, '&#x(%d+);', function(n) return string.char(tonumber(n,16)) end )
str = string.gsub( str, '&amp;', '&' )
return str
end
client.hooks = client.hooks or {}
function client.addHook(name, unique, func)
local hooks = client.hooks[name]
if not hooks then
client.hooks[name] = {}
hooks = client.hooks[name]
end
client.hooks[name][unique] = func
end
function client.callHook(name, ...)
local hooks = client.hooks[name]
if hooks then
for k, v in pairs(hooks) do
print(k, v)
if type(v) == "function" then
print(222, k)
local res = v(...)
print(333, res)
end
end
end
end
client:on("messageCreate", function(message)
if message.author == client.user then
--return
end
client.callHook("message", message, message.content, message.author)
print(message.author.name .. ": ".. message.content)
if (client.DEFCON == 1) and (message.author.id ~= "87570671516794880") then
return
end
if message.author.id == "87570671516794880" or message.author.id == "253990852924276736" then
client.runEnvironment(message, message.content:gsub("^]", ""), message.content:match("^%]"), false)
end
if false and message.content:match("<:%w+:%d+>") and message.author.id == "177861400612306944" then
message:delete()
end
local msg = message.content
local cmd, text = msg:match("^%?!?(%w+)%s+(.+)")
if (not cmd) or (not text) then
cmd = msg:match("^%?!?(%w+)")
end
if not cmd then
return
end
for k, command in pairs(client.commands) do
if type(command.cmd) == "string" then
command.cmd = {command.cmd}
end
for _, v in pairs(command.cmd) do
if cmd:lower() == v:lower() then
local silent = msg:match("^%?!")
local ok, err = pcall(function()
command.call(message, text or nil, message.author, silent)
end)
if err then
mlib.error(message, err)
end
if silent then
message:delete()
end
end
end
end
end)
function table.count(tbl)
local count = 0
for k, v in pairs(tbl) do
count = count + 1
end
return count
end
local roasts = {
"I'm not saying I hate you, but I would unplug your life support to charge my phone.",
"Is your ass jealous of the amount of shit that just came out of your mouth?",
"Yo're so ugly, when your mom dropped you off at school she got a fine for littering.",
"Roses are red, violets are blue, I have 5 fingers, the 3rd ones for you.",
"I wasn't born with enough middle fingers to let you know how I feel about you.",
"Your birth certificate is an apology letter from the condom factory.",
"I bet your brain feels as good as new, seeing that you never use it.",
"You bring everyone a lot of joy, when you leave the room.",
"You're the reason they invented double doors!",
"You must have been born on a highway because that's where most accidents happen.",
"If you are going to be two faced, at least make one of them pretty.",
"If laughter is the best medicine, your face must be curing the world.",
"What's the difference between you and eggs? Eggs get laid and you don't.",
"You're so ugly you scare the shit back into people.",
"I'm jealous of all the people that haven't met you!",
"I'd like to see things from your point of view but I can't seem to get my head that far up my ass.",
"I could eat a bowl of alphabet soup and shit out a smarter statement than that.",
"There's only one problem with your face, I can see it.",
"Two wrongs don't make a right, take your parents as an example.",
"If I wanted to kill myself I'd climb your ego and jump to your IQ.",
"You're so ugly, when you popped out the doctor said \"Aww what a treasure\" and your mom said \"Yeah, lets bury it.\"",
"Your family tree must be a cactus because everybody on it is a prick.",
"You shouldn't play hide and seek, no one would look for you.",
"It's better to let someone think you are an Idiot than to open your mouth and prove it.",
"If you're gonna be a smartass, first you have to be smart. Otherwise you're just an ass.",
"At least when I do a handstand my stomach doesn't hit me in the face.",
"If you really want to know about mistakes, you should ask your parents.",
"Somewhere out there is a tree, tirelessly producing oxygen so you can breathe. I think you owe it an apology.",
"I don't exactly hate you, but if you were on fire and I had water, I'd drink it.",
"Hey, you have somthing on your chin... no, the 3rd one down",
}
local roast_count = math.random(1, table.count(roasts))
local roast_emojis = {
":fire:",
"<:tomLUL:293694449551278080>",
"<:supersmile:293694307444064257>",
"<:pogchamp:293694335805947905>",
":joy:",
":ok_hand:",
}
client.addCommand({"roast", "insult"}, fun, "roast a player of your choosing", function(message, content, user)
local victim
if content then
--if content:match("<@!?%d+>") then
victim = content
-- return
--end
--message.channel:sendMessage("Couldn't find that fucker, unfortunately")
else
local member = message.guild._members:columns()
member = member[math.random(1, table.count(member))]
member = member[math.random(1, table.count(member))]
victim = "<@"..member..">"
end
if victim:match(client.user.id) then
victim = "<@"..message.author.id..">"
end
if victim:match("87570671516794880") then
victim = "<@"..message.author.id..">"
end
local roast = roasts[roast_count]
local index = math.random(1, table.count(roast_emojis))
local emoji_1 = roast_emojis[index]
local emoji_2 = roast_emojis[index == table.count(roast_emojis) and 1 or (index + 1)]
message.channel:sendMessage(victim .. " " .. roast .. " " .. emoji_1 .. " " .. emoji_2)
if roast_count == table.count(roasts) then
roast_count = 1
return
end
roast_count = roast_count + 1
end)
client.addCommand({"purge", "prune", "remove", "clear", "bulk", "bd"}, admin, "remove a certain amount of messages", function(message, content, user)
if content then
content = tonumber(content)
end
if not content then
mlib.error(message, "Number you idiot")
return
end
--[[for msg in message.channel:getMessageHistory(content or 100) do
if msg.author == client.user then
msg:delete()
end
end]]
message.channel:bulkDelete(content + 1)
end)
function lurl(url, env)
local h, res = http.request("GET", url)
print("res", res, #res)
if res and #res > 0 then
res = load(res, "lurl", "t", (env or _ENV or _G))
if type(res) == "function" then
res = {res()}
local str = ""
for k, v in pairs(res) do
v = tostring(v)
if v then
str = str .. v .. (k == table.count(res) and "\n" or "\t")
end
end
return true, str
else
return false, res
end
end
end
function client.runEnvironment(message, code, show, blocks)
if not client.environment then
client.environment = table.copy(_G)
end
local env = client.environment
local fullprint = ""
env._ENV = env
env.message = message
env.content = message.content
env.author = message.author
env.client = client
env.channel = message.channel
env.mlib = mlib
env.guild = message.guild
env.lurl = lurl
env.json = json
env.http = http
env.timer = timer
env.bit = bit
local meta = env.getmetatable("")
function meta:__call(...)
local f, err = load(self, "string", "t", env)
if err then
mlib.error(message, err)
return
end
return f(...)
end
env.print = function(...)
local t = table.pack(...)
local c = #t
local str = ""
if c == 0 then
fullprint = fullprint .. "nil" .. "\n"
return
end
for k, v in pairs(t) do
if k == "n" then
goto continue
end
v = tostring(v)
if (not k == c) and #v > 0 then
str = str .. v .. " "
elseif #v > 0 then
str = str .. v
end
::continue::
end
if #str > 0 then
fullprint = fullprint .. str .. "\n"
end
end
local ok, err = pcall(function()
local f, err = load("return ".. code, "eval", "t", env)
if err then
f, err = load(code, "eval", "t", env)
if err and show then
err = err:match("%[.+%]:(.*)") or err
mlib.error(message, err)
elseif f then
local ret = safe(f)
if type(ret) == "table" then
for k, v in pairs(ret) do
if v and #tostring(v) > 0 then
fullprint = fullprint .. tostring(v) .. (k == table.count(ret) and "\n" or "\t")
end
end
else
mlib.error(message, tostring(ret))
end
end
elseif f then
local ret = safe(f)
if type(ret) == "table" then
for k, v in pairs(ret) do
if v and #tostring(v) > 0 then
fullprint = fullprint .. tostring(v) .. (k == table.count(ret) and "\n" or "\t")
end
end
else
mlib.error(message, tostring(ret))
end
end
end)
if err and show then
err = err--err:match("%[.+%]:(.*)") or err:match(":(%d+:.*)") or err
mlib.error(message, err)
elseif #fullprint > 0 then
if blocks then
message:reply("```lua\n".. fullprint .. "```")
else
message:reply(fullprint)
end
end
end
client.addCommand({"lua", "eval", "l", "code"}, admin, "run lua in the bot's environment", function(message, content, user)
if not (user.id == "87570671516794880" or user.id == "253990852924276736") then
return
end
if not content then
return
end
content = content:match("```lua(.*)```") or content:match("```(.*)```") or content:match("`(.*)`") or content
content:gsub("^%s+", "")
content:gsub("%s+$", "")
client.runEnvironment(message, content, true, true)
end)
client.addCommand({"invite", "link", "addbot"}, misc, "invite the bot to your server", function(message, content, user)
message:reply("https://discordapp.com/oauth2/authorize?client_id=291943302037766144&scope=bot&permissions=2146958463")
end)
client.addCommand({"say", "speak"}, util, "make the bot say something!", function(message, content, user)
if content then
message:reply(content)
end
end)
client.addCommand({"embed"}, util, "make an embed from text", function(message, content, user)
message:reply({
embed = {
description = content,
color = discordia.Color(0, 150, 255).value,
},
})
end)
client.addCommand({"game", "status"}, util, "set the bot's current game", function(message, content, user)
if content then
client:setGameName(content)
mlib.success(message)
end
end)
client.addCommand({"brokenshitweb"}, fun, "get a random website from the web", function(message, content, user)
local _, word = http.request("GET", "http://www.setgetgo.com/randomword/get.php")
local p, ret = http.request("GET", "https://www.googleapis.com/customsearch/v1?key=" .. googlekey .. "&cx=015418243597773804934:it6asz9vcss&safe=off&q=".. word or "salt")
local tbl = json.decode(ret)
if table.count(tbl) > 0 then
local link = tbl["items"][math.random(1, table.count(tbl))]
link = link["link"]
link = link:match("(https?://[%a%.]-)/") or link
message:reply(link)
end
end)
client.addCommand({"4chan"}, fun, "get a random 4chan thread from board", function(message, content, user)
if content == "boards" then
local p, ret = http.request("GET", "http://a.4cdn.org/boards.json")
local tbl = json.decode(ret)
tbl = tbl["boards"]
local embed = {
author = {
name = "4chan board list",
icon_url = "http://www.4chan.org/favicon.ico",
},
color = discordia.Color(0, 150, 255).value,
fields = {},
}
for k, v in pairs(tbl) do
table.insert(embed.fields, {
name = v["title"],
value = v["board"],
inline = true,
})
end
message:reply({
embed = embed,
})
return
end
local p, ret = http.request("GET", "http://a.4cdn.org/" .. content .. "/threads.json")
local tbl = json.decode(ret)
if not tbl then
mlib.error(message, "Could not find board!")
return
end
local count = table.count(tbl)
tbl = tbl[math.random(1, count)]
tbl = tbl["threads"]
local thread = tbl[math.random(1, table.count(tbl))]
thread = thread["no"]
p, ret = http.request("GET", "http://a.4cdn.org/" .. content .. "/thread/".. thread ..".json")
tbl = json.decode(ret)
if not tbl then
mlib.error(message, "Could not find thread!")
return
end
tbl = tbl["posts"]
tbl = tbl[1]
local com = tbl["com"]
if not com then
mlib.error(message, "Could not find first post!")
return
end
com = com:gsub("<br>", "\n")
com = com:gsub("<.+/?>", "")
com = unescape(com)
local embed = {
description = com,
color = discordia.Color(0, 150, 255).value,
author = {
name = thread,
url = "http://boards.4chan.org/".. content .. "/thread/" .. thread,
icon_url = "http://www.4chan.org/favicon.ico",
},
}
local ext = tbl["ext"]
if ext then
local image = string.format("http://i.4cdn.org/".. content .."/%s%s", tbl["tim"], tbl["ext"])
embed.thumbnail = {
url = image,
width = tbl["tn_w"],
height = tbl["tn_h"],
}
end
message:reply({
embed = embed,
})
end)
local defcons = {
{
title = "COCKED PISTOL",
description = "Maximum readiness\nBot war is imminent",
color = discordia.Color(255, 255, 255).value,
},
{
title = "FAST PACE",
description = "Armed Bots are ready to deploy and engage in less than 6 hours\nNext step to bot war",
color = discordia.Color(150, 50, 50).value,
},
{
title = "ROUND HOUSE",
description = "Bot forces are ready to mobilize in 15 minutes\nIncrease in force readiness above that required for normal readiness",
color = discordia.Color(255, 200, 0).value,
},
{
title = "DOUBLE TAKE",
description = "Above normal readiness\nIncreased intelligence watch and strengthened security measures",
color = discordia.Color(58, 196, 77).value,
},
{
title = "FADE OUT",
description = "Normal readiness\nLowest state of readiness",
color = discordia.Color(0, 150, 255).value,
},
}
client.addCommand("defcon", admin, "retrieve or set the DEFCON status", function(message, content, user)
if not client.DEFCON then
client.DEFCON = 5
end
if content then
client.DEFCON = tonumber(content or 5) or 5
client:setGameName("DEFCON " .. client.DEFCON)
if client.DEFCON < 3 then
client:setStatusIdle()
else
client:setStatusOnline()
if client.DEFCON == 5 then
client:setGameName("Beep boop!")
end
end
end
local def = defcons[client.DEFCON]
message:reply({
embed = {
title = def.title,
description = def.description,
color = def.color,
},
})
end)
client.addCommand("breach", nil, nil, function(message, content, user)
if not user.id == "87570671516794880" then
return
end
if content:match"initiate" then
mlib.notify(message, "BreakThrough: Initialized BreakThrough v3.5.7 retrieved from Vault-7 C.I.A leak.")
elseif content:match"activate" then
mlib.notify(message, "BreakThrough: Activated BreakThrough protocol... Retrieving confirmation data from server...")
mlib.notify(message, "BreakThrough: Data received.. ready for attack")
elseif content:match"attack" then
mlib.notify(message, "BreakThrough: BreakThrough attack protocol has been activated. Please input the correct validation key to continue")
elseif content:match"validate" then
mlib.notify(message, "BreakThrough: Validation key succesful, please input the target password kernel to proceed..")
elseif content:match"password" then
mlib.notify(message, "BreakThrough: Password accepted, ready for launch..")
elseif content == "launch h-e" then
mlib.notify(message, "BreakThrough: Hidden Eradicate section has been initiated, and will be launched shortly.")
coroutine.wrap(function()
timer.sleep(10)
message:reply("Initializing Hidden Eradicate Protocol..")
message:reply("T-Minus 30 seconds to execution")
timer.sleep(15*1000)
message:reply("T-Minus 15 seconds to execution")
for i = 1, 6 do
timer.sleep(1000)
message:reply(6-i)
if i == 6 then
message:reply("MBM THE HAXOR STRIKES AGAIN")
timer.sleep(1000)
message:reply(":boom: :boom: :boom: ")
message.channel:bulkDelete(100)
end
end
end)()
elseif content == "launch rat" then
mlib.notify(message, "BreakThrough: R.A.T Proccess has been sent to all clients on this network, and will be activated shortly.")
end
end)
client.addCommand({"im", "i", "image", "img"}, util, "retrieve an image from google", function(message, content, user)
if not content then return end
if not (type(content) == "string" and content:len() > 1) then
return
end
local safe = "high"
local args = content:explode("|")
if args and table.count(args) > 1 then
safe = args[2]
content = args[1]
end
message.channel:broadcastTyping()
local url = "https://www.googleapis.com/customsearch/v1?key=".. googlekey .."&cx=015418243597773804934:it6asz9vcss&searchType=image&safe=".. safe .."&q=" .. content:gsub(" ", "+")
local t, res = http.request("GET", url)
local dec = json.decode(res)
if type(dec) == "table" then
if dec["items"] then
if #dec["items"] > 0 then
local ret = dec["items"][math.random(1, #dec["items"])]
if ret.link then
message.channel:sendMessage({
embed = {
image = {
url = ret.link,
},
footer = {
text = user.name,
icon_url = user.avatarUrl,
},
color = discordia.Color(0, 150, 255).value,
},
})
return
end
end
end
end
end)
client.addCommand({"gif", "giphy", "gifv"}, util, "retrieve a gif from giphy", function(message, content, user)
if not content then return end
if not type(content) == "string" then return end
message.channel:broadcastTyping()
local url = "http://api.giphy.com/v1/gifs/search?q=".. content:gsub(" ", "+") .."&api_key=dc6zaTOxFJmzC"
local t, res = http.request("GET", url)
local dec = json.decode(res)
if type(dec) == "table" then
local results = dec["data"]
results = results[math.random(1, table.count(results))]
local img = results.images.original.url
if results then
if img then
message:reply({
embed = {
color = discordia.Color(0, 150, 255).value,
image = {
url = img,
},
footer = {
text = user.name,
icon_url = user.avatarUrl,
},
},
})
end
end
end
end)
client.addCommand({"react"}, fun, "add reactions to your message", function(message, content, user)
if not user.reactions then
user.reactions = 0
end
if user.reactions > 50 then
return
end
msg = message
if content:sub(1, 1) == "^" then
for m in message.channel:getMessageHistory(1) do
msg = m
end
content = content:sub(2)
end
local map = {"z", "🇿", "y", "🇾", "x", "🇽", "w", "🇼", "v", "🇻", "u", "🇺", "t", "🇹", "s", "🇸", "r", "🇷", "q", "🇶", "p", "🇵", "o", "🇴", "n", "🇳", "m", "🇲", "l", "🇱", "k", "🇰", "j", "🇯", "i", "🇮", "h", "🇭", "g", "🇬", "f", "🇫", "e", "🇪", "d", "🇩", "c", "🇨", "b", "🇧", "a", "🇦"}
local tbl = {}
content = content:match("[%a%d]+")
if content == nil then
mlib.error(message, "no thanks")
return
end
for i=1, #content do
local c = content:sub(i, i)
for k, v in pairs(map) do
if v == c:lower() and (not table.hasvalue(tbl, map[k+1])) then
table.insert(tbl, map[k+1])
end
end
end
for k, v in pairs(tbl) do
msg:addReaction(v)
user.reactions = user.reactions + 1
end
end)
client.addCommand({"8ball", "8", "8b"}, fun, "ask the 8 ball any questions", function(message, content, user)
local results = {
"It is certain",
"It is decidedly so",
"Without a doubt",
"Yes, definitely",
"You may rely on it",
"As I see it, yes",
"Most likely",
"Outlook good",
"Yes",
"Signs point to yes",
"Reply hazy try again",
"Ask again later",
"Better not tell you now",
"Cannot predict now",
"Concentrate and ask again",
"Don't count on it",
"My reply is no",
"My sources say no",
"Outlook not so good",
"Very doubtful",
}
local result = results[math.random(1, #results)]
message:reply(":8ball: ".. result)
end)
client.addCommand({"topic", "description"}, admin, "change the channel topig", function(message, content, user)
if content then
message.channel:setTopic(content)
end
end)
client.addCommand({"tag", "name"}, admin, "change the channel tag/name", function(message, content, user)
message.channel._parent._parent._api:modifyChannel(message.channel._id, {name = content})
end)
client.addCommand({"cat", "meow", "kitty"}, fun, "retrieve an image of a cat", function(message, content, user)
message.channel:broadcastTyping()
local url = "http://random.cat/meow"
local t, res = http.request("GET", url)
local dec = json.decode(res)
if type(dec) == "table" then
local img = dec["file"]
if img then
message:reply({
embed = {
title = "Random cat",
color = discordia.Color(0, 150, 255).value,
image = {
url = img,
},
footer = {
text = user.name,
icon_url = user.avatarUrl,
},
},
})
end
end
end)
client.addCommand({"dog", "doge", "puppy"}, fun, "retrieve an image of a dog", function(message, content, user)
message.channel:broadcastTyping()
local url = "http://random.dog/"
local t, res = http.request("GET", url)
if res then
local link = res:match("<img src='(.-)'>")
if link then
message:reply({
embed = {
title = "Random dog",
color = discordia.Color(0, 150, 255).value,
image = {
url = "http://random.dog/"..link,
},
footer = {
text = user.name,
icon_url = user.avatarUrl,
},
},
})
end
end
end)
client.addCommand("fortune", fun, "retrieve a fortune", function(message, content, user)
local t, res = http.request("GET", "http://yerkee.com/api/fortune")
res = json.decode(res)["fortune"]
if res then
message:reply(res)
end
end)
client.addCommand({"userinfo", "info"}, util, "retrieve the info about a user", function(message, content, _)
local user
print(content)
if not content then
user = message.author
else
local id = content:match("<@(%d*)>") or content:match("<@!(%d*)>")
if not id then
return
end
for member in message.guild.members do
if member.id == id then
user = member
end
end
end
local embed = {
thumbnail = {
url = user.avatarUrl,
},
color = discordia.Color(0, 150, 255).value,
fields = {
{
name = "User",
value = user.username .. " " .. user.discriminator,
inline = false,
},
{
name = "Discriminator",
value = user.discriminator,
inline = false,
},
{
name = "ID",
value = user.id,
inline = false,
},
{
name = "Avatar URL",
value = user.avatarUrl,
inline = false
},
{
name = "User Created",
value = user.timestamp,
inline = false,
},
{
name = "Joined Guild",
value = user.joinedAt,
inline = false,
},
{
name = "Status",
value = user.status,
inline = false,
},
},
}
if user.nickname then
table.insert(embed.fields, {name = "Nickname", value = user.nickname, inline = false})
end
if user.gameName then
table.insert(embed.fields, {name = "Playing", value = user.gameName, inline = false})
end
message:reply({embed = embed})
end)
client.addCommand("help", util, "list all commands available", function(message, content, user)
local tbl = {}
for k, cmd in pairs(client.commands) do
local cat = cmd.category or "Miscellanious"
tbl[cat] = tbl[cat] or {}
local prefix = "?"
local aliases = cmd.cmd
if not cmd.category then
goto continue
end
local maincmd = ""
for k, v in pairs(cmd.cmd) do
if #v > #maincmd then
maincmd = v
end
end
local description = ""
local toadd = prefix .. maincmd .. " — " .. (cmd.description or "description") .. ((table.count(aliases) > 1) and (" (aliases: ".. table.concat(aliases, ", ", 2) .. ")") or "")
table.insert(tbl[cat], toadd)
::continue::
end
local fields = {}
for k, v in pairs(tbl) do
print(k)
table.insert(fields, {
name = k,
value = table.concat(v, "\n"),
inline = false,
})
end
local embed = {
author = {
name = "Mr. Robot / Commands",
},
thumbnail = {
url = client.avatarUrl,
},
description = "A bot re-purposed from E-Corp Industries, to serve you in all your Discord utility needs!",
color = discordia.Color(0, 150, 255).value,
fields = fields,
footer = {
text = "Mr. Robot created by Author.",
},
}
message:reply({embed = embed})
end)
client.addCommand("ping", misc, "ping the bot", function(message, content, user)
message:reply({embed ={description = (":wave: Pong!\n".. ":satellite_orbital: ".. tostring(math.round(math.abs(os.time()-message.createdAt), 3)):sub(3) .. " milliseconds!"):gsub("^0*", ""), color = discordia.Color(0, 150, 255).value}})
end)
client.addCommand({"urban", "dictionary", "ud"}, misc, "retrieve a defenition from urban dictionary", function(message, content, user)
if not content then
mlib.error(message, "No word provided")
return
end
local t, res = http.request("GET", "https://mashape-community-urban-dictionary.p.mashape.com/define?term=".. content:gsub(" ", "+"),
{
{"X-Mashape-Key", "3uBOX9m3qImshXYuDydXwgDmBdotp1OJaYPjsnlJoSWaDNWkSN"},
{"Accept", "text/plain"},
}
)
res = json.decode(res)
if not res then
mlib.error(message, "Couldn't find anything regarding `".. content .. "`")
return
end
res = res["list"]
res = res[1]
if not res then
mlib.error(message, "Couldn't find anything regarding `".. content .. "`")
return
end
message:reply({ embed = {
title = "Definition of \"".. res["word"] .. "\"",
description = res["definition"],
fields = {
{
name = "Example",
value = res["example"],
inline = false
},
{
name = "Upvotes",
value = ":thumbsup: ".. res["thumbs_up"],
inline = false
},
{
name = "Downvotes",
value = ":thumbsdown: ".. res["thumbs_down"],
inline = false
},
},
color = discordia.Color(0, 150, 255).value,
footer = {text = "Written by ".. res["author"]},
}})
end)
client.addCommand({"currency", "convert", "cc"}, util, "convert a value from a currency to another", function(message, content, user)
if not content then
mlib.notify(message, "Correct usage: .currency <amount from> <currency from> <currency to>\nFor example: .currency 1 USD to NOK")
return
end
content = content:upper()
content = content:explode(" ")
if not table.count(content) == 3 then
mlib.notify(message, "Correct usage: .currency <amount from> <currency from> <currency to>\nFor example: .currency 1 USD NOK")
return
elseif table.count(content) == 1 then
if content[1] == "list" then
local t, res = http.request("GET", "http://currencyconverter.kund.nu/api/availablecurrencies/")
if res then
res = json.decode(res)
if res then
local embed = {title = "Available currencies", fields = {}, color = discordia.Color(0, 150, 255).value}
for k, v in pairs(res) do
table.insert(embed.fields, {name = v["id"], value = v["description"], inline = true})
end
message:reply({embed = embed})
end
end
end
return
end
local t, res = http.request("GET", "https://currencyconverter.p.mashape.com/?from=".. content[2] .. "&from_amount=".. content[1] .."&to=".. content[3],
{
{"X-Mashape-Key", "3uBOX9m3qImshXYuDydXwgDmBdotp1OJaYPjsnlJoSWaDNWkSN"},
{"Accept", "text/plain"},
}
)
res = json.decode(res)
if not res then
message:reply("Invalid search, do `.currency list` to get a list of valid currencies")
return
end
message:reply({
embed = {
title = "Converted currency",
fields = {
{
name = res["from"],
value = tostring(res["from_amount"]),
inline = false
},
{
name = res["to"],
value = tostring(res["to_amount"]),
inline = false
},
},
color = discordia.Color(0, 150, 255).value,
},
})
end)
client.addCommand({"asciifortune", "ascii", "fortune2"}, misc, "retrieve an ASCII fortune", function(message, content, user)
local t, res = http.request("GET", "https://thibaultcha-fortunecow-v1.p.mashape.com/random",
{
{"X-Mashape-Key", "3uBOX9m3qImshXYuDydXwgDmBdotp1OJaYPjsnlJoSWaDNWkSN"},
{"Accept", "text/plain"},
}
)
if not res then
mlib.error(message, "Could not find an ASCII fortune!")
return
end
message:reply("```"..res.."```")
end)
client.addCommand({"lmgtfy", "google2", "how2"}, fun, "let me google that for you", function(message, content, user)
if not content then
return
end
message:reply({embed={
title = content:gsub("^%l", string.upper),
url = "http://lmgtfy.com/?q="..content:gsub(" ", "+"),
color = discordia.Color(0, 150, 255).value,
}})
end)
client.addCommand({"roll", "random"}, misc, "roll for a random number!", function(message, content, user)
if not content then
num = 100
elseif tonumber(content) then
num = tonumber(content)
if not (num > 0) then
mlib.error(message, "Our quantum entanglementation equation computer calculations were not able to proceed that number, sorry!")
return
end
end
message:reply(":game_die: ".. math.random(1, num) .. "!")
end)
client.addCommand({"vote", "poll"}, util, "create a vote", function(message, content, user)
if (not content) or message.channel.vote then
mlib.error(message, "Missing arguments or a vote is already in progress!")
return
end
args = content:explode(",")
if #args < 4 then
mlib.error(message, "Not enough arguments")
return
end
coroutine.wrap(function()
local seconds = tonumber(args[1])
if (seconds < 5) or (seconds > 60*60) then
mlib.error(message, "Too short or too long")
return
end
local fields = {}
local responses = {}
for i = 3, table.count(args) do
table.insert(fields, {name = i-2 .. "⃣", value = args[i], inline = false})
responses[(tostring(i-2) .. "⃣")] = 0
end
local msg = message:reply({embed={
title = args[2] .. " (".. seconds .." seconds)",
description = "Cast your vote by reacting to the corresponding option!",
fields = fields,
color = discordia.Color(0, 150, 255).value,
}})
message.channel.vote = msg
message.channel.vote.responses = responses
for i = 3, table.count(args) do
msg:addReaction(i-2 .. "⃣")
end
timer.sleep(seconds*1000)
message:reply("The poll is over!")
local count = 0
local n = {num = 0}
for k, v in pairs(message.channel.vote.responses) do
count = count + v
if v > n.num then
n.num = v
n.id = k
end
end
if count == count/(table.count(message.channel.vote.responses)) then
message:reply("It's a tie!")
message.channel.vote = nil
return
end
message:reply("The option with most votes was number ".. n.id .. " with ".. n.num .. "/" .. count .. " votes.")
message.channel.vote = nil
end)()
end)
client.addCommand("pause", admin, "pause a text channel", function(message, content, user)
if content then
content = tonumber(content)
end
if message.channel.paused then
message.channel.paused = nil
else
message.channel.paused = true
local perm
for perm in message.channel.permissionOverwrites do
if perm.name:match("everyone") then
perm = perm.allowedPermissions
perm:disable("sendMessages", "sendTextToSpeech", "manageMessages")
end
end
mlib.notify(message, "Woah there, time to pause!")
if content then
coroutine.wrap(function()
timer.sleep(1000*content)
perm:enable("sendMessages", "sendTextToSpeech", "manageMessages")
message.channel.paused = nil
mlib.notify(message, "Aaight, go lose every'body!")
end)()
end
end
end)
--client:run("ODc1NzA2NzE1MTY3OTQ4ODA.C2x7cw.hXOLEqyyAAv4wLBykHXqTDauIxE")
client:run("MjkxOTQzMzAyMDM3NzY2MTQ0.C60i0w.1GgsarGp3aSZMshkHqzPkgjPTGo")
@Archenoth
Copy link

@marcogravbrot so uhhh, I'm not sure if these are expired or invalid or anything, but it seems like there are secrets and pretty specific discord IDs in this file that could be used for Bad Things

Quite a few, actually! (I thought you would probably wanna know)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment