diff --git a/locale/Messages.resx b/locale/Messages.resx
index 5a18a42..bda56cf 100644
--- a/locale/Messages.resx
+++ b/locale/Messages.resx
@@ -660,4 +660,7 @@
Maximum number: {0}
+
+ (default)
+
diff --git a/locale/Messages.ru.resx b/locale/Messages.ru.resx
index 6ca6412..f627842 100644
--- a/locale/Messages.ru.resx
+++ b/locale/Messages.ru.resx
@@ -660,4 +660,7 @@
Минимальное число: {0}
+
+ (по умолчанию)
+
diff --git a/locale/Messages.tt-ru.resx b/locale/Messages.tt-ru.resx
index 098fd5a..49e7093 100644
--- a/locale/Messages.tt-ru.resx
+++ b/locale/Messages.tt-ru.resx
@@ -660,4 +660,7 @@
наименьшее: {0}
+
+ (дефолт)
+
diff --git a/src/Commands/ToolsCommandGroup.cs b/src/Commands/ToolsCommandGroup.cs
index c5c1fc7..65897b2 100644
--- a/src/Commands/ToolsCommandGroup.cs
+++ b/src/Commands/ToolsCommandGroup.cs
@@ -244,7 +244,7 @@ public class ToolsCommandGroup : CommandGroup
public async Task ExecuteRandomAsync(
[Description("First number")] long first,
[Description("Second number (Default: 0)")]
- long second = 0)
+ long? second = null)
{
if (!_context.TryGetContextIDs(out var guildId, out _, out var userId))
{
@@ -263,21 +263,36 @@ public class ToolsCommandGroup : CommandGroup
return await SendRandomNumberAsync(first, second, user, CancellationToken);
}
- private async Task SendRandomNumberAsync(long first, long second, IUser user, CancellationToken ct)
+ private async Task SendRandomNumberAsync(long first, long? secondNullable,
+ IUser user, CancellationToken ct)
{
+ var second = secondNullable ?? 0;
+
var min = Math.Min(first, second);
var max = Math.Max(first, second);
var i = Random.Shared.NextInt64(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 description = new StringBuilder().Append("# ").Append(i);
+
+ description.AppendLine().Append("- ").Append(string.Format(
+ Messages.RandomMin, Markdown.InlineCode(min.ToString())));
+ if (secondNullable is null && first >= 0)
+ {
+ description.Append(' ').Append(Messages.Default);
+ }
+
+ description.AppendLine().Append("- ").Append(string.Format(
+ Messages.RandomMax, Markdown.InlineCode(max.ToString())));
+ if (secondNullable is null && first < 0)
+ {
+ description.Append(' ').Append(Messages.Default);
+ }
var embedColor = ColorsList.Blue;
- if (min == max)
+ if (secondNullable is not null && min == max)
{
- description.AppendLine(Markdown.Italicise(Messages.RandomMinMaxSame));
+ description.AppendLine().Append(Markdown.Italicise(Messages.RandomMinMaxSame));
embedColor = ColorsList.Red;
}
diff --git a/src/Messages.Designer.cs b/src/Messages.Designer.cs
index 7c81ab2..7f93fa2 100644
--- a/src/Messages.Designer.cs
+++ b/src/Messages.Designer.cs
@@ -1149,5 +1149,12 @@ namespace Octobot {
return ResourceManager.GetString("RandomMin", resourceCulture);
}
}
+
+ internal static string Default
+ {
+ get {
+ return ResourceManager.GetString("Default", resourceCulture);
+ }
+ }
}
}