-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
68 lines (55 loc) 路 1.65 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
const dotenv = require('dotenv');
const path = require('path');
const { SlashCreator, GatewayServer } = require('slash-create');
const { Client } = require('discord.js');
const { Manager } = require("erela.js");
const { registerManagerEvents } = require('./events');
const { generateDocs } = require('./docs');
dotenv.config();
const client = new Client({
intents: [
'GUILDS',
'GUILD_VOICE_STATES'
]
});
client.manager = new Manager({
nodes: [
{
host: process.env.LAVALINK_SERVER_ADDRESS,
port: parseInt(process.env.LAVALINK_SERVER_PORT),
password: process.env.LAVALINK_SERVER_PASSWORD,
secure: Boolean(process.env.LAVALINK_SECURE),
},
],
send(id, payload) {
const guild = client.guilds.cache.get(id);
if (guild) guild.shard.send(payload);
},
})
client.on("raw", (d) => client.manager.updateVoiceState(d));
registerManagerEvents(client);
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}!`);
client.manager.init(client.user.id);
client.user.setActivity('you sleep at night', { type: 'WATCHING' });
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
};