mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-05-02 03:59:53 +03:00
Update /random
This commit is contained in:
parent
186eb65eb1
commit
00a7b5b5ad
5 changed files with 62 additions and 4 deletions
|
@ -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);
|
||||
|
|
21
src/Messages.Designer.cs
generated
21
src/Messages.Designer.cs
generated
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue