From 0ef3c83f4049227c08731e3f31e53c38e1da5957 Mon Sep 17 00:00:00 2001 From: Indrajith K L Date: Sat, 19 Jun 2021 18:30:58 +0530 Subject: * Radio Bot Implementation --- src/commands/radioStop.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/commands/radioStop.js (limited to 'src/commands/radioStop.js') diff --git a/src/commands/radioStop.js b/src/commands/radioStop.js new file mode 100644 index 0000000..8d5786d --- /dev/null +++ b/src/commands/radioStop.js @@ -0,0 +1,23 @@ +const { VoiceChannel, TextChannel } = require("discord.js"); + +async function stopRadioBroadcast(client, args, message, voiceChannel, textChannel) { + if (voiceChannel) { + await voiceChannel.leave(); + textChannel.send('RADIO Stopped'); + } +} + +module.exports = { + async execute(client, message, args) { + const { RADIO_CHANNEL, NOW_PLAYING_CHANNEL } = process.env; + if (!RADIO_CHANNEL) return message.reply(`Please add RADIO_CHANNEL to .env with a Voice Channel ID`); + if (!NOW_PLAYING_CHANNEL) return message.reply(`Please add NOW_PLAYING_CHANNEL to .env with a Text Channel ID`); + + const voiceChannel = await client.channels.fetch(process.env.RADIO_CHANNEL); + const nowPlayingChannel = await client.channels.fetch(process.env.NOW_PLAYING_CHANNEL); + if (!(voiceChannel instanceof VoiceChannel)) return message.reply(`Please provice a Voice Channel ID to the RADIO_CHANNEL`); + if (!(nowPlayingChannel instanceof TextChannel)) return message.reply(`Please provice a Text Channel ID to the NOW_PLAYING_CHANNEL`); + + stopRadioBroadcast(client, args, message, voiceChannel, nowPlayingChannel); + } +} \ No newline at end of file -- cgit v1.2.3