User status affects banner retrieval
Summary
If the user is offline, the banner retrieval is impossible
Reproduction Steps
I coded a simple banner retrieval code, similar to the avatar command. I made a check to check if the user had actually a banner and it works. However, if the desired user is offline, it will display as user that doesn't have a banner.
Minimal Reproducible Code
@commands.command(aliases=['ba'])
async def banner(self, ctx, user:discord.User = None):
if user is None:
user = ctx.author
if user.banner:
em = discord.Embed(title=user, timestamp=ctx.message.created_at)
em.set_image(url=user.banner.url)
em.set_footer(text=f'Requested by {ctx.author}', icon_url=ctx.author.avatar.url)
await ctx.send(embed=em)
else:
await ctx.send('That user does not have a banner.')
# Note: Somehow Indents broke, but they're good in my code
Expected Results
I expected it to always send the banner image if the desired user had one, and if the user didn't, it would send That user does not have a banner.
Actual Results
If the user is offline, it would always display the error That user does not have a banner.
Intents
Presence & Server Members.
System Information
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in run_module_as_main
return run_code(code, main_globals, None,
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord_main.py", line 300, in
Checklist
- [X] I have searched the open issues for duplicates.
- [X] I have shown the entire traceback, if possible.
- [X] I have removed my token from display, if visible.
Additional Context
No response
As stated in the docs, banners are only available via bot.fetch_user.
Will that be changed in the future?
That's likely a discord limitation so no.
Just use fetch_user as a fallback if the user doesnt have a banner the first time.
Just use fetch_user as a fallback if the user doesnt have a banner the first time.
I did that, it's actually the only way to circunvent this issue.