pycord icon indicating copy to clipboard operation
pycord copied to clipboard

User status affects banner retrieval

Open TjMatBTW opened this issue 5 years ago • 5 comments

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 main() File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord_main.py", line 297, in main args.func(parser, args) File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord_main.py", line 52, in core show_version() File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord_main_.py", line 41, in show_version pkg = pkg_resources.get_distribution('pycord') File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\pkg_resources_init_.py", line 466, in get_distribution dist = get_provider(dist) File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\pkg_resources_init_.py", line 342, in get_provider return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0] File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\pkg_resources_init_.py", line 886, in require needed = self.resolve(parse_requirements(requirements)) File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\pkg_resources_init_.py", line 772, in resolve raise DistributionNotFound(req, requirers) pkg_resources.DistributionNotFound: The 'pycord' distribution was not found and is required by the application

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

TjMatBTW avatar Oct 02 '21 15:10 TjMatBTW

As stated in the docs, banners are only available via bot.fetch_user.

Dorukyum avatar Oct 02 '21 16:10 Dorukyum

Will that be changed in the future?

TjMatBTW avatar Oct 02 '21 16:10 TjMatBTW

That's likely a discord limitation so no.

BobDotCom avatar Oct 02 '21 17:10 BobDotCom

Just use fetch_user as a fallback if the user doesnt have a banner the first time.

BobDotCom avatar Oct 02 '21 17:10 BobDotCom

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.

TjMatBTW avatar Oct 04 '21 17:10 TjMatBTW