Skip to main content

User

Represents a Discord user.

Attributes

id
int
The user’s unique ID.
name
str
The user’s username.
discriminator
str
The user’s discriminator. This is given when the username has conflicts.
If the user has migrated to the new username system, this will always be “0”.
global_name
str | None
The user’s global name.
bot
bool
Specifies if the user is a bot account.
system
bool
Specifies if the user is a system user (i.e. represents Discord officially).
avatar
Asset | None
Returns an Asset for the avatar the user has. If the user does not have a traditional avatar, None is returned.
default_avatar
Asset
Returns the default avatar for a given user. This is calculated by the user’s ID if they’re on the new username system, otherwise their discriminator.
display_avatar
Asset
Returns the user’s display avatar. For regular users this is just their default avatar or uploaded avatar.
banner
Asset | None
Returns the user’s banner asset, if available.
This information is only available via Client.fetch_user().
accent_colour
Colour | None
Returns the user’s accent colour, if applicable. Aliased to accent_color.
This information is only available via Client.fetch_user().
display_name
str
Returns the user’s display name. This will be their global name if set, otherwise their username.
mention
str
Returns a string that allows you to mention the given user.
created_at
datetime
Returns the user’s creation time in UTC. This is when the user’s Discord account was created.
public_flags
PublicUserFlags
The publicly available flags the user has.
jump_url
str
Returns a URL that allows the client to jump to the user.
dm_channel
DMChannel | None
Returns the channel associated with this user if it exists. If this returns None, you can create a DM channel by calling the create_dm() coroutine function.
mutual_guilds
list[Guild]
The guilds that the user shares with the client.
This will only return mutual guilds within the client’s internal cache.

Methods

Sends a message to the user in a DM channel.
content
str
The content of the message to send.
embed
Embed
The rich embed for the content.
file
File
The file to upload.
view
View
A Discord UI View to add to the message.
Returns: Message - The message that was sent.Example:
await user.send("Hello!")
Creates a DMChannel with this user.
This should be rarely called, as this is done transparently for most people.
Returns: DMChannel - The channel that was created.Example:
dm_channel = await user.create_dm()
await dm_channel.send("DM message")
Checks if the user is mentioned in the specified message.
message
Message
required
The message to check if you’re mentioned in.
Returns: bool - Indicates if the user is mentioned in the message.Example:
if user.mentioned_in(message):
    print(f"{user.name} was mentioned")
Checks whether the user is already migrated to global name.Returns: bool - True if the user has migrated to the new username system.Example:
if user.is_migrated():
    print(f"User {user.name} has migrated")

ClientUser

Represents your Discord user (the bot’s user account).

Additional Attributes

verified
bool
Specifies if the user’s email is verified.
locale
str | None
The IETF language tag used to identify the language the user is using.
mfa_enabled
bool
Specifies if the user has MFA turned on and working.

Additional Methods

Edits the current profile of the client.
To upload an avatar or banner, a bytes-like object must be passed in that represents the image being uploaded.
username
str
The new username you wish to change to.
avatar
bytes
A bytes-like object representing the image to upload. Could be None to denote no avatar.
banner
bytes
A bytes-like object representing the image to upload. Could be None to denote no banner.
Returns: ClientUser - The newly edited client user.Example:
with open('avatar.png', 'rb') as f:
    avatar = f.read()
await client.user.edit(avatar=avatar)

Build docs developers (and LLMs) love