-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
executable file
·75 lines (56 loc) · 1.65 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
-- SETUP:
-- Variables:
Discordia = require "discordia"
require "src/import"
Class = Discordia.class
Client = Discordia.Client {
logFile = "logs/discordia.log",
gatewayFile = "logs/gateway.json"
}
bot.isDebug = true
switch = Switch.switch
-- Due to my inability to remember my own code structure:
easy.debug = bot.debug
-- Legacy variables: (i am still very lazy)
info.version = globalInfo.version
-- FUNCTIONS:
local function updateProfile()
Client:setUsername(info.name)
Client:setGame(BotProfile.playing)
-- Client:setStatus(BotProfile.status)
end
-- SETUP:
Client:on("ready", function()
updateProfile()
bot.time.setStartup()
bot.debug("Bot started: %s", os.date())
bot.user = Client.user
-- Legacy (i am extremly lazy, okay??):
info.id = bot.user.id
-- Add bot to ignored IDs list:
table.insert(BannedIDs, bot.user.id)
end)
-- MAIN:
Client:on("messageCreate", function(Message)
if Message.author.bot then return end
Command:handleMessage(Message)
Goodies:handleMessage(Message)
LogChannel:handleEvent(Message, "messageCreate", "messages")
end)
Client:on("messageUpdate", function(Message)
LogChannel:handleEvent(Message, "messageUpdate", "messages")
end)
Client:on("messageDelete", function(Message)
LogChannel:handleEvent(Message, "messageDelete", "messages")
end)
Client:on("reactionAdd", function(Reaction, CallerID)
MessageReaction:handleReaction(Reaction, CallerID)
end)
Client:on("memberJoin", function(Member)
MemberJoinLeave:handleEvent(Member, "memberJoin")
end)
Client:on("memberLeave", function(Member)
MemberJoinLeave:handleEvent(Member, "memberLeave")
end)
-- Run bot with token:
Client:run(string.format('Bot %s', info.token))