Description
I have a specific use case where I must have my slash command methods in my commands "module" to be async and part of making things async is to make it return ValueTask. Since the code throws InvalidDefinitionException it can special case ValueTask and run the command in Async. Also it is interesting that if one needs to return NetCord.Rest.InteractionMessageProperties in said ValueTask (just so they can mark some of the Flags on some of the responses as Ephemeral others with Flags not set, but with Embeds set in its place).
Just a few cases where doing so simply crashed my bot since the exception bubbles up to my minimal Program.cs.
What I use in the commands that makes me need to have it Async:
Ironically returning only InteractionMessageProperties and having a copy of the custom async methods I added to my DbContext for the bot, and calling the non-async version of CreateDbContext from IDbContextFactory<T> works., however I would have expected the async version with it wrapped in ValueTask to also work since the rest of NetCord is async in nature.
The reason why I used EFCore's async methods when implementing my own async methods is so that way I could avoid some threading issues where it would have problems with the DbContext since it is not thread safe.
Description
I have a specific use case where I must have my slash command methods in my commands "module" to be
asyncand part of making things async is to make it returnValueTask. Since the code throwsInvalidDefinitionExceptionit can special caseValueTaskand run the command in Async. Also it is interesting that if one needs to returnNetCord.Rest.InteractionMessagePropertiesin saidValueTask(just so they can mark some of theFlagson some of the responses asEphemeralothers with Flags not set, but withEmbedsset in its place).Just a few cases where doing so simply crashed my bot since the exception bubbles up to my minimal
Program.cs.What I use in the commands that makes me need to have it Async:
Ironically returning only
InteractionMessagePropertiesand having a copy of the custom async methods I added to myDbContextfor the bot, and calling the non-async version ofCreateDbContextfromIDbContextFactory<T>works., however I would have expected the async version with it wrapped inValueTaskto also work since the rest of NetCord is async in nature.The reason why I used EFCore's async methods when implementing my own async methods is so that way I could avoid some threading issues where it would have problems with the DbContext since it is not thread safe.