gpt4 book ai didi

python - 从设置的用户获取个人资料图片

转载 作者:太空宇宙 更新时间:2023-11-04 02:21:47 26 4
gpt4 key购买 nike

我想让我的机器人用硬编码的用户个人资料图片回复我的命令。

这是我目前拥有的代码,因为它使用 message.author 的 pfp 进行回复,我想知道是否以及如何替换 user = message.author使其以硬编码用户为目标。

if message.content.upper().startswith('TEST'):
userID = message.author.id
user = message.author
pfp = user.avatar_url
embed = discord.Embed(
title="test",
description='<@%s>, test' % (userID),
color=0xecce8b
)
embed.set_image(url=pfp)

await client.send_message(message.channel, embed=embed) `

我也知道,如果我切换到“for user in message.mentions”,我可以让它弹出提到的用户的 pfp,但同样,我希望能够在不提及任何人的情况下做到这一点。

感谢您抽出宝贵时间和提出的任何答案!

最佳答案

您可以使用 Server.get_member解析您拥有其 ID 的 Member

if message.content.upper().startswith('TEST'):
user = message.server.get_member("116273596605049942") # Fake snowflake, will not work
if not user:
return # Can't find the user, then quit
pfp = user.avatar_url
embed=discord.Embed(title="test", description='{}, test'.format(user.mention) , color=0xecce8b)
embed.set_image(url=(pfp))
await client.send_message(message.channel, embed=embed)

关于python - 从设置的用户获取个人资料图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51423859/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com