@client.event
async def on_message(message):
all_data = ""
if len(message.embeds) > 0:
for embed in message.embeds: #loop through all embeds in the message
try: #I use try and except for every, because when the field is empty, TypeError is raised.
all_data = all_data + embed.description #get embed description
except TypeError:
pass
try:
all_data = all_data + embed.title #get embed title
except TypeError:
pass
for field in embed.fields: #loop through each field
try:
all_data = all_data + field.value #get value of field
except TypeError:
pass
try:
all_data = all_data + field.name #get name of field
except TypeError:
pass
if "Diona" in all_data: #test if Diona is in any of the data we got
await message.add_reaction(emoji)
if "Diona" in message.content:
await message.add_reaction(emoji)
您可以通过循环
message.embeds
和循环所有字段来获取Embeddes内容,获得标题和描述:参考文献:
相关问题 更多 >
编程相关推荐