/discord-bot

A discord bot with some club specific features made in house at Hack Club NMIT

Primary LanguagePythonMIT LicenseMIT

Hack Club NMIT Discord Bot

A discord bot with some club specific features.

Requirements

Setup

  1. Setup the bot by following this guide : RealPython

  2. Place the token in token.txt

  3. Install the dependencies: pip install -r --user requirements.txt

  4. Set up Firestore and initialize the SDK: Here and Here

  5. Start the bot: python bot.py

Theory

To help you get started on understanding and contributing to this project.

What are cogs?

Documentation Explanation

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.

Contributing

  • Fork the Repo
  • Create a seperate branch (say test)
  • Make changes
  • Create a PR

TODO

TODO