Skip to content

feat: add guild member banner field #1757

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
merged 1 commit into from
Mar 9, 2025

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

Discord has added a banner field to the Guild Member object, making it fetchable. This pull request exposes and adds the field to the library Member object.

Changes

  • Add attr guild_banner and property banner to Member
    • Behavior of banner is similar to display_avatar, defaulting to server banner before getting the global banner
    • Choice of name banner is for consistency with User
    • Edited user.pyi accordingly

Related Issues

#1674 (closed - predates API addition)

Test Scenarios

This creates a slash command /banner that fetches your banner (requires Nitro), if any.

from interactions import Client, slash_command, Embed

bot = Client()

@slash_command(name="banner", description="View your banner")
async def banner_cmd(ctx):
  e = Embed(f"Banner for {ctx.author.tag}")

  if ctx.author.banner:
    e.set_image(ctx.author.banner.url)
  else:
    e.description = "User has no banner."

  return await ctx.send(embed=e)

bot.start("token")

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

@silasary silasary merged commit 9048b93 into interactions-py:unstable Mar 9, 2025
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.

2 participants