serenity-rs / framework

The official command framework for bots written in Serenity

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Contain &Message in FrameworkContext

kangalio opened this issue · comments

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

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.

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