Prevent people from guessing the same thing twice with !roll

This commit is contained in:
runebaas 2017-12-29 01:19:20 +01:00
parent 08b36c1850
commit 00035ac4b1
No known key found for this signature in database
GPG key ID: 2677AF508D0300D6
2 changed files with 11 additions and 0 deletions

View file

@ -34,6 +34,13 @@ namespace Geekbot.net.Commands
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);
if (!prevRoll.IsNullOrEmpty && prevRoll.ToString() == guess.ToString())
{
await ReplyAsync(string.Format(transDict["NoPrevGuess"], Context.Message.Author.Mention));
return;
}
_redis.HashSet($"{Context.Guild.Id}:RollsPrevious", new HashEntry[]{ new HashEntry(Context.Message.Author.Id, guess), });
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)
{ {

View file

@ -91,6 +91,10 @@
"RolledNoGuess": { "RolledNoGuess": {
"EN": "{0}, you rolled {1}", "EN": "{0}, you rolled {1}",
"CHDE": "{0}, du hesch {1} grollt" "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"
} }
} }
} }