-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discussion: Future of command contexts and making contextual information more verbose #153
Comments
I've also stumbled upon this issue, there have been several instances where I need to check what command was the reason for a event or condition, but its seemingly impossible or a huge pain to implement without library level support, and there's also this
|
You can return whatever For example, I want to log every moderation action (inside of an return Result<InfractionPostExectionData>.FromSuccess(new InfractionPostExectionData(createInfractionResult.Entity)); public async Task<Result> AfterExecutionAsync
(
ICommandContext context,
IResult commandResult,
CancellationToken ct = default
)
{
if (!commandResult.IsSuccess)
{
return Result.FromSuccess();
}
if (commandResult is not Result<InfractionPostExectionData> postExecutionDataResult)
{
return Result.FromSuccess();
}
} You could then extend this to simply return the type of the containing class and I know this is not really a solution to what you're saying, but for now, it is a good workaround. |
@Hamsterland thanks for the workaround, i will be using that for now, but that still leaves preexecutionevents and conditions, i hope one of the solutions velvet listed gets added soon:tm: |
[WIP] Rework context types (#153, solution 3)
Myself personally, and I'd assume some others have stumbled upon the issue of not being able to detremine what really happened upon command execution.
@Nihlus pointed out three distinct solutions that all have various pros in cons and regards to how to solve this issue.
Solution 1: Expanding
ICommandContext
This one is a simple change, and would add an
IChildNode
or the likes to the pre-existingICommandContext
and it's derivitives.This would more than likely be an
Optional<T>
property, seeing as contexts (namelyInteractionContext
) have had their usage scope expanded to more than just traditional commands (re: Interactivity)Solution 2: Node injection service
This change is also relatively simple, and piggybacks off a similar system that's currently in use by the command responders.
A new service would be added, by the names of
NodeInjectionService
or the likes. It will posses the current command node being invoked, much likeContextInjectionService
.Solution 3: Reworking context architecture
This solution is largest of the three, and involves reworking how contexts are handled and constructed.
Concrete types would posess a node property only if applicable, being omitted from the others.
ICommandContext
would be minimally affected by this, as new base classes would be rewritten to derive it, especially in the case of interactions, where anIInteractionContext
class would be spawned, andInteractionContext
andInteractionCommandContext
would derive from the former.The text was updated successfully, but these errors were encountered: