From 00035ac4b1e6dd35511c7da514fab9edcf871906 Mon Sep 17 00:00:00 2001 From: runebaas Date: Fri, 29 Dec 2017 01:19:20 +0100 Subject: [PATCH] Prevent people from guessing the same thing twice with !roll --- Geekbot.net/Commands/Roll.cs | 7 +++++++ Geekbot.net/Storage/Translations.json | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/Geekbot.net/Commands/Roll.cs b/Geekbot.net/Commands/Roll.cs index 1ed8408..9d7b576 100644 --- a/Geekbot.net/Commands/Roll.cs +++ b/Geekbot.net/Commands/Roll.cs @@ -34,6 +34,13 @@ namespace Geekbot.net.Commands 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()) + { + 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)); if (guess == number) { diff --git a/Geekbot.net/Storage/Translations.json b/Geekbot.net/Storage/Translations.json index 93a7421..2d3414e 100644 --- a/Geekbot.net/Storage/Translations.json +++ b/Geekbot.net/Storage/Translations.json @@ -91,6 +91,10 @@ "RolledNoGuess": { "EN": "{0}, you rolled {1}", "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" } } } \ No newline at end of file