在 discord.py 中访问成员的横幅

Accessing a member#39;s banner in discord.py(在 discord.py 中访问成员的横幅)
本文介绍了在 discord.py 中访问成员的横幅的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我正在制作图像配置文件命令.我想为此访问会员的横幅.有什么方法可以在 discord.py 中做到这一点?

I am making an image profile command. I would like to access the member's banner for this. Is there any way we can do that in discord.py?

如果不清楚我所说的横幅是什么意思,那么带有蓝色背景的图像就是横幅.我想访问它.

If it is not clear what i mean by banner then, the image with the blue background is the banner. I would like to access that.

推荐答案

discord.py v2.0可以使用

In discord.py v2.0 you can use

# You may have to re-fetch the user for the banner to work properly
user = await bot.fetch_user(user.id)
banner_url = user.banner.url # The URL of the banner

在v2.0之前,有一种hacky方式可以直接使用API获取banner

Before v2.0, there is a hacky way to get the banner by directly using the API

req = await bot.http.request(discord.http.Route("GET", "/users/{uid}", uid=user.id))
banner_id = req["banner"]
if banner_id:
    banner_url = f"https://cdn.discordapp.com/banners/{user.id}/{banner_id}?size=1024"
else:
    # The user doesn't have a banner, do what you want
    # In many forks, User.accent_color exists so you
    # may want to check if your library supports that first
    pass

要安装 discord.py v2.0,您应该运行

To install discord.py v2.0 you should run

pip install -U git+https://github.com/Rapptz/discord.py

这篇关于在 discord.py 中访问成员的横幅的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)
Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)