Setting DefaultRunMode doesn't work
hendrikdemir opened this issue · 7 comments
When trying to set the DefaultRunMode inside the configuration of the CommandService, nothing happens. The DefaultRunMode tends to always pick the sync version and ignores it when you try setting it to async:
.UseCommandService((context, config) =>
{
config = new CommandServiceConfig()
{
CaseSensitiveCommands = false,
LogLevel = LogSeverity.Verbose,
DefaultRunMode = RunMode.Async
};
})
However, when you try to just set the command to manually use RunMode.Async
, it works fine.
Maybe something you forgot to implement by accident?
Apologies for the delay, I never received an email for this issue for some reason. I use runmode async in my own bots and haven't encountered this. I shall investigate.
No problem. As I mentioned earlier, using [Command("name", RunMode = RunMode.Async)]
works. The issue starts when you try to use DefaultRunMode = RunMode.Async
, then it doesn't work.
The issue is your syntax, config is part of an action delegate which configures the actual CommandServiceConfig
when it's initialized into the service collection. Newing up an object is basically a no-op.
See the serilog sample for the correct syntax.
That makes sense, haha. Thanks for clearing it up!
@Directoire No probs. I'll see if I can add an assertion that protects against accidental misconfiguration. As an aside, it would be good if you could update your template repo so peeps don't make the same mistake.
Updated the template ;)
Thanks!