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 required parameters validation error #1589

Merged
merged 4 commits into from
Aug 24, 2022

Conversation

Middledot
Copy link
Member

Summary

def run_bot():
    bot = CustomBot()

    @bot.slash_command()
    async def test(ctx):
        pass

    bot.run(...)
Traceback (most recent call last):
  ...
  File "discord\commands\core.py", line 681, in _parse_options
    params = self._check_required_params(params)
  File "discord\commands\core.py", line 675, in _check_required_params
    raise ClientException(f'Callback for {self.name} command is missing "{p}" parameter.')
discord.errors.ClientException: Callback for test command is missing "context" parameter.

command.__qualname__ is run_bot.<locals>.test
I figured this fix would be better than manually patching edge cases.

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.

@Middledot Middledot added the bug Something isn't working label Aug 24, 2022
Lulalaby
Lulalaby previously approved these changes Aug 24, 2022
@Dorukyum
Copy link
Member

Good chat, but I don't get the point of is_in_cog; isn't that just .cog is not None

@Middledot
Copy link
Member Author

.cog is None by default so there would need to be a trigger to start validating the options. But it can be replaced with the cog attr.

Copy link
Member

@Dorukyum Dorukyum left a comment

Choose a reason for hiding this comment

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

Looks good, thank you

@Middledot Middledot merged commit 3b1a281 into Pycord-Development:master Aug 24, 2022
@Middledot Middledot deleted the fix-param-validation branch August 25, 2022 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants