Skip to content

hikari.api.config#

Core interface for Hikari's configuration dataclasses.

CacheComponents #

Bases: Flag

Flags to control the cache components.

ALL class-attribute instance-attribute #

Fully enables the cache.

DM_CHANNEL_IDS class-attribute instance-attribute #

DM_CHANNEL_IDS = 1 << 10

Enables the DM channel IDs cache.

EMOJIS class-attribute instance-attribute #

EMOJIS = 1 << 5

Enables the emojis cache.

GUILDS class-attribute instance-attribute #

GUILDS = 1 << 0

Enables the guild cache.

GUILD_CHANNELS class-attribute instance-attribute #

GUILD_CHANNELS = 1 << 1

Enables the guild channels cache.

GUILD_STICKERS class-attribute instance-attribute #

GUILD_STICKERS = 1 << 11

Enables the guild stickers cache.

GUILD_THREADS class-attribute instance-attribute #

GUILD_THREADS = 1 << 12

Enables the guild threads cache.

INVITES class-attribute instance-attribute #

INVITES = 1 << 4

Enables the invites cache.

ME class-attribute instance-attribute #

ME = 1 << 9

Enables the me cache.

MEMBERS class-attribute instance-attribute #

MEMBERS = 1 << 2

Enables the members cache.

MESSAGES class-attribute instance-attribute #

MESSAGES = 1 << 8

Enables the messages cache.

NONE class-attribute instance-attribute #

NONE = 0

Disables the cache.

PRESENCES class-attribute instance-attribute #

PRESENCES = 1 << 6

Enables the presences cache.

ROLES class-attribute instance-attribute #

ROLES = 1 << 3

Enables the roles cache.

VOICE_STATES class-attribute instance-attribute #

VOICE_STATES = 1 << 7

Enables the voice states cache.

name property #

name: str

Return the name of the flag combination as a str.

value property #

value: int

Return the int value of the flag.

all #

all(*flags: Self) -> bool

Check if all of the given flags are part of this value.

RETURNS DESCRIPTION
bool

True if any of the given flags are part of this value. Otherwise, return False.

any #

any(*flags: Self) -> bool

Check if any of the given flags are part of this value.

RETURNS DESCRIPTION
bool

True if any of the given flags are part of this value. Otherwise, return False.

difference #

difference(other: Union[int, Self]) -> Self

Perform a set difference with the other set.

This will return all flags in this set that are not in the other value.

Equivalent to using the subtraction - operator.

intersection #

intersection(other: Union[int, Self]) -> Self

Return a combination of flags that are set for both given values.

Equivalent to using the "AND" & operator.

invert #

invert() -> Self

Return a set of all flags not in the current set.

is_disjoint #

is_disjoint(other: Union[int, Self]) -> bool

Return whether two sets have a intersection or not.

If the two sets have an intersection, then this returns False. If no common flag values exist between them, then this returns True.

is_subset #

is_subset(other: Union[int, Self]) -> bool

Return whether another set contains this set or not.

Equivalent to using the "in" operator.

is_superset #

is_superset(other: Union[int, Self]) -> bool

Return whether this set contains another set or not.

none #

none(*flags: Self) -> bool

Check if none of the given flags are part of this value.

Note

This is essentially the opposite of hikari.internal.enums.Flag.any.

RETURNS DESCRIPTION
bool

True if none of the given flags are part of this value. Otherwise, return False.

split #

split() -> Sequence[Self]

Return a list of all defined atomic values for this flag.

Any unrecognised bits will be omitted for brevity.

The result will be a name-sorted typing.Sequence of each member

symmetric_difference #

symmetric_difference(other: Union[int, Self]) -> Self

Return a set with the symmetric differences of two flag sets.

Equivalent to using the "XOR" ^ operator.

For a ^ b, this can be considered the same as (a - b) | (b - a).

union #

union(other: Union[int, Self]) -> Self

Return a combination of all flags in this set and the other set.

Equivalent to using the "OR" ~ operator.

CacheSettings #

Bases: ABC

Settings to control the cache.

components abstractmethod property #

components: CacheComponents

Cache components to use.

only_my_member abstractmethod property #

only_my_member: bool

Reduce the members cache to only the bot itself.

Useful when only the bot member is required (eg. permission checks). This will have no effect if the members cache is not enabled.

HTTPSettings #

Bases: ABC

Settings to control HTTP clients.

max_redirects abstractmethod property #

max_redirects: Optional[int]

Behavior for handling redirect HTTP responses.

If a int, allow following redirects from 3xx HTTP responses for up to this many redirects. Exceeding this value will raise an exception.

If None, then disallow any redirects.

The default is to disallow this behavior for security reasons.

Generally, it is safer to keep this disabled. You may find a case in the future where you need to enable this if Discord change their URL without warning.

Note

This will only apply to the REST API. WebSockets remain unaffected by any value set here.

ssl abstractmethod property #

SSL context to use.

This may be assigned a bool or an ssl.SSLContext object.

If assigned to True, a default SSL context is generated by this class that will enforce SSL verification. This is then stored in this field.

If False, then a default SSL context is generated by this class that will NOT enforce SSL verification. This is then stored in this field.

If an instance of ssl.SSLContext, then this context will be used.

Warning

Setting a custom value here may have security implications, or may result in the application being unable to connect to Discord at all.

Warning

Disabling SSL verification is almost always unadvised. This is because your application will no longer check whether you are connecting to Discord, or to some third party spoof designed to steal personal credentials such as your application token.

There may be cases where SSL certificates do not get updated, and in this case, you may find that disabling this explicitly allows you to work around any issues that are occurring, but you should immediately seek a better solution where possible if any form of personal security is in your interest.

ProxySettings #

Bases: ABC

Settings for configuring an HTTP-based proxy.

trust_env abstractmethod property #

trust_env: bool

Toggle whether to look for a netrc file or environment variables.

If True, and no url is given on this object, then HTTP_PROXY and HTTPS_PROXY will be used from the environment variables, or a netrc file may be read to determine credentials.

If False, then this information is instead ignored.

Note

For more details of using netrc, visit: https://www.gnu.org/software/inetutils/manual/html_node/The-_002enetrc-file.html

url abstractmethod property #

url: Union[None, str]

Proxy URL to use.

If this is None then no explicit proxy is being used.