Skip to content

Getting Started


The following code snippet is how your bot should be setup.

Setup


Place the following code in your main file:

import discord, os
from dotenv import load_dotenv

load_dotenv(dotenv_path='./path/to/env') # omit argument if your env file is on the same level

client = discord.Client(
    token=os.getenv("DISCORD_TOKEN"),
    application_id=1234567890 # replace with your bot's user ID
)

# your code or example snippets here

client.run()

Place the following variables in your .env file:

DISCORD_TOKEN="your-bot-token"

Setup rules

  • Keep sensitive values (like your bot’s token) in a .env file instead of hardcoding them.
  • Always place bot.run() at the end of your script, after all commands and event handlers are registered.

Next Steps

  • Want a quick reference? Check out the API
  • Need some extra help? Check out Examples