【发布时间】:2021-12-16 11:15:02
【问题描述】:
前几天,我开了一个关于bot message.content here的问题
现在,我希望机器人将同一文本中的两个单词替换为仅回复一条消息。
到目前为止,我有这个。
@client.event
async def on_message(message):
if message.author == client.user:
return
words = ['test', 'winter']
changes = ['nice', 'summer']
for word in words:
if word in message.content:
await message.channel.send(f"{message.content.replace(word, changes[words.index(word)])}")
await client.process_commands(message)
这是机器人所做的: here
由于某种原因,它只适用于其中一个词。
【问题讨论】:
标签: python discord discord.py bots