Skip to main content

A pycord extension that allows splitting command groups into multiple cogs

Project description

pycord-multicog

A pycord extension that allows splitting command groups into multiple cogs.

Installation

$ pip install pycord-multicog

Usage

Creating cogs

# cog number 1, a normal cog with a slash command group
class Cog1(Cog):
    group = SlashCommandGroup("group")

    @group.command()
    async def subcommand1(self, ctx):
        await ctx.respond("This is a normal subcommand.")


# cog number 2, has a command used with add_to_group
from pycord.multicog import add_to_group

class Cog2(Cog):
    @add_to_group("group")  # the decorator that does the magic
    @slash_command()
    async def subcommand2(self, ctx):
        await ctx.respond("This subcommand is inside a different cog.")

Applying multicog using apply_multicog

from pycord.multicog import apply_multicog

my_bot.add_cog(Cog1())
my_bot.add_cog(Cog2())
...
apply_multicog(my_bot)  # manually apply multicog after cogs are loaded

Applying multicog using Bot subclass

from pycord.multicog import Bot

my_bot = Bot()  # will automatically apply multicog when commands are being synchronised

Note that the cog attribute of the modified command (subcommand2 in the example) will be set to the cog of the slash command group (Cog1 instead of Cog2).

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

pycord-multicog-1.0.0.tar.gz (3.2 kB view hashes)

Uploaded Source

Built Distribution

pycord_multicog-1.0.0-py3-none-any.whl (3.6 kB view hashes)

Uploaded Python 3

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