Updated guide on self-hosting the bot

This commit is contained in:
Yessiest 2022-05-21 20:46:02 +04:00
parent e87056a2c2
commit b4d0f9ea54
7 changed files with 67 additions and 31 deletions

View File

@ -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/)
# 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
place the bot token in the "./token" file, change server id in bot.lua to the id of your server.
compile [luvit](https://luvit.io) and run bot.lua.
1. Get a bot token and place it in ./token
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
```

View File

@ -46,4 +46,4 @@ if not tempfile then
end
local nstr = tempfile:read("*l")
tempfile:close()
client:run('Bot '..nstr)
client:run('Bot '..nstr:match("^%s*(.+)%s*$"))

View File

@ -26,10 +26,7 @@ local triggerOnce = function(evname,args,vars)
end
end
client:on("messageCreate",function(msg)
if (not msg.guild) or (tostring(msg.guild.id) ~= tostring(id)) then
return
end
event_emitter:on("messageCreate",function(msg)
local content = msg.content
local user = msg.author.id
local channelid = msg.channel.id
@ -45,10 +42,7 @@ client:on("messageCreate",function(msg)
triggerOnce("messageOnce",{content,user,channelid},args)
end)
client:on("userBan",function(user,guild)
if tostring(guild.id) ~= tostring(id) then
return
end
event_emitter:on("userBan",function(user,guild)
args = {
["%$USER"] = user.id,
["%$USERNAME"] = user.name
@ -59,10 +53,7 @@ client:on("userBan",function(user,guild)
triggerOnce("banOnce",{user.id},args)
end)
client:on("userUnban",function(user,guild)
if tostring(guild.id) ~= tostring(id) then
return
end
event_emitter:on("userUnban",function(user,guild)
args = {
["%$USER"] = user.id,
["%$USERNAME"] = user.name
@ -73,14 +64,11 @@ client:on("userUnban",function(user,guild)
triggerOnce("unbanOnce",{user.id},args)
end)
client:on("memberJoin", function(member)
if tostring(member.guild.id) ~= tostring(id) then
return
end
event_emitter:on("memberJoin", function(member)
args = {
["%$USER"] = member.id,
["%$USERNAME"] = member.name,
["%$AGE"] = member.user.createdAt,
["%$AGE"] = discordia.Date():toSeconds()-member.user.createdAt,
["%$DISCRIM"] = member.user.discriminator,
["%$TAG"] = member.user.tag
}
@ -88,24 +76,21 @@ client:on("memberJoin", function(member)
trigger("join",{
member.id,
member.name,
member.user.createdAt
discordia.Date():toSeconds()-member.user.createdAt
},args)
-- @joinOnce: userid, username, age, $USER, $USERNAME, $AGE, $DISCRIM, $TAG
triggerOnce("joinOnce",{
member.id,
member.name,
member.user.createdAt
discordia.Date():toSeconds()-member.user.createdAt
},args)
end)
client:on("memberLeave", function(member)
if tostring(member.guild.id) ~= tostring(id) then
return
end
event_emitter:on("memberLeave", function(member)
args = {
["%$USER"] = member.id,
["%$USERNAME"] = member.name,
["%$AGE"] = member.user.createdAt,
["%$AGE"] = discordia.Date():toSeconds()-member.user.createdAt,
["%$DISCRIM"] = member.user.discriminator,
["%$TAG"] = member.user.tag,
["%$GUILDTIME"] = member.joinedAt,

View File

@ -4,6 +4,8 @@ local plugin = pluginc("cron")
local cron = import("cron")
local fake_message = import("fake_message")
local md5 = import("md5")
local discordia = import("discordia")
local event_emitter = events
local events = {
timer = {},
event = {}
@ -332,10 +334,11 @@ local data = fhandler:read("*a")
fhandler:close()
local eventfunc = load(data,"event loader: "..plugin_path.."/events.lua",nil,setmetatable({
id = id,
client = client,
event_emitter = event_emitter,
exec = exec,
events = events,
config = config
config = config,
discordia = discordia
},{__index = _G}))
eventfunc()
timer:start(true)

View File

@ -172,7 +172,7 @@ local c_aliases = command("aliases", {
return fields
end)(),
footer = {
text = "Events "..tostring(page-4).." - "..tostring(page).." | Total: "..tostring(#events)
text = "Aliases "..tostring(page-4).." - "..tostring(page).." | Total: "..tostring(#events)
}
}})
end

View File

@ -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"}
}
}},
["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>\""},
},
}},
}

View File

@ -48,6 +48,34 @@ local revokerole = command("revoke-role",{
})
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",{
category = "Security",
perms = {