serenity-rs / poise

Discord bot command framework for serenity, with advanced features like edit tracking and flexible argument parsing
MIT License
597 stars 106 forks source link

Handle events and still using the poise context #250

Closed zbrox closed 4 months ago

zbrox commented 4 months ago

I'm trying to figure out how to handle events outside of commands, like leaving certain reactions on messages for example, and still use already built functions I have to post messages in response to said events. Plenty of those require the poise context but the current event handler is using the serenity context.

Am I missing something obvious? Is there an established way to do such a thing?

kangalio commented 4 months ago

Poise context consists of serenity context plus information about the channel and author etc of the command invocation. Poise's reply functions are wrappers around serenity's message post functions, with the channel ID pre-populated. But you can still use serenity's own functions, mainly ChannelId.send_message, to send messages outside of a command invocation context, where poise Context cannot be available, like the event handler