-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.lua
94 lines (81 loc) · 2.48 KB
/
main.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
-- https://github.com/stein197/lua-string
local discordia = require("discordia")
discordia.extensions()
_G.fs = require("fs")
_G.path = require("path")
_G.CORO = require("coro-http")
_G.SPAWN = require("coro-spawn")
_G.TIMER = require("timer")
_G.JSON = require("json")
_G.DISCORDIA = discordia
_G.CLIENT = discordia.Client()
_G.CONFIG = require("./config.lua")
require("./lib/string.lua")
_G.EMBEDCOLOR = DISCORDIA.Color.fromRGB(170, 26, 232).value
_G.NODECLUSTERS = "Powered by [NodeClusters](https://nodeclusters.com/billing/aff.php?aff=7)."
function _G.encodeURI(str)
return (str:gsub("([^A-Za-z0-9%_%.%-%~])", function(v)
return string.upper(string.format("%%%02x", string.byte(v)))
end))
end
-- Polyfill
function math.round(x)
local decimal = x - math.floor(x)
if decimal < 0.5 then -- floor
return x - decimal
else -- ceil
return x + (1 - decimal)
end
end
local function setGame()
local numbersOfGuilds = #_G.CLIENT.guilds
if numbersOfGuilds == 1
then
game = " for +help in a server"
else
game = "for +help in " .. numbersOfGuilds .. " servers"
end
_G.CLIENT:setGame{ name = game, type = 3 }
end
_G.CLIENT:on("ready", function()
print("Ready!")
setGame()
end)
CLIENT:on("guildCreate",function()
setGame()
end)
CLIENT:on("guildDelete",function()
setGame()
end)
print("[LIBRARIES]", "Loading library files")
for k, v in fs.scandirSync("./lib") do
print("[LIBRARIES]", "Loading:", k)
local data = require("./lib/"..k)
print(" ", "[LIBRARIES]", "Success:", k, "has been loaded.")
end
print("[HANDLERS]", "Loading handler files")
for k, v in fs.scandirSync("./handler") do
print("[HANDLERS]", "Loading:", k)
local data = require("./handler/"..k)
if not data.name then
print(" ", "[HANDLERS]", "Error:", k, "does not have a valid name!")
elseif _G[data.name] then
print(" ", "[HANDLERS]", "Error:", k, "has a name which is already registered as a handler. The name is", data.name)
else
_G[data.name] = data
print(" ", "[HANDLERS]", "Success:", k, "has been loaded with the name", data.name)
end
end
print("[CMDS]", "Loading command files")
for k, v in fs.scandirSync("./commands") do
print("[CMDS]", "Loading:", k)
local data = require("./commands/"..k)
print(" ", "[CMDS]", "Success:", k, "has been loaded.")
end
--[[print("[EVENTS]", "Loading command files")
for k, v in fs.scandirSync("./events") do
print("[EVENTS]", "Loading:", k)
local data = require("./events/"..k)
print(" ", "[EVENTS]", "Success:", k, "has been loaded.")
end]]--
CLIENT:run('Bot ' .. CONFIG.token)