Skip to main content

A baisc interface for discord bots to handle receiveing commands using the discord.py package.

Project description

PyPI PyPI PyPI PyPI Documentation Status

MehlBot

MehlBot is a Discord bot that responds to commands by executing (callback) functions.

It's built around the discord.Client class. This allows an easy integration to existing bots and creation of new bots.

Documentation: docs

See examples/hellow_bot.py for full source code.

# imports ... 

class HelloBot(discord.Client):  # discord.Client class

    def __init__(self, intents: Intents, **options) -> None:
        super().__init__(intents=intents, **options)

    async def on_ready(self) -> None:  # Gets called when bot is ready/started
        print("Bot started.")

    async def on_message(self, message: Message):
        if message.author == self.user:  # skip if message's author is the bot
            return

        # necessary callback command
        # bot_commands are in mehlbot.command
        command_found = await command_callback.process_command(self, bot_commands, message)

        # prefix with command if message is command
        log_msg = "" if not command_found else "command: "
        log_msg += f"{message.author.nick} ({message.author.name}): '{message.content}'"
        print(log_msg)


def main():
    hello_bot = HelloBot(discord.Intents.all())  # discord intents
    with Path("token.txt").open() as file:  # load token form file (.gitignore) or use env
        token = file.read()
    hello_bot.run(token)

Dev

  • poetry run task --list to show all defined tasks to run. (run task with: poetry run task <task>)
  • note make html -> rst files copy into source folder, otherwise moduels not found

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mehlbot-1.1.1.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

mehlbot-1.1.1-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file mehlbot-1.1.1.tar.gz.

File metadata

  • Download URL: mehlbot-1.1.1.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.11.1 Windows/10

File hashes

Hashes for mehlbot-1.1.1.tar.gz
Algorithm Hash digest
SHA256 7b843d461fd0a0852d16766c90fef04248504c1bea6bf6bc042d740a55b43203
MD5 11310b1c0a4ee46c83fe3d7529bb9718
BLAKE2b-256 dee2f310ab33364b6aa8d5bfac47ed1da30c67a1771ba07847a5ee5f4306a287

See more details on using hashes here.

File details

Details for the file mehlbot-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: mehlbot-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.11.1 Windows/10

File hashes

Hashes for mehlbot-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4ee68fcd9b48815f62b0a5feadb2526641664922b2dd13e82b52fbe196bcb060
MD5 95b72cdd73fea62acba7e7f404b67342
BLAKE2b-256 0fee3fb72b6fc2974d16785d21eadc665e0d7d07fc83aab97c6238f0cb9f5014

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page