-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenvironment.js
49 lines (40 loc) · 1.08 KB
/
environment.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
const Discord = require('discord.js');
const express = require('express');
const path = require('path');
const commandHelpers = require('./commands.js');
const dynamoClient = require('./dynamodb.js');
async function create() {
const config = {
healthcheck_port: process.env.HEALTHCHECK_PORT || 3000,
bot_token: process.env.BOT_TOKEN,
bot_client_id: process.env.BOT_CLIENT_ID,
debug: !!process.env.DEBUG,
};
if (!config.bot_token) {
throw 'Env variable BOT_TOKEN must be specified.';
}
return {
config,
discord: {
client: new Discord.Client({
intents: [Discord.GatewayIntentBits.Guilds],
}),
rest: new Discord.REST({ version: '10' }).setToken(config.bot_token),
},
server: express(),
db: dynamoClient,
commands: [
...(await commandHelpers.loadFromDirectory(
path.join(__dirname, '../commands/')
)),
...(config.debug
? await commandHelpers.loadFromDirectory(
path.join(__dirname, '../commands.debug/')
)
: []),
],
};
}
module.exports = {
create,
};