Skip to content

useCog decorator #87

@Trimatix

Description

@Trimatix
@useCog(myCog="MyCog")
@BasedCog.staticComponentCallback(StaticComponents.My_Component)
async def myComponentCallback(self, interaction: Interaction, args: str, myCog: MyCog):
    myCog.doStuff()

wrap function in another
try to get a cog called myCog
if you can't get it then make a log with the name of the wrapped function and the cog name, then return
if you can the cog then call the wrapped function
should work for any function in a cog, e.g static component callback or command

https://github.com/GOF2BountyBot/GOF2BountyBot/blob/a3237234083bea59763b1e8d3212e9b029360f1b/bot/cogs/DevMiscCog.py#L64

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions