forked from EllieBotDevs/elliebot
fixed hangman not working sometimes
This commit is contained in:
parent
62a01d3d06
commit
6d08ddee7d
2 changed files with 4 additions and 5 deletions
src/EllieBot/Modules
|
@ -35,7 +35,6 @@ public sealed class HangmanService : IHangmanService, IExecNoCommand
|
|||
if (!_source.GetTerm(category, out var term))
|
||||
return false;
|
||||
|
||||
|
||||
var game = new HangmanGame(term);
|
||||
lock (_locker)
|
||||
{
|
||||
|
@ -71,7 +70,7 @@ public sealed class HangmanService : IHangmanService, IExecNoCommand
|
|||
if (string.IsNullOrWhiteSpace(msg.Content))
|
||||
return;
|
||||
|
||||
if (_cdCache.TryGetValue(msg.Author.Id, out _))
|
||||
if (_cdCache.TryGetValue("hangman:" + msg.Author.Id, out _))
|
||||
return;
|
||||
|
||||
HangmanGame.State state;
|
||||
|
@ -88,7 +87,7 @@ public sealed class HangmanService : IHangmanService, IExecNoCommand
|
|||
|
||||
if (state.GuessResult is HangmanGame.GuessResult.Incorrect or HangmanGame.GuessResult.AlreadyTried)
|
||||
{
|
||||
_cdCache.Set(msg.Author.Id,
|
||||
_cdCache.Set("hangman:" + msg.Author.Id,
|
||||
string.Empty,
|
||||
new MemoryCacheEntryOptions
|
||||
{
|
||||
|
|
|
@ -570,10 +570,10 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
|
|||
if (cdInMinutes <= float.Epsilon)
|
||||
return Task.FromResult(true);
|
||||
|
||||
if (_memCache.TryGetValue(userId, out _))
|
||||
if (_memCache.TryGetValue("xp_gain:" + userId, out _))
|
||||
return Task.FromResult(false);
|
||||
|
||||
using var entry = _memCache.CreateEntry(userId);
|
||||
using var entry = _memCache.CreateEntry("xp_gain:" + userId);
|
||||
entry.Value = true;
|
||||
|
||||
entry.AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(cdInMinutes);
|
||||
|
|
Loading…
Add table
Reference in a new issue