Small cleanup of gamestatusevent
This commit is contained in:
parent
1c9c8af2c5
commit
58e59a208f
1 changed files with 6 additions and 10 deletions
|
@ -27,17 +27,13 @@ public class GameStatusEvent : ICurrencyEvent
|
||||||
|
|
||||||
private readonly string _code;
|
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 _stopLock = new();
|
||||||
|
|
||||||
private readonly object _potLock = new();
|
private readonly object _potLock = new();
|
||||||
private readonly IMessageSenderService _sender;
|
private readonly IMessageSenderService _sender;
|
||||||
|
|
||||||
|
private static readonly EllieRandom _rng = new EllieRandom();
|
||||||
|
|
||||||
public GameStatusEvent(
|
public GameStatusEvent(
|
||||||
DiscordSocketClient client,
|
DiscordSocketClient client,
|
||||||
ICurrencyService cs,
|
ICurrencyService cs,
|
||||||
|
@ -58,7 +54,7 @@ public class GameStatusEvent : ICurrencyEvent
|
||||||
_opts = opt;
|
_opts = opt;
|
||||||
_sender = sender;
|
_sender = sender;
|
||||||
// generate code
|
// 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));
|
_t = new(OnTimerTick, null, Timeout.InfiniteTimeSpan, TimeSpan.FromSeconds(2));
|
||||||
if (_opts.Hours > 0)
|
if (_opts.Hours > 0)
|
||||||
|
@ -88,9 +84,9 @@ public class GameStatusEvent : ICurrencyEvent
|
||||||
if (_isPotLimited)
|
if (_isPotLimited)
|
||||||
{
|
{
|
||||||
await msg.ModifyAsync(m =>
|
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}",
|
Log.Information("Game status event awarded {Count} users {Amount} currency.{Remaining}",
|
||||||
|
|
Loading…
Reference in a new issue