-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBot.lua
70 lines (65 loc) · 2.08 KB
/
Bot.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
fs = require('fs')
options = require('./options')
token = options.Token
hooks = options.Hooks
discordia = require('discordia')
enums = discordia.enums
client = discordia.Client()
uptime = discordia.Stopwatch()
discordia.extensions()
HMath = require('./Modules/MathParser.lua')
function FFB(t) --format for beta
if beta == true then
return t..'_B'
else
return t
end
end
function loadModule(name)
name = name .. '.lua'
local data,others = fs.readFileSync('./Modules/' .. name)
if data then
local a,b = loadstring(data,name)
if not a then
print("<SYNTAX> ERROR LOADING " .. name .. "\nERROR:" .. b)
if sendLog then
sendLog(hooks[FFB('Errors')], "MODULE SYNTAX", string.format("MODULE NAME: %s\nERROR: %s", name, tostring(b)))
end
return false
else
setfenv(a, getfenv())
local c,d = pcall(a)
if not c then
print("<RUNTIME> ERROR LOADING " .. name .. "\nERROR:" .. d)
if sendLog then
sendLog(hooks[FFB('Errors')], "MODULE RUNTIME", string.format("MODULE NAME: %s\nERROR: %s", name, tostring(d)))
end
return false
else
client:info('Module online: ' .. name)
end
end
else
print("<LOADING> ERROR LOADING " .. name .. "\nERROR:" .. tostring(data), tostring(others))
if sendLog then
sendLog(hooks[FFB('Errors')], "MODULE LOADING", string.format("MODULE NAME: %s\nERROR: %s", name, tostring(data) .. '\n' .. tostring(others)))
end
return false
end
end
coroutine.wrap(function()
loadModule('Functions')
loadModule('Database')
loadModule('Commands')
loadModule('Events')
loadModule('Timed')
loadModule('API')
client:on('messageCreate', function(...) pcall(Events.messageCreate, ...) end)
client:on('messageUpdate', function(...) pcall(Events.messageUpdate, ...) end)
client:on('messageDelete', function(...) pcall(Events.messageDelete, ...) end)
client:on('guildCreate', function(...) pcall(Events.guildCreate, ...) end)
client:on('guildDelete', function(...) pcall(Events.guildDelete, ...) end)
client:on('memberJoin', function(...) pcall(Events.memberCreate, ...) end)
client:once('ready', Events.ready)
client:run('Bot ' .. token)
end)()