1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-05-02 03:59:53 +03:00

Update /random

This commit is contained in:
Macintxsh 2023-10-01 19:46:52 +03:00
parent 186eb65eb1
commit 00a7b5b5ad
Signed by: mctaylors
GPG key ID: 361D326747B61E65
5 changed files with 62 additions and 4 deletions

View file

@ -243,8 +243,8 @@ public class ToolsCommandGroup : CommandGroup
[UsedImplicitly]
public async Task<Result> 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);

View file

@ -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);
}
}
}
}