-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
76 lines (60 loc) · 1.95 KB
/
index.js
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
/*** Client ***/
let { client } = require('./client')
const { TOKEN } = require("robo-bot-utils")
const { ch_bots, ch_general, dev_bot } = require('./bot/ids')
/** Prefix Commands **/
const matchCmd = /^>([a-zA-Z]+)/
let dailyCMD = require('./bot/commands/daily')
let prayCMD = require('./bot/commands/pray')
let compatWrap = async (cmd, msg) => {
// author/user patch
msg.user = msg.author
// Reply patch
let reply = null
msg.deferReply = (content)=>reply={}
msg.editReply = (content)=>reply=content
// Execute
await cmd.execute(msg)
if (reply) msg.reply(reply)
}
const {executeBotCommand} = require('./bot/utils/botExec')
const {initGameState} = require('./bot/games/gameState')
client.on('ready', async ()=>{
await initGameState()
//await executeBotCommand(client, 'bs', '462274708499595266')
})
/** Per-Message Effects **/
const messageXP = require("./bot/passive/messageXP")
const handleRoboEvent = require("./bot/passive/handleRoboEvent")
const gameHandler = require('./bot/games/gameHandler')
client.on("messageCreate", async (msg) => {
if (msg.author.bot) return
/** Prefix Commands **/
let match = msg.content.toLowerCase().match(matchCmd)
if (match && [ch_general, ch_bots, dev_bot].includes(msg.channel.id) ) {
let [_, cmdName] = match
if ( ['daily', 'd'].includes(cmdName) ) {
compatWrap(dailyCMD, msg)
} else
if ( ['pray', 'p'].includes(cmdName) ) {
compatWrap(prayCMD, msg)
}
}
/** Passives **/
await messageXP(msg)
await gameHandler(msg)
if (client.robo_events[msg.channel.id]) {
handleRoboEvent(client, msg)
}
});
/** Pyro-Bar **/
const pyroBar = require("./bot/utils/pyroBar")
setInterval(() => {
pyroBar.onMinute(client, ch_general)
}, 1e3 * 60 ); // every mins
/** Per-Join Effects **/
const welcome = require("./bot/passive/welcome")
client.on("guildMemberAdd", async (member) => {
welcome(member) // adds linked role if return member
});
client.login(TOKEN)