From 58e59a208fbfb7c9ccaed0917b4763e6b06df7cb Mon Sep 17 00:00:00 2001 From: Toastie Date: Sat, 17 Aug 2024 18:51:32 +1200 Subject: [PATCH] Small cleanup of gamestatusevent --- .../Modules/Gambling/Events/GameStatusEvent.cs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/EllieBot/Modules/Gambling/Events/GameStatusEvent.cs b/src/EllieBot/Modules/Gambling/Events/GameStatusEvent.cs index aeb23c0..1c461d6 100644 --- a/src/EllieBot/Modules/Gambling/Events/GameStatusEvent.cs +++ b/src/EllieBot/Modules/Gambling/Events/GameStatusEvent.cs @@ -27,17 +27,13 @@ public class GameStatusEvent : ICurrencyEvent private readonly string _code; - private readonly char[] _sneakyGameStatusChars = Enumerable.Range(48, 10) - .Concat(Enumerable.Range(65, 26)) - .Concat(Enumerable.Range(97, 26)) - .Select(x => (char)x) - .ToArray(); - private readonly object _stopLock = new(); private readonly object _potLock = new(); private readonly IMessageSenderService _sender; + private static readonly EllieRandom _rng = new EllieRandom(); + public GameStatusEvent( DiscordSocketClient client, ICurrencyService cs, @@ -58,7 +54,7 @@ public class GameStatusEvent : ICurrencyEvent _opts = opt; _sender = sender; // generate code - _code = new(_sneakyGameStatusChars.Shuffle().Take(5).ToArray()); + _code = new kwum(_rng.Next(1_000_000, 10_000_000)).ToString(); _t = new(OnTimerTick, null, Timeout.InfiniteTimeSpan, TimeSpan.FromSeconds(2)); if (_opts.Hours > 0) @@ -88,9 +84,9 @@ public class GameStatusEvent : ICurrencyEvent if (_isPotLimited) { await msg.ModifyAsync(m => - { - m.Embed = GetEmbed(PotSize).Build(); - }); + { + m.Embed = GetEmbed(PotSize).Build(); + }); } Log.Information("Game status event awarded {Count} users {Amount} currency.{Remaining}",