-
Notifications
You must be signed in to change notification settings - Fork 127
/
Copy pathindex.js
49 lines (39 loc) · 1.19 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
const dotenv = require('dotenv');
const path = require('path');
const { SlashCreator, GatewayServer } = require('slash-create');
const { Client } = require('discord.js');
const { Player } = require('discord-player');
const { registerPlayerEvents } = require('./events');
const { generateDocs } = require('./docs');
dotenv.config();
const client = new Client({
intents: [
'GUILDS',
'GUILD_VOICE_STATES'
]
});
client.player = new Player(client);
registerPlayerEvents(client.player);
const creator = new SlashCreator({
applicationID: process.env.DISCORD_CLIENT_ID,
token: process.env.DISCORD_CLIENT_TOKEN,
});
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
console.log('Generating docs...');
generateDocs(creator.commands);
});
creator
.withServer(
new GatewayServer(
(handler) => client.ws.on('INTERACTION_CREATE', handler)
)
)
.registerCommandsIn(path.join(__dirname, 'commands'));
if (process.env.DISCORD_GUILD_ID) creator.syncCommandsIn(process.env.DISCORD_GUILD_ID);
else creator.syncCommands();
client.login(process.env.DISCORD_CLIENT_TOKEN);
module.exports = {
client,
creator
};