Skip to content

feat: make Member.avatar_url pull from server profile avatar #1652

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

Merged

Conversation

mifuyutsuki
Copy link
Contributor

Pull Request Type

  • Feature addition
  • Bugfix
  • Documentation update
  • Code refactor
  • Tests improvement
  • CI/CD pipeline enhancement
  • Other: [Replace with a description]

Description

Currently, Member.avatar_url (if there is any, e.g. from SlashContext) would return the member's global avatar. This PR makes avatar_url pull the member's server avatar instead, in line with the documentation for display_avatar, where the BaseUser counterpart pulls from (will return guild_avatar if one is set, otherwise return user avatar).

Commit says fix but this PR is marked as feat in case this turns out to be a breaking change.

Changes

  • Explicitly add property avatar_url into Member, identical to the BaseUser counterpart

Related Issues

Test Scenarios

Requires a Nitro user with a server avatar different from the global avatar.

from interactions import Client, slash_command, SlashContext

@slash_command(name="test", description="Test command")
async def test_cmd(ctx: SlashContext):
  await ctx.send(
    f"1: ctx.user.avatar_url (User): <{ctx.user.avatar_url}>\n"
    f"2: ctx.author.avatar_url (Member): <{ctx.author.avatar_url}>\n"
    f"3: ctx.user.display_avatar.url (User): <{ctx.user.display_avatar.url}>\n"
    f"4: ctx.author.display_avatar.url (Member): <{ctx.author.display_avatar.url}>"
  )

bot = Client()
bot.start("token")

Before:

  • Global avatar: (1) (2) (3)
  • Server avatar: (4)

After:

  • Global avatar: (1) (3)
  • Server avatar: (2) (4)

Python Compatibility

  • I've ensured my code works on Python 3.10.x
  • I've ensured my code works on Python 3.11.x

Checklist

  • I've run the pre-commit code linter over all edited files
  • I've tested my changes on supported Python versions
  • I've added tests for my code, if applicable
  • I've updated / added documentation, where applicable

@mifuyutsuki mifuyutsuki changed the title feat: make Member.avatar_url pull from server avatar feat: make Member.avatar_url pull from server profile avatar Apr 4, 2024
@silasary silasary merged commit f2becee into interactions-py:unstable Apr 24, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants