From 00a7b5b5ad0a65407a921de51a9fc479c5450452 Mon Sep 17 00:00:00 2001 From: Macintosh II Date: Sun, 1 Oct 2023 19:46:52 +0300 Subject: [PATCH] Update /random --- locale/Messages.resx | 9 +++++++++ locale/Messages.ru.resx | 9 +++++++++ locale/Messages.tt-ru.resx | 9 +++++++++ src/Commands/ToolsCommandGroup.cs | 18 ++++++++++++++---- src/Messages.Designer.cs | 21 +++++++++++++++++++++ 5 files changed, 62 insertions(+), 4 deletions(-) diff --git a/locale/Messages.resx b/locale/Messages.resx index 7b9a471..67ec5d4 100644 --- a/locale/Messages.resx +++ b/locale/Messages.resx @@ -654,4 +654,13 @@ Your random number is: + + Isn't it obvious? + + + Minimum number: {0} + + + Maximum number: {0} + diff --git a/locale/Messages.ru.resx b/locale/Messages.ru.resx index 3e31f8f..dfa7d09 100644 --- a/locale/Messages.ru.resx +++ b/locale/Messages.ru.resx @@ -654,4 +654,13 @@ Ваше случайное число: + + Разве это не очевидно? + + + Максимальное число: {0} + + + Минимальное число: {0} + diff --git a/locale/Messages.tt-ru.resx b/locale/Messages.tt-ru.resx index df98622..7a6bfe8 100644 --- a/locale/Messages.tt-ru.resx +++ b/locale/Messages.tt-ru.resx @@ -654,4 +654,13 @@ ваше рандомное число: + + ну чувак... + + + наибольшее: {0} + + + наименьшее: {0} + diff --git a/src/Commands/ToolsCommandGroup.cs b/src/Commands/ToolsCommandGroup.cs index 64e6729..e19f484 100644 --- a/src/Commands/ToolsCommandGroup.cs +++ b/src/Commands/ToolsCommandGroup.cs @@ -243,8 +243,8 @@ public class ToolsCommandGroup : CommandGroup [UsedImplicitly] public async Task ExecuteRandomAsync( [Description("Maximum number")] int max, - [Description("Minumum number (Default: 1)")] - int min = 1) + [Description("Minumum number (Default: 0)")] + int min = 0) { if (!_context.TryGetContextIDs(out var guildId, out _, out var userId)) { @@ -282,9 +282,19 @@ public class ToolsCommandGroup : CommandGroup var i = Random.Shared.Next(min, max + 1); + var description = new StringBuilder().Append("# ").AppendLine(i.ToString()) + .Append("- ").AppendLine(string.Format(Messages.RandomMin, Markdown.InlineCode(min.ToString()))) + .Append("- ").AppendLine(string.Format(Messages.RandomMax, Markdown.InlineCode(max.ToString()))); + var embedColor = ColorsList.Blue; + if (min == max) + { + description.AppendLine(Markdown.Italicise(Messages.RandomObvious)); + embedColor = ColorsList.Red; + } + var embed = new EmbedBuilder().WithSmallTitle(Messages.RandomOutput, user) - .WithDescription($"# {i}\n({min}-{max})") - .WithColour(ColorsList.Blue) + .WithDescription(description.ToString()) + .WithColour(embedColor) .Build(); return await _feedback.SendContextualEmbedResultAsync(embed, ct); diff --git a/src/Messages.Designer.cs b/src/Messages.Designer.cs index 3c2c747..cd5a67f 100644 --- a/src/Messages.Designer.cs +++ b/src/Messages.Designer.cs @@ -1135,5 +1135,26 @@ namespace Octobot { return ResourceManager.GetString("RandomOutput", resourceCulture); } } + + internal static string RandomObvious + { + get { + return ResourceManager.GetString("RandomObvious", resourceCulture); + } + } + + internal static string RandomMax + { + get { + return ResourceManager.GetString("RandomMax", resourceCulture); + } + } + + internal static string RandomMin + { + get { + return ResourceManager.GetString("RandomMin", resourceCulture); + } + } } }