pycord-v3 icon indicating copy to clipboard operation
pycord-v3 copied to clipboard

Dependency Injection

Open VincentRPS opened this issue 2 years ago • 0 comments

Add support for sub command/listener dependency injection:

@bot.command(call_once=True)
async def my_command(self, pre: pycord.Prelude) -> pycord.Dependency:
    return pycord.Dependency(pycord.Prelude, pre)

@my_command.command()
async def my_subcommand(self, pre: pycord.Prelude, pr: pycord.Prelude) -> None:
    await pr.send(...)

That is a really dumbed down version of the Dependency injection formula we may adopt. The main command function can also return a list of dependencies if require, and the dependencies go truly like: type, value, where the type is the id defining the Dependency.

VincentRPS avatar Mar 04 '23 12:03 VincentRPS