我目前正在编写一个discord.js
机器人,我做了这个join
命令,所以机器人可以加入我的语音频道
module.exports.run = async (client, message, args) => {
let membervc = message.member.voice.channel;
let botvc = message.guild.me.voice.channel;
if(!membervc) return message.send('You need to join a voice channel first.');
if(botvc){
if(!(botvc.members.size - 1)) return message.reply(`I am already on ${botvc}`);
if(membervc.id == botvc.id) return message.reply('We are already on the same voice channel.');
};
membervc.join();
}
问题是我不知道如何制作它,以便如果最后一个函数出错或根本不起作用它可以向用户发送错误消息,例如
@User, I could not join the channel, "THE ERROR"
:/我不希望我的机器人崩溃并且仅仅因为一个小细节就不得不再次运行它。有没有办法解决它?这对我有很大帮助!提前致谢!