Configure CNext to allow marking the MessageCreate event as handled
Created by: Evengard
Summary
This adds a configuration option to CNext to allow marking the MessageCreate event as handled (and subsequently stopping invocation of other MessageCreate events) in case if a command was found for the message.
Details
Sometimes you want to make sure that the command you are using won't be propagated to subsequent MessageCreate event handlers, to make sure for your custom MessageCreate handler that it is not a command message. One way to do it is to write a custom command handler, but then you need to either copy the command handler source code to retain the same behaviour, or use reflection (because the handler is private). This creates an option to mark the event as handled if a command was found and tasked to be executed, which prevents subsequent event handlers to be called.
Changes proposed
This adds a CommandsNextConfiguration.SignalHandledOnCommandFound
CommandsNextConfiguration.MarkEventAsHandled
option, which, if true, makes the default command handler (CommandsNextExtension.HandleCommandsAsync
) to mark the MessageCreateEventArgs event as Handled (setting e.Handled = true
).
The default value is false (which does nothing) due to backward compatibility.