-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
74 lines (67 loc) · 1.92 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
69
70
71
72
73
74
const { CommandoClient } = require('discord.js-commando');
const { Structures } = require('discord.js');
const path = require('path');
const { prefix, discord_owner_id } = require('./config.json');
Structures.extend('Guild', function(Guild) {
class MusicGuild extends Guild {
constructor(client, data) {
super(client, data);
this.musicData = {
queue: [],
isPlaying: false,
nowPlaying: null,
songDispatcher: null,
volume: 1
};
this.triviaData = {
isTriviaRunning: false,
wasTriviaEndCalled: false,
triviaQueue: [],
triviaScore: new Map()
};
}
}
return MusicGuild;
});
const client = new CommandoClient({
commandPrefix: prefix,
owner: discord_owner_id // value comes from config.json
});
client.registry
.registerDefaultTypes()
.registerGroups([
['music', 'Music Command Group'],
['gifs', 'Gif Command Group'],
['other', 'random types of commands group'],
['guild', 'guild related commands']
])
.registerDefaultGroups()
.registerDefaultCommands({
eval: false,
prefix: false,
commandState: false
})
.registerCommandsIn(path.join(__dirname, 'commands'));
client.once('ready', () => {
console.log('Ready!');
client.user.setActivity(`Premium User`, {
type: 'WATCHING'
});
});
client.on('voiceStateUpdate', async (___, newState) => {
if (
newState.member.user.bot &&
!newState.channelID &&
newState.guild.musicData.songDispatcher &&
newState.member.user.id == client.user.id
) {
newState.guild.musicData.queue.length = 0;
newState.guild.musicData.songDispatcher.end();
}
});
client.on('guildMemberAdd', member => {
const channel = member.guild.channels.cache.find(ch => ch.name === 'general'); // change this to the channel name you want to send the greeting to
if (!channel) return;
channel.send(`Welcome ${member}!`);
});
client.login(process.env.TOKEN);