Red-DiscordBot
Red-DiscordBot is a highly customisable, self-hosted Discord bot framework, offering a wide array of features through its modular 'cogs' (plugins). It supports everything from moderation and utility to music and custom commands. The project maintains an active development cycle with frequent patch releases, often aligning with updates to its core dependencies like discord.py.
Warnings
- breaking Red-DiscordBot V3.5+ depends on `discord.py` V2.x. Cogs (plugins) written for older Red versions (V3.0-V3.4, which used `discord.py` V1.x) will likely require significant updates due to breaking changes in `discord.py`'s API (e.g., `Intents` are now mandatory).
- breaking Migrating from Red V2 to Red V3 involves fundamental architectural changes. Cogs are now Python packages, data storage shifted from `dataIO` to the `Config` system, and core utilities are imported with a `redbot.core` prefix. Older cogs will not function without a complete rewrite or significant refactoring.
- breaking Red V3.2 dropped support for the MongoDB data backend. If you were using MongoDB with an older Red version, you must migrate your data to a supported backend (e.g., JSON, PostgreSQL) before updating to Red V3.2 or later.
- gotcha Achieving full audio functionality, especially for streaming from sources like YouTube or Spotify, often requires additional system-level dependencies. This includes a Java Runtime Environment (JRE 11+) for the Lavalink audio server and FFmpeg for media processing. Troubleshooting audio issues can be complex due to these external requirements.
- gotcha Red-DiscordBot highly recommends (and often implicitly requires) installation within a Python virtual environment. Failure to use a virtual environment can lead to dependency conflicts with other Python projects or system-wide package pollution, making future updates or dependency management difficult.
- gotcha Red-DiscordBot is primarily controlled through its command-line interface for initial setup (`redbot-setup`) and starting the bot (`redbot <instance_name>`). Once running, all bot commands and cog interactions are performed within Discord chat, not the terminal. New users often mistakenly try to type bot commands into the terminal console.
Install
-
pip install -U Red-DiscordBot -
pip install -U Red-DiscordBot[postgres]
Imports
- Red
from redbot.core.bot import Red
- commands
from redbot.core import commands
- Config
from redbot.core import Config
Quickstart
import discord
from redbot.core import commands
class MySimpleCog(commands.Cog):
"""My super awesome cog!"""
def __init__(self, bot):
self.bot = bot
@commands.command()
async def hello(self, ctx):
"""Says hello!"""
await ctx.send("Hello, world!")
@commands.command()
async def myid(self, ctx):
"""Shows your Discord ID."""
await ctx.send(f"Your ID is: {ctx.author.id}")
async def setup(bot):
await bot.add_cog(MySimpleCog(bot))