Go to file
Stijn De Clercq 7bbe4db26d
Merge pull request #74 from stijndcl/list_custom_commands
Show list of custom commands
2021-06-19 23:09:53 +02:00
.github Update issue templates 2021-02-08 19:04:07 +01:00
backend Fix requirements.txt (hopefully) & add some info to FAQ, fixes #47 2021-06-19 22:13:41 +02:00
cogs Show list of custom commands 2021-06-19 23:08:42 +02:00
converters Initial commit 2020-10-13 21:06:00 +02:00
data Show list of custom commands 2021-06-19 23:08:42 +02:00
decorators Initial commit 2020-10-13 21:06:00 +02:00
enums Support roles for 2.2 courses 2021-02-08 18:50:56 +01:00
files Show list of custom commands 2021-06-19 23:08:42 +02:00
functions Merge pull request #72 from stijndcl/flask-backend 2021-06-19 22:29:32 +02:00
startup Check for non-existing files & init with default values 2021-06-19 22:13:41 +02:00
.editorconfig Add deployment workflow 2020-10-24 17:10:51 +02:00
.gitignore Add venv to ignore (PyCharm ignores it automatically) 2021-06-19 22:13:41 +02:00
.python-version Initial commit 2020-10-13 21:06:00 +02:00
creating-commands.md update creating-commands file 2020-10-24 17:02:31 +02:00
databases.md List total commands per day instead of total usages per command 2021-06-19 17:45:26 +02:00
didier.py Use env vars, fixes #62 2021-06-19 22:13:39 +02:00
faq.md Fix requirements.txt (hopefully) & add some info to FAQ, fixes #47 2021-06-19 22:13:41 +02:00
ignored.md Use env vars, fixes #62 2021-06-19 22:13:39 +02:00
readme.md Fix requirements.txt (hopefully) & add some info to FAQ, fixes #47 2021-06-19 22:13:41 +02:00
requirements.txt Fix requirements.txt (hopefully) & add some info to FAQ, fixes #47 2021-06-19 22:13:41 +02:00
settings.py Use env vars, fixes #62 2021-06-19 22:13:39 +02:00

readme.md

Didier

You bet. The time has come.

Discord Documentation

Link to the Discord API docs. When making a command, make sure to check to docs to see if what you're doing is even possible, and if you're providing the right (amount of) parameters. Ask questions in De Zandbak Discord all you want, but at least make an attempt at looking it up first.

Running Didier

In order to run Didier, simply run python3 didier.py in your terminal, or click run in PyCharm (green arrow @ top-right, or right-click the file). Make sure you have installed all the required packages in requirements.txt.

Databases

databases.md contains info on every database. Using this file you can find out which tables exist, which columns those tables have, and which types of values those columns contain. This should be enough for you to set up a local Postgresql database in order to mess around with & test functions before committing them (guilty).

Cog Template

When using PyCharm, you can configure file templates to create blueprints for files. This speeds up the process of creating Cogs as you don't have to write the same exact code every single time.

Below is the Cog template you are expected to use when creating new Cogs for Didier, providing both essential and commonly-used imports & functionality. It's possible that you don't need all of the imports, in which case you can obviously remove the obsolete ones.

from data import constants
import discord
from discord.ext import commands
from decorators import help
from enums.help_categories import Category
from functions import checks


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

    # Don't allow any commands to work when locked
    def cog_check(self, ctx):
        return not self.client.locked

def setup(client):
    client.add_cog(Cog(client))

Replacing the classname Cog with the name of your cog.

Help Categories

Didier uses a custom help command, which classifies certain commands into categories. Discord's default help does this based on Cogs, but this would mean some Cogs would be thousands of lines long, defeating the purpose of using them in the first place.

When creating a new Didier command, you can add it to a Category by adding a decorator above the function. The example below shows how to add a command to the Currency category.

from decorators import help
from discord.ext import commands
from enums.help_categories import Category
from functions import checks

@commands.command(name="Command Name", aliases=["Cn"])
@commands.check(checks.allowedChannels)
@help.Category(Category.Currency)
async def command_name(self, ctx):
    # Command code
    await ctx.send("Command response")

This allows commands across multiple Cogs to be classified under the same category in the help page.

Python Version

Didier uses Python 3.6.9. Seeing as updating Python on a Raspberry Pi is a huge pain, this will not change. As a result, you are expected to write code that is compatible with this version. When initially creating the PyCharm project, set 3.6.9 as your project interpreter.

Ignored Files

ignored.md contains a list of all ignored files, and what they look like. This way, you can recreate these files locally to test commands that use them. API keys should be stored in environment variables. To do so, create a file called .env in the root of this repository (which has already been added to .gitignore) and make sure the names match.

FAQ

faq.md is always worth taking a look at when you've got a question. Right now this doesn't contain much, as I don't have any questions for myself, but over time this will be expanded upon.

  • Embed Visualizer: Allows for easy creation of embeds, and can generate the code for them (bottom: "Generate Code" -> "discord.py (Python)"). This is helpful when starting out so you can see what you're doing, when you don't really know how Embeds work yet.