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

Include bot in interaction context #58

Merged
merged 1 commit into from Sep 1, 2021

Conversation

jgayfer
Copy link
Contributor

@jgayfer jgayfer commented Sep 1, 2021

Summary

Currently incoming application commands have no direct reference to the
bot instance. This change includes the bot instance in our interaction
context, much like how we do it in the commands extension.

Having a reference to the bot is pretty handy, and fits well with the
existing design of the library.

A reference to the bot will also allow us to more easily reference a
potential before_invoke or after_invoke hook from within
discord.app.commands.

Finally, by exposing a public get_context method, we open up the ability
to define a custom context, a feature currently supported by the
commands extension.

Caveats

I have not tested this with user or message commands (not entirely sure how to setup). I can revisit this area once I get a better idea if this is a direction we'd like to pursue.

Checklist

  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • 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, ...)

@jgayfer jgayfer marked this pull request as ready for review September 1, 2021 20:15
discord/app/context.py Outdated Show resolved Hide resolved
discord/bot.py Outdated Show resolved Hide resolved
Copy link
Member

@Middledot Middledot left a comment

Choose a reason for hiding this comment

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

You can add these

discord/bot.py Outdated Show resolved Hide resolved
discord/bot.py Outdated Show resolved Hide resolved
@jgayfer jgayfer force-pushed the context-bot branch 2 times, most recently from 4140060 to 8335366 Compare September 1, 2021 23:38
Currently incoming application commands have no direct reference to the
bot instance. This change includes the bot instance in our interaction
context, much like how we do it in the commands extension.

Having a reference to the bot is pretty handy, and fits well with the
existing design of the library.

A reference to the bot will also allow us to more easily reference a
potential before_invoke or after_invoke hook from within
discord.app.commands.

Finally, by exposing a public get_context method, we open up the ability
to define a custom context, a feature currently supported by the
commands extension.
@jgayfer
Copy link
Contributor Author

jgayfer commented Sep 1, 2021

@Middledot Thanks! Ready for another look.

@Middledot Middledot merged commit 18283a7 into Pycord-Development:master Sep 1, 2021
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.

None yet

3 participants