mirror of
https://github.com/hazemKrimi/discord-bot.git
synced 2026-05-02 02:30:29 +00:00
improved join and leave commands
This commit is contained in:
+15
-5
@@ -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 });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user