From fdf040c2186bfc63e4994807e9336d841d988992 Mon Sep 17 00:00:00 2001 From: austins Date: Wed, 6 Sep 2023 01:14:44 -0700 Subject: [PATCH] FollowupAsync ephemeral doesn't actually work, it uses whatever DeferAsync is --- .../Handlers/TranslateMessageCommandHandlerTests.cs | 10 +--------- .../Handlers/TranslateSlashCommandHandlerTests.cs | 7 ++----- .../Handlers/TranslateMessageCommandHandler.cs | 4 ---- .../Handlers/TranslateSlashCommandHandler.cs | 4 +--- 4 files changed, 4 insertions(+), 21 deletions(-) diff --git a/DiscordTranslationBot.Tests/Handlers/TranslateMessageCommandHandlerTests.cs b/DiscordTranslationBot.Tests/Handlers/TranslateMessageCommandHandlerTests.cs index 8cade83..bff2d10 100644 --- a/DiscordTranslationBot.Tests/Handlers/TranslateMessageCommandHandlerTests.cs +++ b/DiscordTranslationBot.Tests/Handlers/TranslateMessageCommandHandlerTests.cs @@ -84,7 +84,6 @@ await _command .Received(1) .FollowupAsync( embed: Arg.Is(x => x.Title == "Translated Message"), - ephemeral: true, options: Arg.Any() ); } @@ -167,7 +166,6 @@ await _command .Received(1) .FollowupAsync( embed: Arg.Is(x => x.Title == "Translated Message"), - ephemeral: true, options: Arg.Any() ); } @@ -186,11 +184,7 @@ public async Task Handle_MessageCommandExecutedNotification_Returns_WhenTranslat // Assert await _command .Received(1) - .FollowupAsync( - "Translating this bot's messages isn't allowed.", - ephemeral: true, - options: Arg.Any() - ); + .FollowupAsync("Translating this bot's messages isn't allowed.", options: Arg.Any()); } [Fact] @@ -225,7 +219,6 @@ await _command .Received(1) .FollowupAsync( $"Your locale {userLocale} isn't supported for translation via this action.", - ephemeral: true, options: Arg.Any() ); } @@ -268,7 +261,6 @@ await _command .Received(1) .FollowupAsync( "The message couldn't be translated. It might already be in your language or the translator failed to detect its source language.", - ephemeral: true, options: Arg.Any() ); } diff --git a/DiscordTranslationBot.Tests/Handlers/TranslateSlashCommandHandlerTests.cs b/DiscordTranslationBot.Tests/Handlers/TranslateSlashCommandHandlerTests.cs index af9408e..237134f 100644 --- a/DiscordTranslationBot.Tests/Handlers/TranslateSlashCommandHandlerTests.cs +++ b/DiscordTranslationBot.Tests/Handlers/TranslateSlashCommandHandlerTests.cs @@ -94,7 +94,7 @@ await _translationProvider Arg.Is(x => x.LangCode == sourceLanguage.LangCode) ); - await command.Received(1).DeferAsync(true, Arg.Any()); + await command.Received(1).DeferAsync(false, Arg.Any()); await command .Received(1) @@ -156,9 +156,7 @@ public async Task Handle_SlashCommandExecutedNotification_Returns_SourceTextIsEm await _sut.Handle(notification, CancellationToken.None); // Assert - await command - .Received(1) - .FollowupAsync("Nothing to translate.", ephemeral: true, options: Arg.Any()); + await command.Received(1).FollowupAsync("Nothing to translate.", options: Arg.Any()); await _translationProvider .DidNotReceive() @@ -244,7 +242,6 @@ await command .Received(1) .FollowupAsync( "Couldn't detect the source language to translate from or the result is the same.", - ephemeral: true, options: Arg.Any() ); } diff --git a/DiscordTranslationBot/Handlers/TranslateMessageCommandHandler.cs b/DiscordTranslationBot/Handlers/TranslateMessageCommandHandler.cs index 99d53c4..f9e1776 100644 --- a/DiscordTranslationBot/Handlers/TranslateMessageCommandHandler.cs +++ b/DiscordTranslationBot/Handlers/TranslateMessageCommandHandler.cs @@ -54,7 +54,6 @@ public async Task Handle(MessageCommandExecutedNotification notification, Cancel await notification.Command.FollowupAsync( "Translating this bot's messages isn't allowed.", - ephemeral: true, options: new RequestOptions { CancelToken = cancellationToken } ); @@ -119,7 +118,6 @@ await notification.Command.FollowupAsync( // Send message if no translation providers support the locale. await notification.Command.FollowupAsync( $"Your locale {userLocale} isn't supported for translation via this action.", - ephemeral: true, options: new RequestOptions { CancelToken = cancellationToken } ); @@ -132,7 +130,6 @@ await notification.Command.FollowupAsync( await notification.Command.FollowupAsync( "The message couldn't be translated. It might already be in your language or the translator failed to detect its source language.", - ephemeral: true, options: new RequestOptions { CancelToken = cancellationToken } ); @@ -164,7 +161,6 @@ await notification.Command.FollowupAsync( .WithUrl(GetJumpUrl(notification.Command.Data.Message).AbsoluteUri) .WithDescription(description) .Build(), - ephemeral: true, options: new RequestOptions { CancelToken = cancellationToken } ); } diff --git a/DiscordTranslationBot/Handlers/TranslateSlashCommandHandler.cs b/DiscordTranslationBot/Handlers/TranslateSlashCommandHandler.cs index 4a61807..e065f5a 100644 --- a/DiscordTranslationBot/Handlers/TranslateSlashCommandHandler.cs +++ b/DiscordTranslationBot/Handlers/TranslateSlashCommandHandler.cs @@ -40,7 +40,7 @@ public async Task Handle(SlashCommandExecutedNotification notification, Cancella return; } - await notification.Command.DeferAsync(true, new RequestOptions { CancelToken = cancellationToken }); + await notification.Command.DeferAsync(options: new RequestOptions { CancelToken = cancellationToken }); // Get the input values. var options = notification.Command.Data.Options; @@ -60,7 +60,6 @@ public async Task Handle(SlashCommandExecutedNotification notification, Cancella await notification.Command.FollowupAsync( "Nothing to translate.", - ephemeral: true, options: new RequestOptions { CancelToken = cancellationToken } ); @@ -89,7 +88,6 @@ await notification.Command.FollowupAsync( await notification.Command.FollowupAsync( "Couldn't detect the source language to translate from or the result is the same.", - ephemeral: true, options: new RequestOptions { CancelToken = cancellationToken } );