我发送邮件后,Discord.py bot继续在dm上发送垃圾邮件

时间:2020-08-25 14:33:47

标签: python discord.py

尝试创建dm mod邮件机器人,并在我发送邮件时不停地发送相同的邮件。

代码:

def check(message):
    return message.author

@bot.event
async def on_message(message):
  await bot.process_commands(message)
  await bot.wait_for('message', check=check)
  await message.channel.send("Thanks for your message! Our staff team will reply to you as soon as possible.",delete_after=10)
  if message.author.bot:
    breakpoint
    e=bot.get_channel(746784415086149662)
    await e.send(f"**{message.author}**\n"
    f"{message.content}\n")

图片:

image

1 个答案:

答案 0 :(得分:2)

确保消息的作者不是机器人本身还是其他机器人:

def check(message):
    return message.author

@bot.event
async def on_message(message):
  if message.author.bot:
    return
  await bot.process_commands(message)
  await bot.wait_for('message', check=check)
  await message.channel.send("Thanks for your message! Our staff team will reply to you as soon as possible.",delete_after=10)
  if not message.author.bot:
    e=bot.get_channel(746784415086149662)
    await e.send(f"**{message.author}**\n"
    f"{message.content}\n")

您有breakpoint不会退出该功能。