Skip to content

Conversation

DaTurr3t
Copy link
Contributor

@DaTurr3t DaTurr3t commented Mar 10, 2022

Summary

This PR fixes two simple things:

  1. Application Commands in Cogs not having their cog set (see this Issue).
  2. Checking if an Application Command is in a cog and calling its callback accordingly.

This means you can use ctx.invoke() for slash commands again like so:

class TestCog(commands.Cog):
    def __init__(self, bot: discord.Bot) -> None:
        self.bot = bot

    @slash_command(guild_ids=gids)
    async def other_command(self, ctx, greet) -> None:
        await ctx.respond(f"{greet} I should run now!")

    @slash_command(guild_ids=gids)
    async def invoke_test(self, ctx) -> None:
        await ctx.invoke(self.other_command, "Hi!")

Checklist

  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • If type: ignore comments were used, a comment is also left explaining why
  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, typehinting, examples, ...)

Copy link
Contributor

@krittick krittick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, tested with cogs and regression tested without cogs. ApplicationContext.invoke now works properly for both situations.

@krittick krittick added this to the v2.0 milestone Mar 11, 2022
@krittick krittick added bug Something isn't working priority: high High Priority status: awaiting review Awaiting review from a maintainer Merge with squash labels Mar 11, 2022
@krittick krittick enabled auto-merge (squash) March 11, 2022 21:47
@krittick krittick merged commit ac7d3c4 into Pycord-Development:master Mar 12, 2022
@DaTurr3t DaTurr3t deleted the fix_invoke_cog_slash_cmds branch March 13, 2022 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority: high High Priority status: awaiting review Awaiting review from a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants