Fix channel being null in DMs on Interactions (#2098)

This commit is contained in:
Quin Lynch
2022-02-11 21:43:32 -04:00
committed by GitHub
parent 0352374e74
commit 7e1b8c9db0
12 changed files with 111 additions and 64 deletions

View File

@@ -57,11 +57,9 @@ namespace Discord.Interactions
bool isValid = false;
if ((Contexts & ContextType.Guild) != 0)
isValid = context.Channel is IGuildChannel;
if ((Contexts & ContextType.DM) != 0)
isValid = isValid || context.Channel is IDMChannel;
if ((Contexts & ContextType.Group) != 0)
isValid = isValid || context.Channel is IGroupChannel;
isValid = !context.Interaction.IsDMInteraction;
if ((Contexts & ContextType.DM) != 0 && (Contexts & ContextType.Group) != 0)
isValid = context.Interaction.IsDMInteraction;
if (isValid)
return Task.FromResult(PreconditionResult.FromSuccess());