Skip to content

Code Conventions

General

  • In general, all functionality (commands, tasks, event listeners, etc.) should be added to cogs, not the bot itself
  • Cogs should not depend on each other if possible
  • Try to add typing where possible
  • Comment your code! (docstrings are a great way to explain how your commands work)
  • Always format your code with Black before committing (your build will fail if you don't)

New Cogs

Create a new file in the cogs directory named <something>_cog.py with the following template:

from discord.ext import tasks, commands
import config

# Note: config.db is the database. TODO remove this line

# TODO rename SomethingCog

class SomethingCog(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    # TODO add stuff here


def setup(bot):
    # Adds cog to bot from main.py
    bot.add_cog(SomethingCog(bot))
Back to top