Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: run only local hooks for SlashCommandGroup #2139

Merged
merged 3 commits into from Jun 25, 2023

Conversation

OmLanke
Copy link
Contributor

@OmLanke OmLanke commented Jun 23, 2023

Summary

Fixes bot and cog before_invoke hooks being called twice for subcommands (once with ctx.command set to the group, and once with ctx.command set to the subcommand). Fixes #2134 as discussed in the discord server.

This bug originally arised due to #2091 cleaning up the prepare logic. I personally would have considered a feature rather than a bug.

Information

  • 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, ...).

Checklist

  • I have searched the open pull requests for duplicates.
  • 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.
  • I have updated the changelog to include these changes.

@codecov
Copy link

codecov bot commented Jun 23, 2023

Codecov Report

Merging #2139 (97b6641) into master (27d7782) will decrease coverage by 0.02%.
The diff coverage is 14.28%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2139      +/-   ##
==========================================
- Coverage   33.87%   33.86%   -0.02%     
==========================================
  Files         109      109              
  Lines       22353    22367      +14     
==========================================
+ Hits         7573     7575       +2     
- Misses      14780    14792      +12     
Flag Coverage Δ
macos-latest-3.10 33.84% <14.28%> (-0.02%) ⬇️
macos-latest-3.11 33.84% <14.28%> (-0.02%) ⬇️
macos-latest-3.8 33.85% <14.28%> (-0.02%) ⬇️
macos-latest-3.9 33.85% <14.28%> (-0.02%) ⬇️
ubuntu-latest-3.10 33.84% <14.28%> (-0.02%) ⬇️
ubuntu-latest-3.11 33.84% <14.28%> (-0.02%) ⬇️
ubuntu-latest-3.8 33.85% <14.28%> (-0.02%) ⬇️
ubuntu-latest-3.9 33.85% <14.28%> (-0.02%) ⬇️
windows-latest-3.10 33.84% <14.28%> (-0.02%) ⬇️
windows-latest-3.11 33.84% <14.28%> (-0.02%) ⬇️
windows-latest-3.8 33.85% <14.28%> (-0.02%) ⬇️
windows-latest-3.9 33.85% <14.28%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
discord/commands/core.py 40.30% <14.28%> (-0.44%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 27d7782...97b6641. Read the comment docs.

@Lulalaby
Copy link
Member

Changelog

Lulalaby
Lulalaby previously approved these changes Jun 23, 2023
@Lulalaby Lulalaby enabled auto-merge (squash) June 23, 2023 22:20
Copy link
Member

@JustaSqu1d JustaSqu1d left a comment

Choose a reason for hiding this comment

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

type: ignore comments were used but lacked additional rationale (unless I am missing something).

@OmLanke
Copy link
Contributor Author

OmLanke commented Jun 24, 2023

type: ignore comments were used but lacked additional rationale (unless I am missing something).

I just copy pasted the methods from ApplicationCommand and removed the Cog and Bot scoped hooks. The type: ignore comments were used there too. Idk why they are used

@Lulalaby
Copy link
Member

then we keep it like that

Signed-off-by: Om <92863779+Om1609@users.noreply.github.com>
auto-merge was automatically disabled June 25, 2023 16:06

Head branch was pushed to by a user without write access

@Lulalaby Lulalaby enabled auto-merge (squash) June 25, 2023 16:24
@Lulalaby Lulalaby merged commit 297053d into Pycord-Development:master Jun 25, 2023
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bot.before_invoke function runs twice with slash sub commands causing a whole bunch of issues
3 participants