Updated guide on self-hosting the bot
This commit is contained in:
parent
e87056a2c2
commit
b4d0f9ea54
|
@ -1,11 +1,13 @@
|
||||||
[![forthebadge](https://forthebadge.com/images/badges/powered-by-black-magic.svg)](https://forthebadge.com) [![made-with-luvit.svg](https://512mb.org/git/Yessiest/badges/raw/branch/master/badges/made-with-luvit.svg)](https://forthebadge.com/generator/)
|
[![forthebadge](https://forthebadge.com/images/badges/powered-by-black-magic.svg)](https://forthebadge.com) [![made-with-luvit.svg](https://512mb.org/git/Yessiest/badges/raw/branch/master/badges/made-with-luvit.svg)](https://forthebadge.com/generator/)
|
||||||
|
|
||||||
# 512mb.org-bot
|
# 512mb.org-bot
|
||||||
yet another 512mb bot. it's running on a discord library for the luvit framework called [Discordia](https://github.com/SinisterRectus/discordia)
|
Yet another 512mb bot. It's running on a discord library for the luvit framework called [Discordia](https://github.com/SinisterRectus/discordia). For guides on using particular features of the bot check out the [wiki](https://github.com/512mb-org/512mb.org-bot/wiki).
|
||||||
|
|
||||||
# Self-hosting
|
# Self-hosting
|
||||||
place the bot token in the "./token" file, change server id in bot.lua to the id of your server.
|
1. Get a bot token and place it in ./token
|
||||||
compile [luvit](https://luvit.io) and run bot.lua.
|
2. Install libqalculate and compile luaqalc
|
||||||
|
3. Place the ``libqalculator.so`` in ./libraries/
|
||||||
|
4. Get [luvit](https://luvit.io) and run ``bot.lua`` using the ``luvit`` binary
|
||||||
|
|
||||||
# License
|
# License
|
||||||
```
|
```
|
||||||
|
|
2
bot.lua
2
bot.lua
|
@ -46,4 +46,4 @@ if not tempfile then
|
||||||
end
|
end
|
||||||
local nstr = tempfile:read("*l")
|
local nstr = tempfile:read("*l")
|
||||||
tempfile:close()
|
tempfile:close()
|
||||||
client:run('Bot '..nstr)
|
client:run('Bot '..nstr:match("^%s*(.+)%s*$"))
|
||||||
|
|
|
@ -26,10 +26,7 @@ local triggerOnce = function(evname,args,vars)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
client:on("messageCreate",function(msg)
|
event_emitter:on("messageCreate",function(msg)
|
||||||
if (not msg.guild) or (tostring(msg.guild.id) ~= tostring(id)) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local content = msg.content
|
local content = msg.content
|
||||||
local user = msg.author.id
|
local user = msg.author.id
|
||||||
local channelid = msg.channel.id
|
local channelid = msg.channel.id
|
||||||
|
@ -45,10 +42,7 @@ client:on("messageCreate",function(msg)
|
||||||
triggerOnce("messageOnce",{content,user,channelid},args)
|
triggerOnce("messageOnce",{content,user,channelid},args)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
client:on("userBan",function(user,guild)
|
event_emitter:on("userBan",function(user,guild)
|
||||||
if tostring(guild.id) ~= tostring(id) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
args = {
|
args = {
|
||||||
["%$USER"] = user.id,
|
["%$USER"] = user.id,
|
||||||
["%$USERNAME"] = user.name
|
["%$USERNAME"] = user.name
|
||||||
|
@ -59,10 +53,7 @@ client:on("userBan",function(user,guild)
|
||||||
triggerOnce("banOnce",{user.id},args)
|
triggerOnce("banOnce",{user.id},args)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
client:on("userUnban",function(user,guild)
|
event_emitter:on("userUnban",function(user,guild)
|
||||||
if tostring(guild.id) ~= tostring(id) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
args = {
|
args = {
|
||||||
["%$USER"] = user.id,
|
["%$USER"] = user.id,
|
||||||
["%$USERNAME"] = user.name
|
["%$USERNAME"] = user.name
|
||||||
|
@ -73,14 +64,11 @@ client:on("userUnban",function(user,guild)
|
||||||
triggerOnce("unbanOnce",{user.id},args)
|
triggerOnce("unbanOnce",{user.id},args)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
client:on("memberJoin", function(member)
|
event_emitter:on("memberJoin", function(member)
|
||||||
if tostring(member.guild.id) ~= tostring(id) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
args = {
|
args = {
|
||||||
["%$USER"] = member.id,
|
["%$USER"] = member.id,
|
||||||
["%$USERNAME"] = member.name,
|
["%$USERNAME"] = member.name,
|
||||||
["%$AGE"] = member.user.createdAt,
|
["%$AGE"] = discordia.Date():toSeconds()-member.user.createdAt,
|
||||||
["%$DISCRIM"] = member.user.discriminator,
|
["%$DISCRIM"] = member.user.discriminator,
|
||||||
["%$TAG"] = member.user.tag
|
["%$TAG"] = member.user.tag
|
||||||
}
|
}
|
||||||
|
@ -88,24 +76,21 @@ client:on("memberJoin", function(member)
|
||||||
trigger("join",{
|
trigger("join",{
|
||||||
member.id,
|
member.id,
|
||||||
member.name,
|
member.name,
|
||||||
member.user.createdAt
|
discordia.Date():toSeconds()-member.user.createdAt
|
||||||
},args)
|
},args)
|
||||||
-- @joinOnce: userid, username, age, $USER, $USERNAME, $AGE, $DISCRIM, $TAG
|
-- @joinOnce: userid, username, age, $USER, $USERNAME, $AGE, $DISCRIM, $TAG
|
||||||
triggerOnce("joinOnce",{
|
triggerOnce("joinOnce",{
|
||||||
member.id,
|
member.id,
|
||||||
member.name,
|
member.name,
|
||||||
member.user.createdAt
|
discordia.Date():toSeconds()-member.user.createdAt
|
||||||
},args)
|
},args)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
client:on("memberLeave", function(member)
|
event_emitter:on("memberLeave", function(member)
|
||||||
if tostring(member.guild.id) ~= tostring(id) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
args = {
|
args = {
|
||||||
["%$USER"] = member.id,
|
["%$USER"] = member.id,
|
||||||
["%$USERNAME"] = member.name,
|
["%$USERNAME"] = member.name,
|
||||||
["%$AGE"] = member.user.createdAt,
|
["%$AGE"] = discordia.Date():toSeconds()-member.user.createdAt,
|
||||||
["%$DISCRIM"] = member.user.discriminator,
|
["%$DISCRIM"] = member.user.discriminator,
|
||||||
["%$TAG"] = member.user.tag,
|
["%$TAG"] = member.user.tag,
|
||||||
["%$GUILDTIME"] = member.joinedAt,
|
["%$GUILDTIME"] = member.joinedAt,
|
||||||
|
|
|
@ -4,6 +4,8 @@ local plugin = pluginc("cron")
|
||||||
local cron = import("cron")
|
local cron = import("cron")
|
||||||
local fake_message = import("fake_message")
|
local fake_message = import("fake_message")
|
||||||
local md5 = import("md5")
|
local md5 = import("md5")
|
||||||
|
local discordia = import("discordia")
|
||||||
|
local event_emitter = events
|
||||||
local events = {
|
local events = {
|
||||||
timer = {},
|
timer = {},
|
||||||
event = {}
|
event = {}
|
||||||
|
@ -332,10 +334,11 @@ local data = fhandler:read("*a")
|
||||||
fhandler:close()
|
fhandler:close()
|
||||||
local eventfunc = load(data,"event loader: "..plugin_path.."/events.lua",nil,setmetatable({
|
local eventfunc = load(data,"event loader: "..plugin_path.."/events.lua",nil,setmetatable({
|
||||||
id = id,
|
id = id,
|
||||||
client = client,
|
event_emitter = event_emitter,
|
||||||
exec = exec,
|
exec = exec,
|
||||||
events = events,
|
events = events,
|
||||||
config = config
|
config = config,
|
||||||
|
discordia = discordia
|
||||||
},{__index = _G}))
|
},{__index = _G}))
|
||||||
eventfunc()
|
eventfunc()
|
||||||
timer:start(true)
|
timer:start(true)
|
||||||
|
|
|
@ -172,7 +172,7 @@ local c_aliases = command("aliases", {
|
||||||
return fields
|
return fields
|
||||||
end)(),
|
end)(),
|
||||||
footer = {
|
footer = {
|
||||||
text = "Events "..tostring(page-4).." - "..tostring(page).." | Total: "..tostring(#events)
|
text = "Aliases "..tostring(page-4).." - "..tostring(page).." | Total: "..tostring(#events)
|
||||||
}
|
}
|
||||||
}})
|
}})
|
||||||
end
|
end
|
||||||
|
|
|
@ -43,4 +43,22 @@ return {
|
||||||
{name = "Options: ", value = "`--regex (regex)` - match content against regex; \n`--user (user)` - match user against id/name; \n`-w` - match webhook messages"}
|
{name = "Options: ", value = "`--regex (regex)` - match content against regex; \n`--user (user)` - match user against id/name; \n`-w` - match webhook messages"}
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
|
["ban"] = { embed = {
|
||||||
|
title = "Ban members",
|
||||||
|
description = "nuff said.",
|
||||||
|
fields = {
|
||||||
|
{name = "Usage: ", value = "ban <member>"},
|
||||||
|
{name = "Perms: ", value = "banMembers"},
|
||||||
|
{name = "Options: ", value = "--reason=\"<reason>\""},
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
["kick"] = { embed = {
|
||||||
|
title = "Ban members",
|
||||||
|
description = "nuff said.",
|
||||||
|
fields = {
|
||||||
|
{name = "Usage: ", value = "kick <member>"},
|
||||||
|
{name = "Perms: ", value = "kickMembers"},
|
||||||
|
{name = "Options: ", value = "--reason=\"<reason>\""},
|
||||||
|
},
|
||||||
|
}},
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,34 @@ local revokerole = command("revoke-role",{
|
||||||
})
|
})
|
||||||
plugin:add_command(revokerole)
|
plugin:add_command(revokerole)
|
||||||
|
|
||||||
|
local ban = command("ban",{
|
||||||
|
category = "Security",
|
||||||
|
perms = {
|
||||||
|
"banMembers"
|
||||||
|
},
|
||||||
|
args = {
|
||||||
|
"member"
|
||||||
|
},
|
||||||
|
exec = function(msg,args,opts)
|
||||||
|
return args[1]:ban(opts["reason"])
|
||||||
|
end
|
||||||
|
})
|
||||||
|
plugin:add_command(ban)
|
||||||
|
|
||||||
|
local kick = command("kick", {
|
||||||
|
category = "Security",
|
||||||
|
perms = {
|
||||||
|
"kickMembers",
|
||||||
|
},
|
||||||
|
args = {
|
||||||
|
"member"
|
||||||
|
},
|
||||||
|
exec = function(msg,args,opts)
|
||||||
|
return args[1]:ban(opts["reason"])
|
||||||
|
end
|
||||||
|
})
|
||||||
|
plugin:add_command(kick)
|
||||||
|
|
||||||
local warn = command("warn",{
|
local warn = command("warn",{
|
||||||
category = "Security",
|
category = "Security",
|
||||||
perms = {
|
perms = {
|
||||||
|
|
Loading…
Reference in New Issue