mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-04-20 00:43:36 +03:00
Show what default number is
Signed-off-by: Macintosh II <mctaylxrs@outlook.com>
This commit is contained in:
parent
cbf263622d
commit
6a961dac3d
5 changed files with 38 additions and 7 deletions
|
@ -660,4 +660,7 @@
|
||||||
<data name="RandomMax" xml:space="preserve">
|
<data name="RandomMax" xml:space="preserve">
|
||||||
<value>Maximum number: {0}</value>
|
<value>Maximum number: {0}</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Default" xml:space="preserve">
|
||||||
|
<value>(default)</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
|
|
|
@ -660,4 +660,7 @@
|
||||||
<data name="RandomMin" xml:space="preserve">
|
<data name="RandomMin" xml:space="preserve">
|
||||||
<value>Минимальное число: {0}</value>
|
<value>Минимальное число: {0}</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Default" xml:space="preserve">
|
||||||
|
<value>(по умолчанию)</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
|
|
|
@ -660,4 +660,7 @@
|
||||||
<data name="RandomMin" xml:space="preserve">
|
<data name="RandomMin" xml:space="preserve">
|
||||||
<value>наименьшее: {0}</value>
|
<value>наименьшее: {0}</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Default" xml:space="preserve">
|
||||||
|
<value>(дефолт)</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
|
|
|
@ -244,7 +244,7 @@ public class ToolsCommandGroup : CommandGroup
|
||||||
public async Task<Result> ExecuteRandomAsync(
|
public async Task<Result> ExecuteRandomAsync(
|
||||||
[Description("First number")] long first,
|
[Description("First number")] long first,
|
||||||
[Description("Second number (Default: 0)")]
|
[Description("Second number (Default: 0)")]
|
||||||
long second = 0)
|
long? second = null)
|
||||||
{
|
{
|
||||||
if (!_context.TryGetContextIDs(out var guildId, out _, out var userId))
|
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);
|
return await SendRandomNumberAsync(first, second, user, CancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Result> SendRandomNumberAsync(long first, long second, IUser user, CancellationToken ct)
|
private async Task<Result> SendRandomNumberAsync(long first, long? secondNullable,
|
||||||
|
IUser user, CancellationToken ct)
|
||||||
{
|
{
|
||||||
|
var second = secondNullable ?? 0;
|
||||||
|
|
||||||
var min = Math.Min(first, second);
|
var min = Math.Min(first, second);
|
||||||
var max = Math.Max(first, second);
|
var max = Math.Max(first, second);
|
||||||
|
|
||||||
var i = Random.Shared.NextInt64(min, max + 1);
|
var i = Random.Shared.NextInt64(min, max + 1);
|
||||||
|
|
||||||
var description = new StringBuilder().Append("# ").AppendLine(i.ToString())
|
var description = new StringBuilder().Append("# ").Append(i);
|
||||||
.Append("- ").AppendLine(string.Format(Messages.RandomMin, Markdown.InlineCode(min.ToString())))
|
|
||||||
.Append("- ").AppendLine(string.Format(Messages.RandomMax, Markdown.InlineCode(max.ToString())));
|
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;
|
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;
|
embedColor = ColorsList.Red;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
7
src/Messages.Designer.cs
generated
7
src/Messages.Designer.cs
generated
|
@ -1149,5 +1149,12 @@ namespace Octobot {
|
||||||
return ResourceManager.GetString("RandomMin", resourceCulture);
|
return ResourceManager.GetString("RandomMin", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static string Default
|
||||||
|
{
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("Default", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue