from dubious.discord import disc

class dubious.discord.disc.Snowflake(r: str | int)

Represents a Discord Snowflake.

dubious.discord.api imports this. It’s acceptable to use

from dubious.discord import api and use api.Snowflake instead of disc.Snowflake.

class dubious.discord.disc.Disc

Root class for all Discord objects. Exists in case there’s some functionality to be implemented across every Discord data structure.

class dubious.discord.disc.t_Cast

Represents the return type of cast().

alias of TypeVar(‘t_Cast’)

dubious.discord.disc.cast(t_to: type[t_Cast], raw: Any) t_Cast

Casts raw data of any shape to the given type, t_to.

dubious.discord.disc.uncast(raw: Any)

Transforms an object to a json-compatible object.

class dubious.discord.disc.Http(value)

Enum for each potential type of request to make to the Discord API.

class dubious.discord.disc.t_Ret

Represents the type that an HttpReq will return upon success.

alias of TypeVar(‘t_Ret’)

class dubious.discord.disc.HttpReq

A class that holds information about a request to make to the Discord API.

Subclasses should define within themselves a class for the query attribute and/or the form attribute, if either exist, and appropriately set the type hints of either.

query: Disc | None = None

An object to give to the request. Acts as a query string in the URL; is given to requests.request() as the params kwarg.

form: Disc | None = None

An object to give to the request. Acts as a json string in the request’s body; is given to requests.request() as the json kwarg.

method: ClassVar[Http]

The HTTP method with which to make the request. Given to requests.request() as the method argument.

endpoint: str

The URL at which the request should be made. Given to requests.request() as the url argument. This field is set dynamically in a subclass’s __post_init__ in order to allow for per-guild/per-channel/etc. requests.

do_with(token: str) t_Ret

Perform this Discord API request with requests.request(). Requires authentication using a bot token - this is usually dubious.pory.Pory.token.

When a rate limit is encountered, wait the response’s given time and retry (by calling recursively).