-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
52 lines (48 loc) · 1.32 KB
/
main.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
// Global vars
queue = new Map();
client = undefined;
// Action functions
var {
execute,
skip,
stop,
disconnect,
getQueue,
nowPlaying,
remove,
shuffle,
} = require("./actions");
// Handle recieved function
async function cmdFunc(msg, args, action) {
client = msg.client;
const serverQueue = queue.get(msg.guild.id);
if (action == "play") {
execute(msg, serverQueue, args); // Attempt to play track
} else if (action == "next") {
skip(msg, serverQueue); // Skip track
} else if (action == "stop") {
stop(msg, serverQueue); // Stop playback
} else if (action == "disconnect") {
disconnect(msg, msg.guild.id); // Disconnect from vc
} else if (action == "queue") {
getQueue(msg, serverQueue, args); // Sends queue
} else if (action == "nowPlaying") {
nowPlaying(msg, serverQueue); // Sends current track
} else if (action == "remove") {
remove(msg, serverQueue, args); // Remove from queue
} else if (action == "shuffle") {
shuffle(msg, serverQueue); // Shuffle queue
}
}
// Global prototype function for required modules
Number.prototype.durationFormat = function () {
if (this >= 3600) {
return new Date(this * 1000).toISOString().substr(11, 8);
} else {
return new Date(this * 1000).toISOString().substr(14, 5);
}
};
// Exports
module.exports = {
cmdFunc,
};