Giter Club home page Giter Club logo

basementbot's Introduction

BasementBot

BasementBot is a Dockerized Discord bot. Written on top of the Python Discord API, it provides the loading and unloading of custom extensions to extend and scale the bot as much as you want.

Setup

Note: this bot requires at minimum a MongoDB connection to maintain guild settings. If you wish to not use a MongoDB connection, check the base module for bots that don't rely on MongoDB.

  • Create a config.yaml file from the config.default.yaml file in the repo.
  • In the config.yaml file set your Discord developer token (see here)
  • In the config.yaml file set MongoDB connection settings (username, password, host, port, etc)
  • (Optional) set any other config.yaml variables. Some included extensions won't work without the correct API keys.

Production

  • Build the prod image:

    make prod
    
  • Run the Docker image using a docker-compose.yml configuration (see repo):

    make upp
    
  • Check the logs to verify things are working:

    make logs
    
  • Run Discord commands with the prefix you set in the .env file (defaults to .)

Development

  • Build the dev image:

    make dev
    
  • Spin up the dev containers:

    make upd
    

Makefile

The Makefile offers shortcut commands for development.

  • sync makes an updated pipenv virtual environment.
  • check-format checks the formatting without changing files.
  • format checks formatting and changes files.
  • lint runs pylint.
  • test runs unit tests.
  • dev builds the dev Docker image.
  • prod builds the prod Docker image.
  • upd spins up the development bot container.
  • upp spins up the production bot container.
  • down brings down the bot container.
  • reboot restarts the dev container.
  • restart restarts the bot container.
  • logs shows the main container logs.

Making extensions

On startup, the bot will load all extension files in the basement_bot/extensions/ directory. These files hold commands for the bot to use with its prefix. Each command is an async function decorated as a command, and each file must have an entrypoint function called setup, which tells the loading process how to add the extension file.

A (very) simple example:

import base
from discord.ext import commands


def setup(bot):
    bot.process_extension_setup(cogs=[Greeter])


class Greeter(base.BaseCog):
    @commands.command(
        name="hello",
        brief="Says hello to the bot",
        description="Says hello to the bot (because they are doing such a great job!)",
        usage="",
    )
    async def hello(self, ctx):
        # H, E, Y
        emojis = ["๐Ÿ‡ญ", "๐Ÿ‡ช", "๐Ÿ‡พ"]
        for emoji in emojis:
            await ctx.message.add_reaction(emoji)

Extensions can be configured per-guild with settings saved on MongoDB. There are several extensions included in the main repo, so please reference them for more advanced examples.

basementbot's People

Contributors

effprime avatar jalad25 avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.