Getting Started with PyDiscoBasePro

Prerequisites

Installation

pip install pydiscobasepro

Create Your First Bot

pydisco create MyFirstBot
cd MyFirstBot
pip install -r requirements.txt

Configuration

Edit config/config.json:

{
  "token": "YOUR_BOT_TOKEN_HERE",
  "prefix": "!",
  "intents": {
    "guilds": true,
    "members": true,
    "messages": true,
    "message_content": true
  },
  "mongodb": {
    "uri": "mongodb://localhost:27017",
    "database": "myfirstbot"
  }
}

Run Your Bot

python bot.py

Your bot should now be online! Invite it to your server using the OAuth2 URL from the Discord Developer Portal.

Add Your First Command

Create commands/hello.py:

import discord
from discord import app_commands

class Hello:
    def __init__(self, bot, database):
        self.bot = bot
        self.database = database
        self.name = "hello"
        self.description = "Say hello!"

        self.slash_command = app_commands.Command(
            name=self.name,
            description=self.description,
            callback=self.run
        )

    async def run(self, interaction: discord.Interaction):
        await interaction.response.send_message("Hello, World! 🌍")

# The framework will automatically load this command!

Next Steps