Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Getting user info in a DM doesn't work #46

Closed
ghost opened this issue Jun 21, 2021 · 7 comments
Closed

[BUG] Getting user info in a DM doesn't work #46

ghost opened this issue Jun 21, 2021 · 7 comments
Labels
unconfirmed bug Unconfirmed bug

Comments

@ghost
Copy link

ghost commented Jun 21, 2021

Summary

A simple summary of the bug.

Whenever I try to get the avatar_url of a user in a DM it returns the default discord profile picture, and if I try to get the name of the user it returns 'None'

Reproduction Steps

How did you make it happen?
  1. Go into a DM
  2. Run:
  3. Try to get a user's name/avatar

Code

Relevant code that shows the bug.
@Client.command()
async def test(Context, User: discord.User):
	print(User.avatar_url)
	print(User.name)

Expected Results

What is supposed to happen?

Returns the user's correct tag and avatar

Actual Results

What is currently happening?

Returns 'None' as the user's name and the default discord profile picture as their avatar

System Info

Run python -m discord --version and paste the information below.
- Python v3.9.5-final
- discord.py v1.8.1-final
- aiohttp v3.7.4.post0
- system info: Windows 10 10.0.19041

Checklist

Let's make sure this issue is valid!
  • [ x ] I am using the latest released version of the library.
  • [ x ] I am using a user token.
  • [ x ] I have shown the entire traceback and exception information.
  • [ x ] I've removed my token from any code.

Additional Information

Put any extra context, weird configurations, or other important info here.
@ghost ghost added the unconfirmed bug Unconfirmed bug label Jun 21, 2021
@Ceres445
Copy link

How are you using the command? !test @user?

@caiocinel
Copy link

caiocinel commented Jun 22, 2021

I also noticed this problem, but I managed to solve it by getting the context information.

*This is far from ideal, but it worked until the next release came out, which should probably fix the problem.

https://github.com/caiocinel/Selfium/blob/main/app/events/client/commands/avatar.py

@ghost
Copy link
Author

ghost commented Jun 22, 2021

How are you using the command? !test @user?

Yes

@ghost
Copy link
Author

ghost commented Jun 22, 2021

I also noticed this problem, but I managed to solve it by getting the context information.

*This is far from ideal, but it worked until the next release came out, which should probably fix the problem.

https://github.com/caiocinel/Selfium/blob/main/app/events/client/commands/avatar.py

OK, thanks, I'll try this out

@ghost
Copy link
Author

ghost commented Jun 22, 2021

I also noticed this problem, but I managed to solve it by getting the context information.

*This is far from ideal, but it worked until the next release came out, which should probably fix the problem.

https://github.com/caiocinel/Selfium/blob/main/app/events/client/commands/avatar.py

Your way still isn't working for me
My command:

@Client.command()
async def test123(ctx):

	async def byMember(member):
		if hasattr(member, 'id'):
			targetId = int(member.id)
		else:
			targetId = member.author.id

		return await byID(targetId)

	async def byID(id):
		target = await Client.fetch_user(int(id))
		return target

	if(ctx.message.mentions):
		target = ctx.message.mentions
	else:
		target = ctx.args

	try:
		for t in range(len(target)):
			memberFetch = await byMember(target[t])
			embed = discord.Embed(colour=discord.Colour.green())
			embed.set_author(name=f"🖼️ Here's {memberFetch.display_name} profile picture", url=f"{memberFetch.avatar_url.BASE + memberFetch.avatar_url._url}")
			embed.set_image(url=memberFetch.avatar_url.BASE + memberFetch.avatar_url._url)
			await ctx.send(embed=embed)
	except:
		print('not found')

Hope it's not a stupid mistake on my part

@caiocinel
Copy link

caiocinel commented Jun 22, 2021

Your code worked perfectly in my tests (although it might be better structured), set some breakpoints and see what happens.

image

@ghost
Copy link
Author

ghost commented Jun 22, 2021

Your code worked perfectly in my tests (although it might be better structured), set some breakpoints and see what happens.

image

Using the development version fixed it for me. Works using your method and the normal method. Thanks for the help

@ghost ghost closed this as completed Jun 22, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unconfirmed bug Unconfirmed bug
Projects
None yet
Development

No branches or pull requests

2 participants