我正在尝试创建一个discord.py机器人,该机器人在每个带有on_message事件的消息中查找给定的关键字。尽管这对于普通文本非常有用,但我无法将其与嵌入的消息一起使用,这正是我所需要的。有什么办法吗?
答案 0 :(得分:1)
message.embeds
将为您提供Embed
对象的列表。您可以尝试类似
def check_all_message(check_for, message):
if check_for in message.content:
return True
for e in message.embeds:
if any(item and check_for in item for item in (e.title, e.footer, e.description)):
return True
if e.fields:
for field in e.fields:
if check_for in field.name or check_for in field.value:
return True
return False
@bot.event
async def on_message(message):
if message.author == bot.user:
return
if check_all_message("apple", message):
await bot.send_message(message.channel, 'You said "apple"!')