我正在制作图像配置文件命令。我想为此访问会员的横幅。我们有什么办法可以在discord.py 中做到这一点吗?
如果不清楚我所说的横幅是什么意思,那么蓝色背景的图像就是横幅。我想访问它。
在discord.py v2.0中你可以使用
# 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之前,有一种直接使用API获取横幅的hacky方法
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,您应该运行
pip install -U git+https://github.com/Rapptz/discord.py
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)