Skip to content

Commit

Permalink
fix bug in Translation command
Browse files Browse the repository at this point in the history
Signed-off-by: Plerx <50530305+Plerx2493@users.noreply.github.com>
  • Loading branch information
Plerx2493 committed Aug 11, 2024
1 parent 7af7f46 commit 3f93697
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public async Task TranslateText
[Description("The text you want to translate")]
string text,
[Description("The language you want to get (default: en)"), SlashAutoCompleteProvider(typeof(TargetLanguageAutoCompletion))]
string language = "en",
string? language = null,
[Description("Weather the result should be public or not (default: false)")]
bool publicResult = false
)
Expand All @@ -85,6 +85,13 @@ await ctx.EditResponseAsync(new DiscordWebhookBuilder()
.WithContent("⚠️ Text can't be empty!"));
return;
}

if (language is null)
{
string? lang = await _translationUserInfo.GetPreferredLanguageAsync(ctx.User.Id);

language = lang ?? "en-US";
}

TextResult translatedText = await _translator.TranslateTextAsync(text, null, language);

Expand Down

0 comments on commit 3f93697

Please sign in to comment.