Development Guide

Welcome to the development guide! This is basically a reference sheet to help you through the process of developing Cakebot!

You will need to install dependencies (see section below) before you can start developing, so your IDE can assist you in development.



Note: you may want to create a virtualenv first. If you want to, see the section below.

Please run this in a terminal:

make deps

If this fails, check that you have pip installed for your Python version.


You can use this format to add any valid PyPI or Cakebot hosted package to our requirements.txt:


Virtual Environments

Here is how to run the bot in a Virtual Environment (virtualenv).

What provider should I use?

We require virtualenv instead of pipenv.

Create virtualenv

First, install virtualenv. See here for how to do that.

Then, head to here to learn how to create it and activate it.

Activate virtualenv

Run this command:

$ source virtualenvname/bin/activate

Starting Bot in Development Environment

The bot is built to work primarily on our server, and because of that, some files may need to be adjusted on your computer.

GitHub API Wrapper

Normally, you will need to not provide a token (used by the +report command, and its GitHub API wrapper instance), as we aren't publishing our personal access token for @RDILBot for security reasons.

If you really must use it (e.g. for testing), follow this guide to creating a personal access token (make sure you add gist and repo:public_repo permissions at the very least), then paste the generated token into the "github" field of the "tokens" object in your config.json.


You will need to create your own bot here (new application -> build a bot -> create bot) and generate/supply a token (which needs to be pasted into the "discord" value of the "tokens" object in the config.json file).

The Database


You should only run this the first time.

Since we use a database to store some information in, you will need to run this command to create it:

$ python3 initdb

Running the Bot

We have a custom command-line interface for the bot, and so you will need to run it to launch the bot:

$ python3 run

To see more commands that are available via the CLI, you can run python3 --help.

Making New Python Modules

When making new Python modules, please keep the following in mind:

  1. Please add copyright header to the top of the file before any code.
  2. Please put it in the cakebot package for organization.
  3. Use UpperCamelCase to name it.

Copyright Header

Here is the copyright header we require:

Cakebot - A cake themed Discord bot
Copyright (C) 2019-current year Reece Dunham
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <>.

Python Version

To develop the bot, you will need to have a supported Python version installed.


The bot runs on v3.8.0 in production, so lower version syntax/features can potentially throw errors.

Compatibility Policy

The bot currently does support:

  • CPython 3.7.x
  • CPython 3.8.x

However, we absolutely do not support Python versions older than v3.6.x.

Python 3.6.x may work, but is not suggested.

Diagnosing Errors

Using PyCharm IDE

Please see this guide on how to analyze stacks for Python.

Common Errors

Improper token

If the last line of your stack contains improper token passed, try these steps:

  1. Make sure the line of the JSON for the token specifies the right one.
  2. Check if your bot is already running in any other terminals. It can only run one instance at a time.


See PythonAnywhere's guide on fixing these.


If the bot seems to have a performance issue, you can try enabling the profiler to find the issue.


This does require you to have admin access to the bot (your Discord user ID in the UserUtil file).

To start profiling, run the command start-profiler in any Discord channel.

The profiler will start analysis in the background.

To end the profiling session and get results, just run stop-profiler.

All recorded results will be outputted to the profile.txt file.

Last updated on by Reece Dunham