TokenProvider

Provides a method to retrieve the Discord bot token used for authentication.

The token can be provided through a command-line argument, a file, or an environment variable.

  • If a token is passed as an argument, it is used if non-null and non-blank.

  • If no argument is provided, the token is read from a file located at src/main/kotlin/token.txt.

  • If the file does not exist or is empty, the token is retrieved from the environment variable DISCORD_BOT_TOKEN.

Throws

if no token is found in the argument, file, or environment variable.

Example usage:

val token = TokenProvider.getToken(args.getOrNull(0))

Functions

Link copied to clipboard
fun getToken(argToken: String? = null): String

Retrieves the Discord bot token.