forked from BotStudios/Music-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
44 lines (39 loc) · 1.21 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
const Discord = require('discord.js');
const { Client, Collection } = require("discord.js")
const { readdirSync } = require("fs")
const { play, stop } = require('./commands.js');
const client = new Discord.Client();
client.login("YOUR_BOT_TOKEN");
client.on('ready', () => console.log('Bot has logged in!'));
client.on("ready", () => {
client.user.setActivity("BotStudios", { type: "STREAMING", url: "https://www.twitch.tv/BotStudiosGithub" })
})
client.on('message', (msg) => {
if (msg.author.bot) return;
const prefix = '-'; //can set the prefix default is -
if (!msg.content.startsWith(prefix)) return;
const commandName = getCommandName(prefix, msg.content);
const args = getCommandArgs(prefix, msg.content);
if (commandName === 'p')
return play(msg, args);
else if (commandName === 's')
return stop(msg, args);
});
if (commandName === 'play')
return play(msg, args);
else if (commandName === 'stop')
return stop(msg, args);
});
function getCommandName(prefix, content) {
return content
.slice(prefix.length)
.split(' ')[0];
}
function getCommandArgs(prefix, content) {
return content
.slice(prefix.length)
.split(' ')
.slice(1);
}
// coded by BotStudios Team
// Version 2