diff --git a/commands/music/join.js b/commands/music/join.js index 03a7f83..8af98e7 100644 --- a/commands/music/join.js +++ b/commands/music/join.js @@ -1,4 +1,5 @@ const { Command } = require('discord.js-commando'); +const { MessageEmbed } = require('discord.js'); module.exports = class JoinCommand extends Command { constructor(client) { @@ -17,12 +18,21 @@ module.exports = class JoinCommand extends Command { } run = async message => { - const voiceChannel = message.member.voice.channel; + try { + const voiceChannel = message.member.voice.channel; - if (!voiceChannel) return message.reply('you need to join a channel!'); + if (!voiceChannel) { + const embed = new MessageEmbed().setColor('#ff0000').setTitle(':x: You need to join a voice channel first'); + return await message.say({ embed }); + } - await voiceChannel.join(); - - return message.say('joined!'); + await voiceChannel.join(); + const embed = new MessageEmbed().setColor('#000099').setTitle('Joined'); + return await message.say({ embed }); + } catch(err) { + console.error(err); + const embed = new MessageEmbed().setColor('#ff0000').setTitle(':x: Error occured, if you are my creator please fix me soon'); + return message.say({ embed }); + } } } \ No newline at end of file diff --git a/commands/music/leave.js b/commands/music/leave.js index 6c9d668..8897716 100644 --- a/commands/music/leave.js +++ b/commands/music/leave.js @@ -1,4 +1,5 @@ const { Command } = require('discord.js-commando'); +const { MessageEmbed } = require('discord.js'); module.exports = class Leave extends Command { constructor(client) { @@ -15,13 +16,26 @@ module.exports = class Leave extends Command { }); } - run = message => { - if (!message.member.voice.channel) return message.reply('you need to join a channel!'); + run = async message => { + try { + const voiceChannel = message.member.voice.channel; - const voiceChannel = message.member.voice.channel; + if (!voiceChannel) { + const embed = new MessageEmbed().setColor('#ff0000').setTitle(':x: You need to join a voice channel first'); + return await message.say({ embed }); + } - voiceChannel.leave(); - - return message.say('left!'); + message.guild.music.queue = []; + message.guild.music.isPlaying = false; + message.guild.music.nowPlaying = null; + message.guild.music.dispatcher = null; + const embed = new MessageEmbed().setColor('#000099').setTitle('Left'); + voiceChannel.leave(); + return await message.say({ embed }); + } catch (err) { + console.error(err); + const embed = new MessageEmbed().setColor('#ff0000').setTitle(':x: Error occured, if you are my creator please fix me soon'); + return message.say({ embed }); + } } } \ No newline at end of file