Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Contain &Message in FrameworkContext #26

Open
kangalio opened this issue Feb 22, 2021 · 2 comments
Open

Contain &Message in FrameworkContext #26

kangalio opened this issue Feb 22, 2021 · 2 comments
Labels
feature request Proposition for a new feature or improvement

Comments

@kangalio
Copy link
Contributor

The FrameworkContext docs state: this context type contains every data that's relevant to the command. Would it be possible to move the &Message parameter, that every command function currently had, into FrameworkContext as well?

  • it would make command functions shorter and cleaner
  • it would be more consistent (since other data relevant to the command already resides in FrameworkContext)
  • it encapsulates all useful command context into a single struct that can be passed around easily (for example in my bot using this framework I will have to pass around both FrameworkContext and &Message to a certain utility function, which seems redundant)

Is there an issue with the proposal that I hadn't considered? Otherwise I'd gladly create a PR for this

@vicky5124
Copy link

vicky5124 commented Feb 22, 2021

Having Message inside Context would mean that it would have to be in an Option, making it less convenient to use, as FrameworkContext may appear in methods that do not involve commands.
I personally prefer to have them split, it's something i really liked about this library over other's such as d.py
I also don't think it would be cleaner, as it would mean that doing simple stuff such as sending a message would need another item on the tree context.message.channel_id.say() instead of msg.channel_id.say(), or following a previous point context.message.unwrap().channel_id.say() (i do not think msg would be a good field name).
Having the user do let msg = context.message.unwrap() on every single time would just defeat the point of this, and it's better to keep it as it's own function parameter.

@kangalio
Copy link
Contributor Author

That sounds sensible. I'm interested in which circumstances FrameworkContext appears outside of commands?

@arqunis arqunis added the feature request Proposition for a new feature or improvement label Feb 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature request Proposition for a new feature or improvement
Projects
None yet
Development

No branches or pull requests

3 participants