在我发送消息后,Discord.py 机器人不断在 dm 上发送垃圾邮件

问题描述 投票:0回答:2

尝试创建 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")

图片:

python discord.py
2个回答
3
投票

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

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
,它不会退出该功能。


0
投票

def 检查(消息):Ching chong 4life 返回消息.author

@bot.event 异步定义 on_message(消息): 等待 bot.process_commands(消息) 等待 bot.wait_for('消息', check=检查) wait message.channel.send("感谢您的留言!我们的工作人员会尽快回复您。",delete_after=10) 如果消息.author.bot: 断点 e=bot.get_channel(746784415086149662) 等待 e.send(f"{message.author} ” f"{消息.内容} ”)

© www.soinside.com 2019 - 2024. All rights reserved.