A discord bot with some club specific features.
-
Setup the bot by following this guide : RealPython
-
Place the token in token.txt
-
Install the dependencies:
pip install -r --user requirements.txt
-
Start the bot:
python bot.py
To help you get started on understanding and contributing to this project.
-
Python Guides :
-
Discord API Guides:
Cogs is a special feature which lets you distribute functions/commands of the bot in different files.
In every module part of the cog, the commands, listeners, etc are wrapped in a class.
So why do this?
Cogs allow you to load and unload modules.
So say for example, your bot was just a single file called bot.py
, if you made any changes to the file, to make it work on the bot, you would've had to kill the script and start it again. This can cause inconvenience to the users of the bot who are using different features of the bot.
So if you had cogs, you could just unload the module, make the changes, and load it back, leaving the rest of the bot unaffected.
Syntax for a cog:
In file example.py
import discord
from discord.ext import commands
from discord.ext.commands import Bot
class Example(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command()
async def hello(self, ctx):
await ctx.send("Hello!")
def setup(bot):
bot.add_cog(Example(bot))
So if you had this example.py
file, you could load this module using the command h!load example
as described in bot.py
without having to kill the entire script.
- Fork the Repo
- Create a seperate branch (say
test
) - Make changes
- Create a PR
TODO