【发布时间】:2021-10-23 21:07:47
【问题描述】:
我希望我的 Discord Python 机器人复制并发送一条我写的但在消息中包含经过编辑的内容的消息。
例如,如果机器人在消息中找到单词“test”(例如 Google 链接 https://www.google.com/search?q=test),那么我希望机器人只编辑消息中的“test”并将其更改为例如。 "nice123" (https://www.google.com/search?q=nice123)
到目前为止,我有这个用于消息编辑 -
@client.event
async def on_message(message):
words = ['test']
for word in words:
if word in message.content:
await message.channel.send("nice123")
这是复制部分-
@client.event
async def on_message(message):
if message.author == client.user:
return
但我有点纠结于如何将这两者合二为一,以便复制、编辑和发回。
【问题讨论】:
-
您不能有多个
on_message事件。您是否尝试在回答部分使用message.content?
标签: python discord discord.py bots