使用Discord.py,有没有办法读取嵌入式消息? [英] With Discord.py, is there a way to read embedded messages?

查看:92
本文介绍了使用Discord.py,有没有办法读取嵌入式消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码打印出用户发送的消息。但是,当发送嵌入式消息时,终端上什么也没有,也什么也没读。

My code print out the message the user sends. However, when an embedded message gets sent, there is nothing on the terminal and nothing is read.

我的机器人有没有办法在不和谐的情况下读取嵌入式消息和普通消息

Is there a way for my bot to read embedded messages along with normal messages on discord

Python 3.8

Python 3.8

client = discord.Client()

@client.event
async def on_message(message):
    print(message.content)

client.run(token)


推荐答案

您可以使用 message.embeds 文档链接。尝试以下解决方案:

You can get list of embeds from message with message.embeds. Link for docs. Try this solution:

@client.event
async def on_message(message):
    embeds = message.embeds # return list of embeds
    for embed in embeds:
        print(embed.to_dict()) # it's content of embed in dict

PS如果您的邮件有一个嵌入,则可以使用: embed_content_in_dict = message.embeds [0] .to_dict()

P.S. If your message has one embed you can use: embed_content_in_dict = message.embeds[0].to_dict()

这篇关于使用Discord.py,有没有办法读取嵌入式消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆