首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何修复catch函数Discord.js中的错误

如何修复catch函数Discord.js中的错误
EN

Stack Overflow用户
提问于 2022-07-05 17:33:37
回答 1查看 64关注 0票数 0

我正在制定一个禁止的代码,我遇到了这样一个问题,机器人没有停止播放代码。

代码

代码语言:javascript
运行
复制
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(' ')}`)] })

(已决定)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-07-14 11:46:41

代码语言:javascript
运行
复制
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')]})
        })```
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72873462

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档