Skip to content

hikari.impl.config#

Data class containing network-related configuration settings.

BasicAuthHeader #

An object that can be set as a producer for a basic auth header.

charset class-attribute instance-attribute #

charset: str = field(default='utf-8', validator=instance_of(str))

Encoding to use for the username and password.

Default is "utf-8", but you may choose to use something else, including third-party encodings (e.g. IBM's EBCDIC codepages).

header property #

header: str

Create the full Authentication header value.

password class-attribute instance-attribute #

password: str = field(repr=False, validator=instance_of(str))

Password to use.

username class-attribute instance-attribute #

username: str = field(validator=instance_of(str))

Username for the header.

Warning

This must not contain ":".

CacheSettings #

Bases: CacheSettings

Settings to control the cache.

components class-attribute instance-attribute #

components: CacheComponents = field(converter=CacheComponents, default=ALL)

The cache components to use.

Defaults to hikari.api.config.CacheComponents.ALL.

max_dm_channel_ids class-attribute instance-attribute #

max_dm_channel_ids: int = field(default=50)

The maximum number of channel IDs to store in the cache at once.

This will have no effect if the channel IDs cache is not enabled.

Defaults to 50.

max_messages class-attribute instance-attribute #

max_messages: int = field(default=300)

The maximum number of messages to store in the cache at once.

This will have no effect if the messages cache is not enabled.

Defaults to 300.

only_my_member class-attribute instance-attribute #

only_my_member: bool = field(default=False)

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.

Defaults to False.

HTTPSettings #

Bases: HTTPSettings

Settings to control HTTP clients.

enable_cleanup_closed class-attribute instance-attribute #

enable_cleanup_closed: bool = field(default=False, validator=instance_of(bool))

Toggle whether to clean up closed transports.

This defaults to False to combat various protocol and asyncio issues present. If you are sure you know what you are doing, you may instead set this to True to enable this behavior internally.

force_close_transports class-attribute instance-attribute #

force_close_transports: bool = field(default=True, validator=instance_of(bool))

Toggle whether to force close transports on shut down.

This defaults to True to combat various protocol and asyncio issues present when using Microsoft Windows. If you are sure you know what you are doing, you may instead set this to False to disable this behavior internally.

max_redirects class-attribute instance-attribute #

max_redirects: Optional[int] = field(default=10)

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 class-attribute instance-attribute #

ssl: SSLContext = field(factory=lambda: _ssl_factory(True), converter=_ssl_factory, validator=instance_of(SSLContext))

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.

timeouts class-attribute instance-attribute #

Settings to control HTTP request timeouts.

The behaviour if this is not explicitly defined is to use sane defaults that are most efficient for optimal use of this library.

HTTPTimeoutSettings #

Settings to control HTTP request timeouts.

acquire_and_connect class-attribute instance-attribute #

acquire_and_connect: Optional[float] = field(default=None)

Timeout for request_socket_connect PLUS connection acquisition.

By default, this has no timeout allocated. Setting it to None will disable it.

request_socket_connect class-attribute instance-attribute #

request_socket_connect: Optional[float] = field(default=None)

Timeout for connecting a socket.

By default, this has no timeout allocated. Setting it to None will disable it.

request_socket_read class-attribute instance-attribute #

request_socket_read: Optional[float] = field(default=None)

Timeout for reading a socket.

By default, this has no timeout allocated. Setting it to None will disable it.

total class-attribute instance-attribute #

total: Optional[float] = field(default=30.0)

Total timeout for entire request.

By default, this has a 30 second timeout allocated. Setting it to None will disable it.

ProxySettings #

Bases: ProxySettings

Settings for configuring an HTTP-based proxy.

all_headers property #

all_headers: Optional[Headers]

Return all proxy headers.

Will be None if no headers are to be send with any request.

auth class-attribute instance-attribute #

auth: Any = field(default=None)

Authentication header value to use.

When cast to a str, this should provide the full value for the authentication header.

If you are using basic auth, you should consider using the hikari.impl.config.BasicAuthHeader helper object here, as this will provide any transformations you may require into a Base64 string.

The default is to have this set to None, which will result in no authentication being provided.

headers class-attribute instance-attribute #

headers: Optional[Headers] = field(default=None)

Additional headers to use for requests via a proxy, if required.

trust_env class-attribute instance-attribute #

trust_env: bool = field(default=False, validator=instance_of(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.

Defaults to False to prevent potentially unwanted behavior.

url class-attribute instance-attribute #

url: Union[None, str] = field(default=None)

Proxy URL to use.

Defaults to None which disables the use of an explicit proxy.