python - 我发送消息后,Discord.py bot 不断在 dm 上发送垃圾邮件
问题描述
尝试创建一个 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")
图片:
解决方案
确保消息的作者不是机器人本身或其他机器人:
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
哪个不会退出该功能。
推荐阅读
- cordova - cordova 支持 OS X 的 localStorage 吗?
- html - eclipse标签位置无效(ol)警告
- javascript - 在 D3.js 中转换时的圆形离开轨迹
- python - 我可以从 Python 触发在 KV 文件中创建的屏幕吗?
- python - 如何按计数超过整个工作表中特定值的值过滤数据框?
- php - 为搜索页面过滤器添加自定义 css 类
- java - C++ 调用 Java 函数以使用 JNI 获取 JavaClassObject 数组
- batch-file - 如何启动 pgadmin4 并在 windows cmd 中打开一个 sql 文件?
- python - 从python发送电子邮件时获取'float'对象没有属性'encode'
- javascript - 仅在第一次按下按钮时才反应增量项目计数