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);
|
var transDict = _translation.GetDict(Context);
|
||||||
if (guess <= 100 && guess > 0)
|
if (guess <= 100 && guess > 0)
|
||||||
{
|
{
|
||||||
var prevRoll = _redis.HashGet($"{Context.Guild.Id}:RollsPrevious", Context.Message.Author.Id);
|
var prevRoll = _redis.HashGet($"{Context.Guild.Id}:RollsPrevious2", Context.Message.Author.Id).ToString()?.Split('|');
|
||||||
if (!prevRoll.IsNullOrEmpty && prevRoll.ToString() == guess.ToString())
|
if (prevRoll?.Length == 2)
|
||||||
{
|
{
|
||||||
await ReplyAsync(string.Format(transDict["NoPrevGuess"], Context.Message.Author.Mention));
|
if (prevRoll[0] == guess.ToString() && DateTime.Parse(prevRoll[1]) > DateTime.Now.AddDays(-1))
|
||||||
return;
|
{
|
||||||
|
await ReplyAsync(string.Format(transDict["NoPrevGuess"], Context.Message.Author.Mention));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_redis.HashSet($"{Context.Guild.Id}:RollsPrevious",
|
_redis.HashSet($"{Context.Guild.Id}:RollsPrevious2",
|
||||||
new[] {new HashEntry(Context.Message.Author.Id, guess)});
|
new[] {new HashEntry(Context.Message.Author.Id, $"{guess}|{DateTime.Now}")});
|
||||||
await ReplyAsync(string.Format(transDict["Rolled"], Context.Message.Author.Mention, number, guess));
|
await ReplyAsync(string.Format(transDict["Rolled"], Context.Message.Author.Mention, number, guess));
|
||||||
if (guess == number)
|
if (guess == number)
|
||||||
{
|
{
|
||||||
|
|
|
@ -93,8 +93,8 @@
|
||||||
"CHDE": "{0}, du hesch {1} grollt"
|
"CHDE": "{0}, du hesch {1} grollt"
|
||||||
},
|
},
|
||||||
"NoPrevGuess": {
|
"NoPrevGuess": {
|
||||||
"EN": ":red_circle: {0}, you can't guess the same number again",
|
"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"
|
"CHDE": ":red_circle: {0}, du chasch nid nomol es gliche rate innerhalb vo 24 stund"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue