Skip to content

All the parts for building a Discord robot

License

Notifications You must be signed in to change notification settings

p-hennessy/Bolt

Repository files navigation

README

Logo

Python License Codacy Badge LibrariesIO

About Bolt

Bolt is an extensible chatbot written entirely in Python, inspired by Errbot and Hubot projects. The goal of this project is to provide a simple to extend bot framework for Discord.

Batteries included:

I am open to feedback and suggestions. Feel free to submit a pull request or open an issue :)

Bolt originally started out as a simple Trivia Bot that used long polling and webhooks to read and write to chat channels. I became obsessed with making this bot more robust and at that time, no bots existed for Discord, so this bot evolved into a fully vetted framework that I could use to build functionality off of.

This project is a place I can experiment with design ideas and evolve a sense of personal code standards. I treat it as an academic project to learn about new libraries and tools available to me as Python continues to grow.

Installing

Coming soon...

Examples

Command creation

from bolt import Plugin
from bolt import command

class SomePlugin(Plugin):
    @command("hi")
    def on_sayhi(self, event):
        self.say(event.channel_id, f"Hello {event.sender.name}")

Hook Discord Event

from bolt import Plugin
from bolt import subscriber
from bolt.discord import Events

class SomePlugin(Plugin):
    @subscriber(Events.MESSAGE_REACTION_ADD)
    def on_message_reaction_add(self, event):
        # do stuff

Webhook

from bolt import Plugin
from bolt import webhook

class SomePlugin(Plugin):
    @webhook('/hookme', methods=['GET'])
       def webhook(self, request):
           # do stuff

Code interval

from bolt import Plugin
from bolt import interval

class SomePlugin(Plugin):
    @interval(60)
    def updateathing(self, event):
        # do stuff

Database Interaction

from bolt import Plugin
from bolt import command

class SomePlugin(Plugin):
    def activate(self):
        self.users = self.bot.database_client['plugin-users']

    @command("whoami")
    def whoami(self, event):
        author = self.users.find_one({"id": event.author.id})

Schedule code to run

Coming soon...

Discord object mapping

Coming soon...

License

Bolt is licensed under the MIT License