Skip to content

Commit

Permalink
fix: ephemeral error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
NyuwBot committed Jan 1, 2024
1 parent cbb4b4e commit 05d0d6b
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1158,18 +1158,14 @@ private Task InteractionHandler(DiscordClient client, InteractionCreateEventArgs
break;
}
case InteractionType.AutoComplete when s_errored:
await e.Interaction.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder().WithContent("Application commands failed to register properly on startup.")).ConfigureAwait(false);
throw new InvalidOperationException("Application commands failed to register properly on startup.");
case InteractionType.AutoComplete:
{
var methods = CommandMethods.Where(x => x.CommandId == e.Interaction.Data.Id).ToList();
var groups = GroupCommands.Where(x => x.CommandId == e.Interaction.Data.Id).ToList();
var subgroups = SubGroupCommands.Where(x => x.CommandId == e.Interaction.Data.Id).ToList();
if (methods.Count is 0 && groups.Count is 0 && subgroups.Count is 0)
{
await e.Interaction.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder().WithContent("An autocomplete interaction was created, but no command was registered for it")).ConfigureAwait(false);
throw new InvalidOperationException("An autocomplete interaction was created, but no command was registered for it");
}

try
{
Expand Down Expand Up @@ -1361,7 +1357,7 @@ private Task ContextMenuHandler(DiscordClient client, ContextMenuInteractionCrea
{
if (s_errored)
{
await e.Interaction.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder().WithContent("Context menus failed to register properly on startup.")).ConfigureAwait(false);
await e.Interaction.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder().WithContent("Context menus failed to register properly on startup.").AsEphemeral()).ConfigureAwait(false);
throw new InvalidOperationException("Context menus failed to register properly on startup.");
}

Expand All @@ -1370,7 +1366,7 @@ private Task ContextMenuHandler(DiscordClient client, ContextMenuInteractionCrea

if (method == null)
{
await e.Interaction.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder().WithContent("A context menu command was executed, but no command was registered for it.")).ConfigureAwait(false);
await e.Interaction.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder().WithContent("A context menu command was executed, but no command was registered for it.").AsEphemeral()).ConfigureAwait(false);
throw new InvalidOperationException("A context menu command was executed, but no command was registered for it.");
}

Expand Down

0 comments on commit 05d0d6b

Please sign in to comment.