[英]How to fix a bug in the catch function Discord.js
I am making a code to ban, and I encountered such a problem that the bot does not stop playing the code我正在制作一个禁止的代码,我遇到了bot不停止播放代码的问题
code代码
message.guild.members.ban(args[0]).catch(err => {
if (err.code === 10013) return message.channel.send({ embeds: [new MessageEmbed().setTitle('Oh no!').setDescription('No user').setColor('ff3333')]})
if (err.code === 50035) return message.channel.send({ embeds: [new MessageEmbed().setTitle('Oh no!').setDescription('No user').setColor('ff3333')]})
})
message.reply({ embeds: [new MessageEmbed().setTitle('Ban').setDescription(`User - <@${args[0]}> ban\nMod - ${message.author}\nReson - ${args.slice(1).join(' ')}`)] })
( Decided ) (决定)
message.guild.members.ban(args[0]).then(banu => {
message.reply({ embeds: [new MessageEmbed().setTitle('Ban').setDescription(`User - ${banu} ban\Mod - ${message.author}\nReson - ${args.slice(1).join(' ')}`)] })
}).catch(err => {
if (err.code === 10013) return message.channel.send({ embeds: [new MessageEmbed().setTitle('Oh no!').setDescription('No user').setColor('ff3333')]})
if (err.code === 50035) return message.channel.send({ embeds: [new MessageEmbed().setTitle('Oh no!').setDescription('No user').setColor('ff3333')]})
})```
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.