hikari.users#
Application and entities that are used to describe Users on Discord.
AvatarDecoration #
Data for an avatar decoration.
asset_hash class-attribute instance-attribute #
The hash of the asset.
expires_at class-attribute instance-attribute #
The datetime at which the user will no longer have access to the avatar decoration.
sku_id class-attribute instance-attribute #
The ID of the asset's SKU.
make_url #
make_url(
*,
file_format: UndefinedOr[
Literal["PNG", "JPEG", "JPG", "WEBP", "APNG"]
] = UNDEFINED,
size: int = 4096,
lossless: bool = True,
) -> URL
Generate the image URL for this avatar decoration.
| PARAMETER | DESCRIPTION |
|---|---|
file_format | The format to use for this URL. Supports If not specified, the format will be TYPE: |
size | The size to set for the URL; This is ignored for the TYPE: |
lossless | Whether to return a lossless or compressed WEBP image; This is ignored if TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
URL | The URL to the avatar decoration. |
| RAISES | DESCRIPTION |
|---|---|
TypeError | If an invalid format is passed for |
ValueError | If |
OwnUser #
Bases: UserImpl
Represents a user with extended OAuth2 information.
email class-attribute instance-attribute #
is_mfa_enabled class-attribute instance-attribute #
Whether the user's account has multi-factor authentication enabled.
is_verified class-attribute instance-attribute #
Whether the email for this user's account has been verified.
Will be None if retrieved through the OAuth2 flow without the email scope.
locale class-attribute instance-attribute #
The user's set locale.
This is not provided in the READY event.
premium_type class-attribute instance-attribute #
premium_type: PremiumType | int | None = attrs.field(
eq=False, hash=False, repr=False
)
The type of Nitro Subscription this user account had.
This will always be None for bots.
fetch_dm_channel async #
fetch_dm_channel() -> NoReturn
Fetch the DM channel for this user.
| RETURNS | DESCRIPTION |
|---|---|
DMChannel | The requested channel. |
| RAISES | DESCRIPTION |
|---|---|
UnauthorizedError | If you are unauthorized to make the request (invalid/missing token). |
NotFoundError | If the user is not found. |
RateLimitTooLongError | Raised in the event that a rate limit occurs that is longer than |
InternalServerError | If an internal error occurs on Discord while handling the request. |
fetch_self async #
fetch_self() -> OwnUser
Get this user's up-to-date object.
| RETURNS | DESCRIPTION |
|---|---|
OwnUser | The requested user object. |
| RAISES | DESCRIPTION |
|---|---|
UnauthorizedError | If you are unauthorized to make the request (invalid/missing token). |
RateLimitTooLongError | Raised in the event that a rate limit occurs that is longer than |
InternalServerError | If an internal error occurs on Discord while handling the request. |
send async #
send(
content: UndefinedOr[Any] = UNDEFINED,
*,
attachment: UndefinedOr[Resourceish] = UNDEFINED,
attachments: UndefinedOr[
Sequence[Resourceish]
] = UNDEFINED,
component: UndefinedOr[ComponentBuilder] = UNDEFINED,
components: UndefinedOr[
Sequence[ComponentBuilder]
] = UNDEFINED,
embed: UndefinedOr[Embed] = UNDEFINED,
embeds: UndefinedOr[Sequence[Embed]] = UNDEFINED,
nonce: UndefinedOr[str] = UNDEFINED,
tts: UndefinedOr[bool] = UNDEFINED,
reply: UndefinedOr[
SnowflakeishOr[PartialMessage]
] = UNDEFINED,
reply_must_exist: UndefinedOr[bool] = UNDEFINED,
mentions_everyone: UndefinedOr[bool] = UNDEFINED,
mentions_reply: UndefinedOr[bool] = UNDEFINED,
user_mentions: UndefinedOr[
SnowflakeishSequence[PartialUser] | bool
] = UNDEFINED,
role_mentions: UndefinedOr[
SnowflakeishSequence[PartialRole] | bool
] = UNDEFINED,
flags: UndefinedType | int | MessageFlag = UNDEFINED,
) -> NoReturn
Send a message to this user in DM's.
| PARAMETER | DESCRIPTION |
|---|---|
content | If provided, the message contents. If If this is a Likewise, if this is a TYPE: |
attachment | If provided, the message attachment. This can be a resource, or string of a path on your computer or a URL. Attachments can be passed as many different things, to aid in convenience.
TYPE: |
attachments | If provided, the message attachments. These can be resources, or strings consisting of paths on your computer or URLs. TYPE: |
component | If provided, builder object of the component to include in this message. TYPE: |
components | If provided, a sequence of the component builder objects to include in this message. TYPE: |
embed | If provided, the message embed. TYPE: |
embeds | If provided, the message embeds. TYPE: |
tts | If provided, whether the message will be read out by a screen reader using Discord's TTS (text-to-speech) system. TYPE: |
nonce | An arbitrary identifier to associate with the message. This can be used to identify it later in received events. If provided, this must be less than 32 bytes. If not provided, then a null value is placed on the message instead. All users can see this value. TYPE: |
reply | If provided, the message to reply to. TYPE: |
reply_must_exist | If provided, whether to error if the message being replied to does not exist instead of sending as a normal (non-reply) message. This will not do anything if not being used with TYPE: |
mentions_everyone | If provided, whether the message should parse @everyone/@here mentions. TYPE: |
mentions_reply | If provided, whether to mention the author of the message that is being replied to. This will not do anything if not being used with TYPE: |
user_mentions | If provided, and TYPE: |
role_mentions | If provided, and TYPE: |
flags | If provided, optional flags to set on the message. If Note that some flags may not be able to be set. Currently the only flags that can be set are TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
Message | The created message. |
| RAISES | DESCRIPTION |
|---|---|
ValueError | If more than 100 unique objects/entities are passed for |
TypeError | If both |
BadRequestError | This may be raised in several discrete situations, such as messages being empty with no attachments or embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; too many attachments; attachments that are too large; invalid image URLs in embeds; |
UnauthorizedError | If you are unauthorized to make the request (invalid/missing token). |
ForbiddenError | If you are missing the |
NotFoundError | If the user is not found. |
RateLimitTooLongError | Raised in the event that a rate limit occurs that is longer than |
InternalServerError | If an internal error occurs on Discord while handling the request. |
PartialUser #
A partial interface for a user.
Fields may or may not be present, and should be explicitly checked before using them to ensure they are not hikari.undefined.UNDEFINED.
This is used for endpoints and events that only expose partial user information.
For full user info, consider calling the hikari.users.PartialUser.fetch_self method to perform an API call.
accent_color abstractmethod property #
accent_color: UndefinedNoneOr[Color]
Custom banner color for the user if set, else None.
The official client will decide the default color if not set.
accent_colour property #
accent_colour: UndefinedNoneOr[Color]
Alias for the hikari.users.PartialUser.accent_color field.
avatar_decoration abstractmethod property #
avatar_decoration: UndefinedNoneOr[AvatarDecoration]
Avatar decoration for the user, if they have one, otherwise None.
avatar_hash abstractmethod property #
avatar_hash: UndefinedNoneOr[str]
Avatar hash for the user, if they have one, otherwise None.
banner_hash abstractmethod property #
banner_hash: UndefinedNoneOr[str]
Banner hash for the user, if they have one, otherwise None.
discriminator abstractmethod property #
discriminator: UndefinedOr[str]
Discriminator for the user.
!!! deprecated 2.0.0.dev120 Discriminators are deprecated and being replaced with "0" by Discord during username migration. This field will be removed after migration is complete. Learn more here: https://dis.gd/usernames
display_name property #
display_name: UndefinedNoneOr[str]
Return the user's display name.
Either users global name (if set) or its username.
global_name abstractmethod property #
global_name: UndefinedNoneOr[str]
Global name for the user, if they have one, otherwise None.
is_system abstractmethod property #
is_system: UndefinedOr[bool]
Whether this user is a system account.
mention abstractmethod property #
mention: str
Return a raw mention string for the given user.
Examples:
>>> some_user.mention
'<@123456789123456789>'
primary_guild abstractmethod property #
primary_guild: UndefinedNoneOr[PrimaryGuild]
The users primary guild tag.
fetch_dm_channel async #
fetch_dm_channel() -> DMChannel
Fetch the DM channel for this user.
| RETURNS | DESCRIPTION |
|---|---|
DMChannel | The requested channel. |
| RAISES | DESCRIPTION |
|---|---|
UnauthorizedError | If you are unauthorized to make the request (invalid/missing token). |
NotFoundError | If the user is not found. |
RateLimitTooLongError | Raised in the event that a rate limit occurs that is longer than |
InternalServerError | If an internal error occurs on Discord while handling the request. |
fetch_self async #
fetch_self() -> User
Get this user's up-to-date object by performing an API call.
| RETURNS | DESCRIPTION |
|---|---|
User | The requested user object. |
| RAISES | DESCRIPTION |
|---|---|
NotFoundError | If the user is not found. |
RateLimitTooLongError | Raised in the event that a rate limit occurs that is longer than |
InternalServerError | If an internal error occurs on Discord while handling the request. |
send async #
send(
content: UndefinedOr[Any] = UNDEFINED,
*,
attachment: UndefinedOr[Resourceish] = UNDEFINED,
attachments: UndefinedOr[
Sequence[Resourceish]
] = UNDEFINED,
component: UndefinedOr[ComponentBuilder] = UNDEFINED,
components: UndefinedOr[
Sequence[ComponentBuilder]
] = UNDEFINED,
embed: UndefinedOr[Embed] = UNDEFINED,
embeds: UndefinedOr[Sequence[Embed]] = UNDEFINED,
nonce: UndefinedOr[str] = UNDEFINED,
tts: UndefinedOr[bool] = UNDEFINED,
reply: UndefinedOr[
SnowflakeishOr[PartialMessage]
] = UNDEFINED,
reply_must_exist: UndefinedOr[bool] = UNDEFINED,
mentions_everyone: UndefinedOr[bool] = UNDEFINED,
mentions_reply: UndefinedOr[bool] = UNDEFINED,
user_mentions: UndefinedOr[
SnowflakeishSequence[PartialUser] | bool
] = UNDEFINED,
role_mentions: UndefinedOr[
SnowflakeishSequence[PartialRole] | bool
] = UNDEFINED,
flags: UndefinedType | int | MessageFlag = UNDEFINED,
) -> Message
Send a message to this user in DM's.
| PARAMETER | DESCRIPTION |
|---|---|
content | If provided, the message contents. If If this is a Likewise, if this is a TYPE: |
attachment | If provided, the message attachment. This can be a resource, or string of a path on your computer or a URL. Attachments can be passed as many different things, to aid in convenience.
TYPE: |
attachments | If provided, the message attachments. These can be resources, or strings consisting of paths on your computer or URLs. TYPE: |
component | If provided, builder object of the component to include in this message. TYPE: |
components | If provided, a sequence of the component builder objects to include in this message. TYPE: |
embed | If provided, the message embed. TYPE: |
embeds | If provided, the message embeds. TYPE: |
tts | If provided, whether the message will be read out by a screen reader using Discord's TTS (text-to-speech) system. TYPE: |
nonce | An arbitrary identifier to associate with the message. This can be used to identify it later in received events. If provided, this must be less than 32 bytes. If not provided, then a null value is placed on the message instead. All users can see this value. TYPE: |
reply | If provided, the message to reply to. TYPE: |
reply_must_exist | If provided, whether to error if the message being replied to does not exist instead of sending as a normal (non-reply) message. This will not do anything if not being used with TYPE: |
mentions_everyone | If provided, whether the message should parse @everyone/@here mentions. TYPE: |
mentions_reply | If provided, whether to mention the author of the message that is being replied to. This will not do anything if not being used with TYPE: |
user_mentions | If provided, and TYPE: |
role_mentions | If provided, and TYPE: |
flags | If provided, optional flags to set on the message. If Note that some flags may not be able to be set. Currently the only flags that can be set are TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
Message | The created message. |
| RAISES | DESCRIPTION |
|---|---|
ValueError | If more than 100 unique objects/entities are passed for |
TypeError | If both |
BadRequestError | This may be raised in several discrete situations, such as messages being empty with no attachments or embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; too many attachments; attachments that are too large; invalid image URLs in embeds; |
UnauthorizedError | If you are unauthorized to make the request (invalid/missing token). |
ForbiddenError | If you are missing the |
NotFoundError | If the user is not found. |
RateLimitTooLongError | Raised in the event that a rate limit occurs that is longer than |
InternalServerError | If an internal error occurs on Discord while handling the request. |
PartialUserImpl #
Bases: PartialUser
Implementation for partial information about a user.
This is pretty much the same as a normal user, but information may not be present, which will be denoted by hikari.undefined.UNDEFINED.
accent_color class-attribute instance-attribute #
accent_color: UndefinedNoneOr[Color] = attrs.field(
eq=False, hash=False, repr=False
)
The custom banner color for the user, if set.
The official client will decide the default color if not set.
app class-attribute instance-attribute #
app: RESTAware = attrs.field(
repr=False,
eq=False,
hash=False,
metadata={attrs_extensions.SKIP_DEEP_COPY: True},
)
Client application that models may use for procedures.
avatar_decoration class-attribute instance-attribute #
avatar_decoration: UndefinedNoneOr[AvatarDecoration] = (
attrs.field(eq=False, hash=False, repr=False)
)
Avatar decoration of the user, if an avatar decoration is set.
avatar_hash class-attribute instance-attribute #
avatar_hash: UndefinedNoneOr[str] = attrs.field(
eq=False, hash=False, repr=False
)
Avatar hash of the user, if a custom avatar is set.
banner_hash class-attribute instance-attribute #
banner_hash: UndefinedNoneOr[str] = attrs.field(
eq=False, hash=False, repr=False
)
Banner hash of the user, if a custom banner is set.
discriminator class-attribute instance-attribute #
discriminator: UndefinedOr[str] = attrs.field(
eq=False, hash=False, repr=True
)
Four-digit discriminator for the user if unmigrated.
!!! deprecated 2.0.0.dev120 Discriminators are deprecated and being replaced with "0" by Discord during username migration. This field will be removed after migration is complete. Learn more here: https://dis.gd/usernames
flags class-attribute instance-attribute #
flags: UndefinedOr[UserFlag] = attrs.field(
eq=False, hash=False, repr=True
)
Public flags for this user.
global_name class-attribute instance-attribute #
global_name: UndefinedNoneOr[str] = attrs.field(
eq=False, hash=False, repr=True
)
Global name of the user.
id class-attribute instance-attribute #
The ID of this user.
is_bot class-attribute instance-attribute #
is_bot: UndefinedOr[bool] = attrs.field(
eq=False, hash=False, repr=True
)
Whether this user is a bot account.
is_system class-attribute instance-attribute #
is_system: UndefinedOr[bool] = attrs.field(
eq=False, hash=False, repr=True
)
Whether this user is a system account.
mention property #
mention: str
Return a raw mention string for the given user.
Examples:
>>> some_user.mention
'<@123456789123456789>'
primary_guild class-attribute instance-attribute #
primary_guild: UndefinedNoneOr[PrimaryGuild] = attrs.field(
eq=False, hash=False, repr=True
)
The users primary guild tag.
username class-attribute instance-attribute #
username: UndefinedOr[str] = attrs.field(
eq=False, hash=False, repr=True
)
Username of the user.
PremiumType #
Bases: int, Enum
The types of Nitro.
NITRO class-attribute instance-attribute #
NITRO = 2
Premium tier including all available perks (e.g. 2 server boosts).
NITRO_BASIC class-attribute instance-attribute #
NITRO_BASIC = 3
Premium tier including basic perks (e.g. animated emojis and avatars).
NITRO_CLASSIC class-attribute instance-attribute #
NITRO_CLASSIC = 1
Legacy premium tier, including basic perks like animated emojis and avatars.
PrimaryGuild #
Data for the users primary guild.
badge_hash class-attribute instance-attribute #
The guild tag badge hash.
identity_enabled class-attribute instance-attribute #
Whether the identity is enabled.
identity_guild_id class-attribute instance-attribute #
The users identity guild's ID.
tag class-attribute instance-attribute #
The text for the guild tag.
make_url #
make_url(
*,
file_format: UndefinedOr[
Literal["PNG", "JPEG", "JPG", "WEBP"]
] = UNDEFINED,
size: int = 4096,
lossless: bool = True,
) -> URL
Generate the image URL for this primary guild badge.
| PARAMETER | DESCRIPTION |
|---|---|
file_format | The format to use for this URL. Supports If not specified, the format will be TYPE: |
size | The size to set for the URL; This is ignored for the TYPE: |
lossless | Whether to return a lossless or compressed WEBP image; This is ignored if TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
URL | The URL to the avatar decoration. |
| RAISES | DESCRIPTION |
|---|---|
TypeError | If an invalid format is passed for |
ValueError | If |
User #
Bases: PartialUser, ABC
Interface for any user-like object.
This does not include partial users, as they may not be fully formed.
accent_color abstractmethod property #
accent_color: Color | None
The custom banner color for the user, if set else None.
The official client will decide the default color if not set.
accent_colour property #
accent_colour: Color | None
Alias for the hikari.users.User.accent_color field.
avatar_decoration abstractmethod property #
avatar_decoration: AvatarDecoration | None
Avatar decoration for the user, if they have one, otherwise None.
avatar_hash abstractmethod property #
avatar_hash: str | None
Avatar hash for the user, if they have one, otherwise None.
banner_hash abstractmethod property #
banner_hash: str | None
Banner hash for the user, if they have one, otherwise None.
discriminator abstractmethod property #
discriminator: str
Discriminator for the user.
!!! deprecated 2.0.0.dev120 Discriminators are deprecated and being replaced with "0" by Discord during username migration. This field will be removed after migration is complete. Learn more here: https://dis.gd/usernames
display_avatar_decoration property #
display_avatar_decoration: AvatarDecoration | None
Display avatar decoration for the user, if they have one set.
Will be None if no avatar decoration is set.
display_banner_url property #
display_banner_url: URL | None
Display banner URL for this user, if they have one set.
Will be None if no banner is set.
global_name abstractmethod property #
global_name: str | None
Global name for the user, if they have one, otherwise None.
mention abstractmethod property #
mention: str
Return a raw mention string for the given user.
Examples:
>>> some_user.mention
'<@123456789123456789>'
primary_guild abstractmethod property #
primary_guild: PrimaryGuild | None
The users primary guild tag.
make_avatar_url #
make_avatar_url(
*,
file_format: UndefinedOr[
Literal[
"PNG", "JPEG", "JPG", "WEBP", "AWEBP", "GIF"
]
] = UNDEFINED,
size: int = 4096,
lossless: bool = True,
) -> URL | None
Generate the avatar URL for this user, if set.
If no avatar is set, this returns None.
| PARAMETER | DESCRIPTION |
|---|---|
file_format | The format to use for this URL. Supports If not specified, the format will be determined based on whether the avatar is animated or not. TYPE: |
size | The size to set for the URL; Can be any power of two between TYPE: |
lossless | Whether to return a lossless or compressed WEBP image; This is ignored if TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
Optional[URL] | The URL, or |
| RAISES | DESCRIPTION |
|---|---|
TypeError | If an invalid format is passed for |
ValueError | If |
make_banner_url #
make_banner_url(
*,
file_format: UndefinedOr[
Literal[
"PNG", "JPEG", "JPG", "WEBP", "AWEBP", "GIF"
]
] = UNDEFINED,
size: int = 4096,
lossless: bool = True,
) -> URL | None
Generate the banner URL for this user, if set.
If no banner is set, this returns None.
| PARAMETER | DESCRIPTION |
|---|---|
file_format | The format to use for this URL. Supports If not specified, the format will be determined based on whether the banner is animated or not. TYPE: |
size | The size to set for the URL; Can be any power of two between TYPE: |
lossless | Whether to return a lossless or compressed WEBP image; This is ignored if TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
Optional[URL] | The URL, or |
| RAISES | DESCRIPTION |
|---|---|
TypeError | If an invalid format is passed for |
ValueError | If |
UserFlag #
Bases: Flag
The known user flags that represent account badges.
ACTIVE_DEVELOPER class-attribute instance-attribute #
ACTIVE_DEVELOPER = 1 << 22
Active developer of a Discord app.
BOT_HTTP_INTERACTIONS class-attribute instance-attribute #
BOT_HTTP_INTERACTIONS = 1 << 19
Uses only HTTP interactions and is shown in the active member list.
BUG_HUNTER_LEVEL_1 class-attribute instance-attribute #
BUG_HUNTER_LEVEL_1 = 1 << 3
Participated in the Discord Testers community.
BUG_HUNTER_LEVEL_2 class-attribute instance-attribute #
BUG_HUNTER_LEVEL_2 = 1 << 14
Vastly participated in the Discord Testers community.
COLLABORATOR class-attribute instance-attribute #
COLLABORATOR = 1 << 50
Discord Collaborator, considered Staff.
DISCORD_CERTIFIED_MODERATOR class-attribute instance-attribute #
DISCORD_CERTIFIED_MODERATOR = 1 << 18
Alumni of the moderator program.
EARLY_SUPPORTER class-attribute instance-attribute #
EARLY_SUPPORTER = 1 << 9
Early premium supporter of Discord.
EARLY_VERIFIED_DEVELOPER class-attribute instance-attribute #
EARLY_VERIFIED_DEVELOPER = 1 << 17
Early verified bot developer.
HYPESQUAD_BALANCE class-attribute instance-attribute #
HYPESQUAD_BALANCE = 1 << 8
Member of the HypeSquad House of Balance.
HYPESQUAD_BRAVERY class-attribute instance-attribute #
HYPESQUAD_BRAVERY = 1 << 6
Member of the HypeSquad House of Bravery.
HYPESQUAD_BRILLIANCE class-attribute instance-attribute #
HYPESQUAD_BRILLIANCE = 1 << 7
Member of the HypeSquad House of Brilliance.
HYPESQUAD_EVENTS class-attribute instance-attribute #
HYPESQUAD_EVENTS = 1 << 2
Participated in HypeSquad Events.
PARTNERED_SERVER_OWNER class-attribute instance-attribute #
PARTNERED_SERVER_OWNER = 1 << 1
Partnered Discord server owner.
PROVISIONAL_ACCOUNT class-attribute instance-attribute #
PROVISIONAL_ACCOUNT = 1 << 23
Provisional account used with the social layer integration.
RESTRICTED_COLLABORATOR class-attribute instance-attribute #
RESTRICTED_COLLABORATOR = 1 << 51
Restricted Discord Collaborator, considered Staff.
TEAM_USER class-attribute instance-attribute #
TEAM_USER = 1 << 10
Pseudo-user for an app's development team.
UserImpl #
Bases: PartialUserImpl, User
Concrete implementation of user information.
accent_color class-attribute instance-attribute #
The custom banner color for the user, if set.
The official client will decide the default color if not set.
avatar_decoration class-attribute instance-attribute #
avatar_decoration: AvatarDecoration | None = attrs.field(
eq=False, hash=False, repr=False
)
Avatar decoration of the user, if they have one.
avatar_hash class-attribute instance-attribute #
The user's avatar hash, if they have one, otherwise None.
banner_hash class-attribute instance-attribute #
Banner hash of the user, if they have one, otherwise None
discriminator class-attribute instance-attribute #
The user's discriminator.
!!! deprecated 2.0.0.dev120 Discriminators are deprecated and being replaced with "0" by Discord during username migration. This field will be removed after migration is complete. Learn more here: https://dis.gd/usernames
flags class-attribute instance-attribute #
The public flags for this user.
global_name class-attribute instance-attribute #
The user's global name.
is_bot class-attribute instance-attribute #
is_system class-attribute instance-attribute #
primary_guild class-attribute instance-attribute #
primary_guild: PrimaryGuild | None = attrs.field(
eq=False, hash=False, repr=True
)
The users primary guild tag.