Allow the same guess after 24h again with !roll

This commit is contained in:
runebaas 2018-07-22 15:02:53 +02:00
parent 83f3c61661
commit 948c48909e
No known key found for this signature in database
GPG key ID: 2677AF508D0300D6
2 changed files with 11 additions and 8 deletions

View file

@ -34,15 +34,18 @@ namespace Geekbot.net.Commands.Games
var transDict = _translation.GetDict(Context);
if (guess <= 100 && guess > 0)
{
var prevRoll = _redis.HashGet($"{Context.Guild.Id}:RollsPrevious", Context.Message.Author.Id);
if (!prevRoll.IsNullOrEmpty && prevRoll.ToString() == guess.ToString())
var prevRoll = _redis.HashGet($"{Context.Guild.Id}:RollsPrevious2", Context.Message.Author.Id).ToString()?.Split('|');
if (prevRoll?.Length == 2)
{
await ReplyAsync(string.Format(transDict["NoPrevGuess"], Context.Message.Author.Mention));
return;
if (prevRoll[0] == guess.ToString() && DateTime.Parse(prevRoll[1]) > DateTime.Now.AddDays(-1))
{
await ReplyAsync(string.Format(transDict["NoPrevGuess"], Context.Message.Author.Mention));
return;
}
}
_redis.HashSet($"{Context.Guild.Id}:RollsPrevious",
new[] {new HashEntry(Context.Message.Author.Id, guess)});
_redis.HashSet($"{Context.Guild.Id}:RollsPrevious2",
new[] {new HashEntry(Context.Message.Author.Id, $"{guess}|{DateTime.Now}")});
await ReplyAsync(string.Format(transDict["Rolled"], Context.Message.Author.Mention, number, guess));
if (guess == number)
{