mirror of
https://github.com/hazemKrimi/discord-bot.git
synced 2026-05-01 18:30:25 +00:00
improved the stop command
This commit is contained in:
+24
-6
@@ -1,4 +1,5 @@
|
|||||||
const { Command } = require('discord.js-commando');
|
const { Command } = require('discord.js-commando');
|
||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
|
||||||
module.exports = class Play extends Command {
|
module.exports = class Play extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -15,13 +16,30 @@ module.exports = class Play extends Command {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
run = message => {
|
run = async message => {
|
||||||
if (!message.member.voice.channel) return message.reply('you need to join a channel!');
|
try {
|
||||||
|
if (!message.member.voice.channel) {
|
||||||
|
const embed = new MessageEmbed().setColor('#ff0000').setTitle(':x: You need to join a voice channel first');
|
||||||
|
return await message.say({ embed });
|
||||||
|
}
|
||||||
|
else if (!message.guild.music.isPlaying) {
|
||||||
|
const embed = new MessageEmbed().setColor('#ff0000').setTitle(':x: Play something first');
|
||||||
|
return message.say({ embed });
|
||||||
|
}
|
||||||
|
else {
|
||||||
const voiceChannel = message.member.voice.channel;
|
const voiceChannel = message.member.voice.channel;
|
||||||
|
message.guild.music.queue = [];
|
||||||
|
message.guild.music.isPlaying = false;
|
||||||
|
message.guild.music.nowPlaying = null;
|
||||||
|
message.guild.music.dispatcher = null;
|
||||||
voiceChannel.leave();
|
voiceChannel.leave();
|
||||||
|
const embed = new MessageEmbed().setColor('#000099').setTitle(':stop_button: Stopped player and cleared queue');
|
||||||
return message.say('stopped!');
|
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 });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user