hikari.snowflakes#
Implementation of a Snowflake type.
Module Contents#
- class hikari.snowflakes.Snowflake[source]#
Bases:
int
A concrete representation of a unique ID for an entity on Discord.
This object can be treated as a regular
int
for most purposes.- property created_at: datetime.datetime[source]#
When the object was created.
- property internal_process_id: int[source]#
ID of the process that created this snowflake on Discord’s systems.
- property internal_worker_id: int[source]#
ID of the worker that created this snowflake on Discord’s systems.
- class hikari.snowflakes.Unique[source]#
Bases:
abc.ABC
Mixin for a class that enforces uniqueness by a snowflake ID.
- property created_at: datetime.datetime[source]#
When the object was created.
- hikari.snowflakes.calculate_shard_id(app_or_count, guild)[source]#
Calculate the shard ID for a guild based on it’s shard aware app or shard count.
- Parameters:
- app_or_count
typing.Union
[hikari.traits.ShardAware
,int
] The shard aware app of the current application or the integer count of the current app’s shards.
- guild
SnowflakeishOr
[hikari.guilds.PartialGuild
] The object or ID of the guild to get the shard ID of.
- app_or_count
- Returns:
int
The zero-indexed integer ID of the shard that should cover this guild.
- hikari.snowflakes.SearchableSnowflakeish[source]#
Type hint for a snowflakeish that can be searched for in history.
This is just a
Snowflakeish
that can alternatively be some form ofdatetime.datetime
instance.The valid types for this type hint are:
str
containing digits.
- hikari.snowflakes.SearchableSnowflakeishOr[source]#
Type hint for a unique object entity that can be searched for.
This is a variant of
SnowflakeishOr
that also allows an alternative value of adatetime.datetime
to be specified.Essentially this represents any concrete object, or ID of that object. It is used across Hikari’s API to allow use of functions when information is only partially available (due to Discord inconsistencies, edge case behaviour, or use of intents).
The valid types for this type hint are:
- hikari.snowflakes.Snowflakeish[source]#
Type hint for a value that resembles a
Snowflake
object functionally.This is a value that is
Snowflake
-ish.A value is
Snowflake
-ish if casting it to anint
allows it to be cast to aSnowflake
.The valid types for this type hint are:
- hikari.snowflakes.SnowflakeishIterable[source]#
Type hint representing an iterable of unique object entities.
- hikari.snowflakes.SnowflakeishOr[source]#
Type hint representing a unique object entity.
This is a value that is
Snowflake
-ish or a specific type covariant.If you see
SnowflakeishOr[Foo]
anywhere as a type hint, it means the value may be aFoo
instance, aSnowflake
, aint
or astr
with numeric digits only.Essentially this represents any concrete object, or ID of that object. It is used across Hikari’s API to allow use of functions when information is only partially available (due to Discord inconsistencies, edge case behaviour, or use of intents).
The valid types for this type hint are: