mirror of
https://github.com/hazemKrimi/discord-bot.git
synced 2026-05-01 18:30:25 +00:00
improved basic commands
This commit is contained in:
+6
-1
@@ -1,8 +1,13 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'join',
|
name: 'join',
|
||||||
description: 'joins a voice channel',
|
description: 'joins a voice channel',
|
||||||
execute: async (message, voiceChannel, args) => {
|
execute: async(message, args) => {
|
||||||
|
const voiceChannel = message.member.voice.channel;
|
||||||
|
|
||||||
if (!voiceChannel) return message.reply('you need to join a channel!');
|
if (!voiceChannel) return message.reply('you need to join a channel!');
|
||||||
|
|
||||||
connection = await voiceChannel.join();
|
connection = await voiceChannel.join();
|
||||||
|
|
||||||
|
return message.channel.send('joined!');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
+7
-1
@@ -1,7 +1,13 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'leave',
|
name: 'leave',
|
||||||
description: 'leaves a voice channel',
|
description: 'leaves a voice channel',
|
||||||
execute: async = (message, voiceChannel, args) => {
|
execute: async(message, args) => {
|
||||||
|
if (!message.member.voice.channel) return message.reply('you need to join a channel!');
|
||||||
|
|
||||||
|
const voiceChannel = message.member.voice.channel;
|
||||||
|
|
||||||
voiceChannel.leave();
|
voiceChannel.leave();
|
||||||
|
|
||||||
|
return message.channel.send('left!');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -18,14 +18,13 @@ client.on('message', async message => {
|
|||||||
|
|
||||||
const args = message.content.slice(process.env.PREFIX.length).split(/ +/);
|
const args = message.content.slice(process.env.PREFIX.length).split(/ +/);
|
||||||
const commandName = args.shift().toLowerCase();
|
const commandName = args.shift().toLowerCase();
|
||||||
const voiceChannel = message.member.voice.channel;
|
|
||||||
|
|
||||||
if (!client.commands.has(commandName)) return message.reply('this command does not exist!');
|
if (!client.commands.has(commandName)) return message.reply('this command does not exist!');
|
||||||
|
|
||||||
const command = client.commands.get(commandName);
|
const command = client.commands.get(commandName);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
command.execute(message, voiceChannel, args);
|
command.execute(message, args);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
message.reply('there was an error trying to execute that command!');
|
message.reply('there was an error trying to execute that command!');
|
||||||
|
|||||||
Reference in New Issue
Block a user