Skip to content

Conversation

ooliver1
Copy link
Member

@ooliver1 ooliver1 commented Jun 25, 2025

Summary

This PR adds a non-None primary_guild property representing a user's "tag" as described in discord/discord-api-docs#6836.

When enabled is None, this is described in messages in the Discord Developers server as meaning the tag has been edited but not approved by the user. This hopefully will be mentioned in the Discord documentation when it is merged 🤞.

Forgive the member.py scope creep with avatar decoration data, spotted this needing to be edited too (could member cache updating be handled better?).

Test Code
import os
from typing import Optional

from dotenv import load_dotenv
from nextcord import Intents, Interaction, User
from nextcord.ext.commands import Bot

load_dotenv()

bot = Bot(intents=Intents(guilds=True, members=True, messages=True, message_content=True))

@bot.slash_command()
async def my_primary_guild(interaction: Interaction, user: Optional[User] = None):
    u = interaction.user if user is None else user
    assert u is not None

    await interaction.send(
        f"Your primary guild is {u.primary_guild.identity_guild_id}.\n"
        f"Identity enabled: {u.primary_guild.identity_enabled}\n"
        f"Tag: {u.primary_guild.tag}\n"
        f"Badge: {u.primary_guild.badge.url if u.primary_guild.badge else 'None'}"
    )

@bot.event
async def on_user_update(before, after):
    if before.primary_guild != after.primary_guild:
        print(
            f"User {before} primary guild changed from {before.primary_guild} to {after.primary_guild}"
        )

bot.run(os.environ["TOKEN"])

This is a Code Change

  • I have tested my changes.
  • I have updated the documentation to reflect the changes.
  • I have run task pyright and fixed the relevant issues.

@ooliver1 ooliver1 added t: api coverage Type: api coverage - this adds code to cover the discord API s: waiting for discord status: the issue requires changes to the documentation or behaviour before it can be completed. labels Jun 25, 2025
self._state, guild_id=self.identity_guild_id, badge_hash=self._badge
)
return None

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can get the creation date of the primary guild

Suggested change
@property
def created_at(self) -> Optional[datetime]:
"""Optional[:class:`datetime.datetime`]: Returns the primary guild's creation time in UTC."""
if self.identity_guild_id:
return snowflake_time(self.identity_guild_id)
return None

@ooliver1 ooliver1 removed the s: waiting for discord status: the issue requires changes to the documentation or behaviour before it can be completed. label Jul 2, 2025
@ooliver1 ooliver1 added p: high Priority: high - should be worked on as soon as reasonable s: awaiting review Status: the issue or PR is awaiting reviews labels Jul 2, 2025
@ooliver1 ooliver1 marked this pull request as ready for review July 2, 2025 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p: high Priority: high - should be worked on as soon as reasonable s: awaiting review Status: the issue or PR is awaiting reviews t: api coverage Type: api coverage - this adds code to cover the discord API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants