Allow the same guess after 24h again with !roll
This commit is contained in:
parent
83f3c61661
commit
948c48909e
2 changed files with 11 additions and 8 deletions
|
@ -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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -93,8 +93,8 @@
|
|||
"CHDE": "{0}, du hesch {1} grollt"
|
||||
},
|
||||
"NoPrevGuess": {
|
||||
"EN": ":red_circle: {0}, you can't guess the same number again",
|
||||
"CHDE": ":red_circle: {0}, du chasch nid nomol es gliche rate"
|
||||
"EN": ":red_circle: {0}, you can't guess the same number again within 24 hours",
|
||||
"CHDE": ":red_circle: {0}, du chasch nid nomol es gliche rate innerhalb vo 24 stund"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue