aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@protonmail.com>2020-12-23 19:42:15 -0500
committerAndrew Lee <alee14498@protonmail.com>2020-12-23 19:42:15 -0500
commitf642655034423902d06549179b9491726daa1980 (patch)
treeb614cf6013eaa62d32474ec41e6b92adc4325d20
parent07c35df0621344840b9f58c73b086526b5982095 (diff)
downloadDLAP-old-version.tar.gz
DLAP-old-version.tar.bz2
DLAP-old-version.zip
Now it should say nothing for textold-version
-rw-r--r--bot.js16
1 files changed, 14 insertions, 2 deletions
diff --git a/bot.js b/bot.js
index c34e4dc..1883f21 100644
--- a/bot.js
+++ b/bot.js
@@ -25,6 +25,7 @@ const config = require('./config.json');
let dispatcher;
let audio;
let voiceChannel;
+let fileData;
bot.login(config.token);
@@ -47,8 +48,8 @@ function playAudio() {
dispatcher.on('start', () => {
console.log('Now playing ' + audio);
- let data = "Now Playing: " + audio;
- fs.writeFile("now-playing.txt", data, (err) => {
+ fileData = "Now Playing: " + audio;
+ fs.writeFile("now-playing.txt", fileData, (err) => {
if (err)
console.log(err);
});
@@ -171,12 +172,23 @@ bot.on('message', async msg => {
if (!voiceChannel) return console.error('The voice channel does not exist!\n(Have you looked at your configuration?)');
msg.reply('Leaving voice channel.');
console.log('Leaving voice channel.');
+ fileData = "Now Playing: Nothing";
+ fs.writeFile("now-playing.txt", fileData, (err) => {
+ if (err)
+ console.log(err);
+ });
+ audio = "Not Playing";
dispatcher.destroy();
voiceChannel.leave();
}
if (command == 'stop') {
await msg.reply('Powering off...');
+ fileData = "Now Playing: Nothing";
+ await fs.writeFile("now-playing.txt", fileData, (err) => {
+ if (err)
+ console.log(err);
+ });
const statusEmbed = new Discord.MessageEmbed()
.setAuthor(`${bot.user.username}`, bot.user.avatarURL())
.setDescription(`That\'s all folks! Powering down ${bot.user.username}...`)