forked from Machine-Maker/AdventureBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.js
58 lines (48 loc) · 1.59 KB
/
bot.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
require('dotenv').config()
// Argument setup
process.HIDE_WARNINGS = false
const argv = process.argv.slice(2)
if (argv.includes('-nw') || argv.includes('--no-warnings')) process.HIDE_WARNINGS = true
const { CommandoClient } = require('discord.js-commando')
const path = require('path')
const botConfig = require('./configs/bot_config')
const databases = require('./setup/databases')
const scenarios = require('./setup/scenarios')
const logging = require('./setup/logging')
const promises = require('./setup/promises')
const events = require('./setup/events')
const bot = new CommandoClient({
commandPrefix: '!',
owner: '338670732403933194',
unknownCommandResponse: false
})
module.exports = bot
bot.config = botConfig
logging.setup()
promises.setup()
databases.setup(bot).then(res => {
bot.db = res
scenarios.setup(bot).then(res => {
bot.scenarios = res
bot.startScenario = bot.scenarios.find(s => s.name === 'Start')
if (!bot.startScenario) console.error('Could not find start scenario!')
bot.randomScenario = () =>
bot.scenarios.filter(s => s.name !== 'Start')[
Math.floor(Math.random() * (bot.scenarios.length - 1))
]
events.setup(bot)
})
})
bot.registry
.registerDefaultTypes()
.registerDefaultGroups()
.registerDefaultCommands({
help: false,
prefix: false,
ping: false,
unknownCommand: false,
commandState: false
})
.registerGroups([['admin', 'Admin'], ['dev', 'Dev'], ['user', 'User']])
.registerCommandsIn(path.join(__dirname, 'commands'))
bot.login(process.env.ENVIRONMENT === 'dev' ? process.env.TOKEN_TEST : process.env.TOKEN)