aboutsummaryrefslogtreecommitdiff
path: root/bot.js
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@protonmail.com>2020-07-20 19:58:06 -0400
committerAndrew Lee <alee14498@protonmail.com>2020-07-20 19:58:06 -0400
commita65df85c8c85cbeeffd0fc9b760be3b773a59865 (patch)
tree291aed93eff139bba5511d10c3428a1309d438c0 /bot.js
parenta37d6172c4fe3e5150da6c6de834a1570268ec51 (diff)
downloadDLAP-a65df85c8c85cbeeffd0fc9b760be3b773a59865.tar.gz
DLAP-a65df85c8c85cbeeffd0fc9b760be3b773a59865.tar.bz2
DLAP-a65df85c8c85cbeeffd0fc9b760be3b773a59865.zip
Added help embed and made some tweaks
Diffstat (limited to 'bot.js')
-rw-r--r--bot.js27
1 files changed, 18 insertions, 9 deletions
diff --git a/bot.js b/bot.js
index 1789d29..898d477 100644
--- a/bot.js
+++ b/bot.js
@@ -11,6 +11,7 @@ const fs = require('fs');
const client = new Discord.Client();
const config = require('./config.json');
let dispatcher;
+let audio;
client.login(config.token);
@@ -19,24 +20,25 @@ function playAudio() {
if (!channel) return console.error('The channel does not exist!');
channel.join().then(connection => {
- console.log('Connected to the voice channel.');
let files = fs.readdirSync('./music');
- let audio;
while (true) {
audio = files[Math.floor(Math.random() * files.length)];
- console.log('Searching file...');
+ console.log('Searching .mp3 file...');
if (audio.endsWith('.mp3')) {
break;
}
}
dispatcher = connection.play('./music/' + audio);
-
- console.log('Now playing ' + audio);
- let serviceChannel = client.channels.cache.get('606602551634296968');
- serviceChannel.send('**Project Jul-2020 Bot:**\nNow playing ' + audio);
+ dispatcher.on('start', () => {
+ console.log('Now playing ' + audio);
+ let serviceChannel = client.channels.cache.get('606602551634296968');
+ serviceChannel.send('**Project Jul-2020 Bot:**\nNow playing ' + audio);
+ });
+ dispatcher.on('error', console.error);
+
dispatcher.on('finish', () => {
playAudio();
});
@@ -54,6 +56,7 @@ client.on('ready', () => {
console.log(`Voice Channel: ${config.voiceChannel}\n`);
client.user.setStatus('invisible');
+ console.log('Connected to the voice channel.');
playAudio();
});
@@ -67,7 +70,12 @@ client.on('message', async msg => {
// Public allowed commands
if (command == 'help') {
- msg.channel.send(`Bot help:\n\`\`\`${config.prefix}help\n${config.prefix}ping\n${config.prefix}git\n${config.prefix}about\n\nFeel free to either lower the volume or mute me if it gets annoying!\n\`\`\``)
+ const helpEmbed = new Discord.MessageEmbed()
+ .addField('Bot Help', `${config.prefix}help\n${config.prefix}ping\n${config.prefix}git\n${config.prefix}about`)
+ .setFooter('© Copyright 2020, Andrew Lee. Licensed with GPL-3.0.')
+ .setColor('#0066ff')
+
+ msg.channel.send(helpEmbed);
}
if (command == 'ping') {
@@ -89,11 +97,12 @@ client.on('message', async msg => {
if (command == 'join') {
msg.reply('Joining voice channel.');
+ console.log('Connected to the voice channel.');
playAudio();
}
if (command == 'skip') {
- msg.reply("Skipping...")
+ msg.reply("Skipping `" + audio + "`...")
dispatcher.pause();
dispatcher = null
playAudio();