Package: discord-typings
discord-typingsPython typings of all payloads that Discord sends asTypedDicts.QuickstartThe library requires no setup except for installation. The easiest way to
install it is through PyPI where it is similarly nameddiscord-typings:pipinstalldiscord-typingsNow, start importing the relevant typings directly from the library:fromdiscord_typingsimportUserDatadefprint_author(user:UserData)->None:print(f"Created by{user['username']}#{user['discriminator']}")print_author({'id':'344404945359077377','username':'Bluenix','discriminator':'7543','avatar':None})It is also possible to import the library inside of aTYPE_CHECKING-clause:fromtypingimportAny,TYPE_CHECKINGifTYPE_CHECKING:fromdiscord_typingsimportSnowflakeclassData:id:'Snowflake'value:AnyNoteIt is not recommended to import the library this way, as it does not allow
you to introspect the annotations in other code. It is merely pointed out
for completeness.Naming and UsageThere is no documentation or API reference as this provides no value on top of
the Discord developer documentation the types are based on. Typings are named
after the object they represent, and there are little to noexceptionsto this rule.Typings use suffixes to differentiate between potential wrapping objects in
user code - such as importingUserDatato parse into a customUserclass.
These areData,Event, andCommand.Eventrefers to a gateway eventreceivedover the gateway whileCommandrefers to a gateway commandsentover the gateway.Datais used for any general objects likeUserData.ExceptionsTo differentiate between the data for complete application commands, and the
data Discord expects to receive to create an application command, there is
a special-casedApplicationCommandPayload.Codestyle and ContributingDiscord-typings is a relatively simple library with little code, but
unfortunately needs to be constantly maintained with Discord's API.
The purpose of this library is for this to be a community effort;
any help with maintenance is greatly appreciated.StructureThe library follows the API docs both in terms of naming, structure, and order
inside of individual files. This should hopefully make it easier to find the
code to change when you have the documentation entry at hand.All internal imports should be done by importing the entire module, then
accessing the typing as an attribute. Iffrom ... import ..., or specific
things are imported, that is likely to create complicated circular imports.
Inside of annotations, wrap the attribute access (discord_typings.X) in
quotes to make it a string and defer its evaluation.All typings which directly represent a Discord payload (excluding typings
created for the purpose of aUnion) should be added to the file's__all__,
then be added to the module's__init__and its__all__.Version GuaranteesOnce discord-typings releases itsv1.0release, it will follow strict
semantic versioning guarantees. Keep in mind that thisonly appliesto the Python interface - such asTypeDicts, top-level unions, and
other aliases.Due to Discord's frequent API updates, it is not guaranteed that code
which type-checks in one minor version will do so in another one. This
is because code which does not type-check will not have an effect on
runtime for users.As a reminder of semantic versioning, and a summary of the above:Release TypeUpgradeDowngradeCommentMajorOnly type of release with breaking Python changesMinorXMay add new features, can break type-checkingPatchXXOnly intended for bugsWarnPatch versions will be used to rectify any accidental breaking changes
or unintended bugs / behaviour, therefore you shouldalwaysuse
the latest patch version.NoteBecause patch versions may change previous behaviour, theycouldbe
considered breaking, however the intention is always to fix unintended
behaviour or previous breaking changes which should not have been.
In those cases, the previous version will be pulled from PyPI.Links and FeedbackPyPI PackageDiscord API DocsWumpy Project Discord Server