python - 如何获取发消息人的头像url?

标签 python python-3.x discord discord.py

如何从上下文中获取发送命令的人的头像 URL?

@client.command()
async def test(ctx):
    print("Username is = " + ctx.message.author)
    print(ctx.message.author + "'s avatar url is = " )

如你所见,我可以轻松地从上下文中获取作者,但如何获取他们的头像图片?

我已经看到了解决方案,但它不是来自上下文

最佳答案

要获取作者的头像网址,只需使用ctx.message.author.avatar_url

@client.command()
async def test(ctx):
    print("Username is = " + ctx.message.author)
    print(ctx.message.author + "'s avatar url is = " + ctx.message.author.avatar_url)

关于python - 如何获取发消息人的头像url?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58470003/

相关文章:

python - 我们可以在 Beautifulsoup 中将所有 XML 标签转换为小写吗

python - 在 Windows 7x64 上从 Python3.x 调用 Matlab2013

python - 将 html 数据从网站转换为 pandas 数据框

javascript - Discord.js 删除命令消息

python - 如何在 Django REST 中使用序列化程序创建具有嵌套项的对象

python - Pandas GroupBy String 连接列名而不是列值

python - 实现 alpha-beta 修剪算法时函数中的奇怪行为

python - 如何使用discord.py 获取discord 用户的用户ID

python - 使用Python打印400空消息代码中的变量输出

python - 及时格式化为小数点后 3 位数字