diff --git a/locale/Messages.resx b/locale/Messages.resx
index 282e678..4d84198 100644
--- a/locale/Messages.resx
+++ b/locale/Messages.resx
@@ -648,4 +648,10 @@
Nitro booster since
+
+ The minimum number is greater than the maximum!
+
+
+ Your random number is:
+
diff --git a/locale/Messages.ru.resx b/locale/Messages.ru.resx
index 77e3838..a7823df 100644
--- a/locale/Messages.ru.resx
+++ b/locale/Messages.ru.resx
@@ -648,4 +648,10 @@
Начал бустить сервер
+
+ Минимальное число больше чем максимальное!
+
+
+ Ваше случайное число:
+
diff --git a/locale/Messages.tt-ru.resx b/locale/Messages.tt-ru.resx
index b0335a8..5a08755 100644
--- a/locale/Messages.tt-ru.resx
+++ b/locale/Messages.tt-ru.resx
@@ -648,4 +648,10 @@
бустит сервер со времен
-
\ No newline at end of file
+
+ почему минимальное > максимальное
+
+
+ ваше рандомное число:
+
+
diff --git a/src/Commands/ToolsCommandGroup.cs b/src/Commands/ToolsCommandGroup.cs
index 3ac8b70..f60c109 100644
--- a/src/Commands/ToolsCommandGroup.cs
+++ b/src/Commands/ToolsCommandGroup.cs
@@ -228,4 +228,51 @@ public class ToolsCommandGroup : CommandGroup
Messages.DescriptionActionExpiresAt, Markdown.Timestamp(communicationDisabledUntil.Value)));
}
}
+
+ [Command("random")]
+ [DiscordDefaultDMPermission(false)]
+ [Description("Generates a random number")]
+ [UsedImplicitly]
+ public async Task ExecuteRandomAsync(int max, int min = 1)
+ {
+ if (!_context.TryGetContextIDs(out _, out _, out var userId))
+ {
+ return new ArgumentInvalidError(nameof(_context), "Unable to retrieve necessary IDs from command context");
+ }
+
+ var currentUserResult = await _userApi.GetCurrentUserAsync(CancellationToken);
+ if (!currentUserResult.IsDefined(out var currentUser))
+ {
+ return Result.FromError(currentUserResult);
+ }
+
+ var userResult = await _userApi.GetUserAsync(userId, CancellationToken);
+ if (!userResult.IsDefined(out var user))
+ {
+ return Result.FromError(userResult);
+ }
+
+ return await SendRandomAsync(max, min, user, currentUser, CancellationToken);
+ }
+
+ private async Task SendRandomAsync(int max, int min, IUser user, IUser currentUser, CancellationToken ct)
+ {
+ if (min > max)
+ {
+ var failedEmbed = new EmbedBuilder().WithSmallTitle(
+ Messages.RandomMinGreaterThanMax, currentUser)
+ .WithColour(ColorsList.Red).Build();
+
+ return await _feedback.SendContextualEmbedResultAsync(failedEmbed, ct);
+ }
+
+ var i = Random.Shared.Next(min, max + 1);
+
+ var embed = new EmbedBuilder().WithSmallTitle(Messages.RandomOutput, user)
+ .WithDescription($"# {i}\n({min}-{max})")
+ .WithColour(ColorsList.Blue)
+ .Build();
+
+ return await _feedback.SendContextualEmbedResultAsync(embed, ct);
+ }
}
diff --git a/src/Messages.Designer.cs b/src/Messages.Designer.cs
index 8784b90..ae712df 100644
--- a/src/Messages.Designer.cs
+++ b/src/Messages.Designer.cs
@@ -1121,5 +1121,19 @@ namespace Boyfriend {
return ResourceManager.GetString("ShowInfoGuildMemberPremiumSince", resourceCulture);
}
}
+
+ internal static string RandomMinGreaterThanMax
+ {
+ get {
+ return ResourceManager.GetString("RandomMinGreaterThanMax", resourceCulture);
+ }
+ }
+
+ internal static string RandomOutput
+ {
+ get {
+ return ResourceManager.GetString("RandomOutput", resourceCulture);
+ }
+ }
}
}