在 discord.py 中访问成员的横幅
- 作者: 曰邢一珊闺蜜
- 来源: 51数据库
- 2023-02-10
问题描述
我正在制作图像配置文件命令.我想为此访问会员的横幅.有什么方法可以在 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(重写)on_member_update 无法正常工作
0
Discord.py 在 vc 中获取用户分钟数
0
discord.py 重写 |为我的命令出错
0
Discord.py rewrite 如何 DM 命令?
0
播放音频时,最后一部分被切断.如何解决这个问题?(discord.py)
0
在消息删除消息 Discord.py
0
如何使 discord.py 机器人私人/直接消息不是作者的人?
0
(Discord.py) 如何获取整个嵌入内容?
0
Discord bot 尽管获得了许可,但不能提及所有人
0
Discord.py discord.NotFound 异常
0