-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserver.js
77 lines (67 loc) · 2.35 KB
/
server.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
77
const Discord = require('discord.js');
const {
prefix,
API_TOKEN,
} = require('./config.json');
const { MessageHandler } = require('./src/handlers/MessageHandler');
const {
VoiceChannelChangeHandler,
} = require('./src/handlers/VoiceChannelChangeHandler');
const { NewMemberAddHandler } = require('./src/handlers/NewMemberAddHandler');
const { MemberLeaveHandler } = require('./src/handlers/MemberLeaveHandler');
const { ReactionHandler } = require ('./src/handlers/ReactionHandler');
const startBot = async () => {
const client = new Discord.Client({
intents: [
Discord.GatewayIntentBits.Guilds,
Discord.GatewayIntentBits.GuildMessages,
Discord.GatewayIntentBits.MessageContent,
Discord.GatewayIntentBits.GuildVoiceStates,
Discord.GatewayIntentBits.GuildMessageReactions,
Discord.GatewayIntentBits.GuildMembers,
Discord.GatewayIntentBits.GuildPresences,
],
partials:
[
Discord.Partials.Channel,
Discord.Partials.Message,
Discord.Partials.Reaction],
});
const messageHandler = new MessageHandler(prefix);
const vcChangeHandler = new VoiceChannelChangeHandler();
const newMemberHandler = new NewMemberAddHandler();
const memberLeaveHandler = new MemberLeaveHandler();
const reactionHandler = new ReactionHandler();
client.once('ready', () => {
messageHandler.initialize();
client.user.setPresence({
activity: {
name: `${prefix}help`,
type: 'LISTENING',
},
});
console.log('Discord bot live');
});
client.on('messageCreate', (message) => {
messageHandler.handleMessage(message);
});
client.on('voiceStateUpdate', (oldState, newState) => {
vcChangeHandler.handleChangeMemberInVoiceChannel(oldState, newState);
});
client.on('guildMemberAdd', (newMember) => {
newMemberHandler.handleNewMember(newMember);
});
client.on('guildMemberRemove', (member) => {
memberLeaveHandler.handleMemberLeave(member);
});
client.on('messageReactionAdd', async (reaction, user) => {
const botpfp = client.user.displayAvatarURL();
reactionHandler.handleReaction(reaction, user, botpfp);
});
client.on('messageReactionRemove', async (reaction, user) => {
const botpfp = client.user.displayAvatarURL();
reactionHandler.handleReaction(reaction, user, botpfp, true);
});
client.login(API_TOKEN);
};
startBot();