Nostrum.Token (nostrum v0.11.0-dev)
View SourceA helper module for verifying the Discord bot token.
The token can be generated in the "Bot" tab of your Application the Discord Developer Portal and can be configured in your config file.
config :nostrum,
token: "666" # The token of your bot as a string
Summary
Functions
Decode the given Discord bot token.
Functions
@spec decode_token!(binary()) :: pos_integer()
Decode the given Discord bot token.
We check if the token is a binary followed by splitting it into 3 parts separated by a dot "."
.
The first part is the Base64 encoded user_id which we decode and parse into as integer.
The second part is an encoded timestamp, and the last part an arbitrary cryptographic signature.
Returns the user ID in the token.
Raises on failure.
Examples
iex> token = "OTY4NTU2MzQ4MzkwMzkxODU5.G49NjP.pD8PLpKp-Xx8sr-8m1DCxSPTJZdcpcJZOExc1c"
iex> Nostrum.Token.decode_token!(token)
968556348390391859
iex> token = "ODY4MDcxODUzMDMyMzU3OTc4.YPqU6Q.jNJcq1daGG3otexX3c1LcxCpgpQ"
iex> Nostrum.Token.decode_token!(token)
868071853032357978