繁体   English   中英

有没有办法在嵌入 discord.py 中读取特定字段的值

[英]Is there a way to read a value of a specific field in an embed discord.py

嵌入

所以我在图片中有一个嵌入,我想从那个嵌入中获取用户 ID,有什么办法吗?

到目前为止我尝试了什么:

set_field_at()是一个 function 将更新字段的内容。 您将无法使用此方法检索内容。

您仍然可以使用.fields 您可以在您选择的方法中放入类似于以下内容的内容。

embed = # Put the Embed in the picture as a discord.Embed object and assign it to this variable
for field in embed.fields: # Dynamically get the user id field.
    if field.name.lower() == "user id": # I recommend copying and pasting the field of choice, just in case the characters are not the same visually.
        user_id_field = field
        break
else: # In case the field isn't found
    pass # Put some code here
user_id = int(user_id_field.value) # Get the value of the field
# Either send or print it

参考:

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM