-
Notifications
You must be signed in to change notification settings - Fork 0
/
servers.js
62 lines (51 loc) · 1.57 KB
/
servers.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
var servers = new Map();
module.exports = {
// Get reference to the servers settings as a whole.
get: (serverId) => {
return servers.get(serverId);
},
// Reference to queue of the server
getQueue: (serverId) => {
return servers.get(serverId).queue;
},
// Create a new server in the map with default settings.
newServer: (serverId) => {
servers.set(serverId, {
queue: [],
isPlaying: false,
voiceId: 0 // uk-male default
});
},
// Adds a new voice file to the end of the queue
addToQueue: (serverId, voiceFile) => {
servers.get(serverId).queue.push(voiceFile);
},
// Returns next element in queue and then shifts forward
nextInQueue: (serverId) => {
return servers.get(serverId).queue.shift();
},
// Sets the index of the voice
setVoiceId: (serverId, index) => {
servers.get(serverId).voiceId = index;
},
// Change the current status of the bot playing something
changePlaying: (serverId) => {
servers.get(serverId).isPlaying = !servers.get(serverId).isPlaying;
},
// Change the current status of the bot playing something to false
setPlayingFalse: (serverId) => {
servers.get(serverId).isPlaying = false;
},
// Change the current status of the bot playing something to true
setPlayingTrue: (serverId) => {
servers.get(serverId).isPlaying = true;
},
// Returns if there is anything playing in the server
isPlaying: (serverId) => {
return servers.get(serverId).isPlaying;
},
// Debug command to print servers to the console
console: () => {
console.log(servers);
}
}