Red-DiscordBot

3.5.24 · active · verified Mon Apr 13

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

Install

Imports

Quickstart

Red-DiscordBot is primarily managed via a command-line interface and in-Discord commands. To get started, you first install Red into a virtual environment. Then, you run `redbot-setup <instance_name>` in your terminal, which guides you through creating a bot, setting a prefix, and obtaining the bot token. You then start the bot using `redbot <instance_name>`. The bot provides an invite URL, and once invited to a server, you can interact with it using the configured prefix (e.g., `[p]help`). This example shows a simple 'cog' (plugin) that defines two commands. Save this as `mysimplecog.py` in your cogs directory, then load it in Discord using `[p]load mysimplecog`.

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))

view raw JSON →