Skip to content

Commit

Permalink
Patch for floodcheckers (#329)
Browse files Browse the repository at this point in the history
#!components: grid-bot
#!deployable-components: grid-bot

ExecuteScript.cs:
~ Updates the error message to properly notify the correct type of command.

OnSlashCommandExecuted.cs:
~ Fix where exception is now a InteractionException for some reason.
  • Loading branch information
nikita-petko authored Jul 31, 2024
1 parent f268627 commit 284f34d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion services/grid-bot/lib/commands/Modules/ExecuteScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public override async Task BeforeExecuteAsync(ICommandInfo command)

var perUserFloodChecker = _floodCheckerRegistry.GetPerUserScriptExecutionFloodChecker(Context.User.Id);
if (perUserFloodChecker.IsFlooded())
throw new ApplicationException("You are sending render commands too quickly, please wait a few moments and try again.");
throw new ApplicationException("You are sending execute script commands too quickly, please wait a few moments and try again.");

perUserFloodChecker.UpdateCount();
}
Expand Down
13 changes: 13 additions & 0 deletions services/grid-bot/lib/events/Events/OnSlashCommandExecuted.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,19 @@ public async Task Invoke(ICommandInfo command, IInteractionContext context, IRes

var ex = executeResult.Exception;

if (ex is not InteractionException interactionException)
{
_backtraceUtility.UploadException(ex);

await interaction.FollowupAsync(
$"An unexpected Exception has occurred. Exception ID: {Guid.NewGuid()}, send this ID to <@!{_discordRolesSettings.BotOwnerId}>"
);

return;
}

ex = interactionException.InnerException;

// Check if it is a Missing Permissions exception from Discord.
if (ex is Discord.Net.HttpException httpException && httpException.DiscordCode == DiscordErrorCode.MissingPermissions)
{
Expand Down

0 comments on commit 284f34d

Please sign in to comment.