on_command_error重复消息

时间:2019-03-06 05:17:23

标签: python discord discord.py discord.py-rewrite

我有这个事件来捕捉错误

const arr = [
{item: 'Jelly Beans', areaCode: 321, Company: "Bob's Candy"},
{item: 'Skittles', areaCode: 444, Company: "Jim's Candy"},
{item: 'Snickers', areaCode: 321, Company: "Bob's Candy"},
{item: 'M&Ms', areaCode: 444, Company: "Jim's Candy"},
{item: 'Gummy Bears', areaCode: 123, Company: "Sally's Candy"}];

const res = Object.values(arr.reduce((acc, {item, areaCode, Company}) => {
  if(areaCode in acc) {
    acc[areaCode].item.push(item);
  } else {
    acc[areaCode] = {item: [item], areaCode, Company};
  };
  
  return acc;
}, {}));

console.log(res);

当事件捕获错误时,它将继续发送两次相同的消息。 例如,它将发送 #channel_name不是NSFW频道

我正在使用discord.py的重写分支

非常感谢您的帮助

1 个答案:

答案 0 :(得分:0)

@bot.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.CommandNotFound):
        await ctx.send("**Invalid command. Try using** `help` **to figure out commands!**")
    if isinstance(error, commands.MissingRequiredArgument):
        await ctx.send('**Please pass in all requirements.**')
    if isinstance(error, commands.MissingPermissions):
        await ctx.send("**You dont have all the requirements or permissions for using this command :angry:**")