Add the timeout in !roll back
This commit is contained in:
parent
8018d5e750
commit
0898e9b6bd
3 changed files with 22 additions and 11 deletions
|
@ -10,7 +10,7 @@ using Geekbot.net.Lib.KvInMemoryStore;
|
||||||
using Geekbot.net.Lib.Localization;
|
using Geekbot.net.Lib.Localization;
|
||||||
using Geekbot.net.Lib.RandomNumberGenerator;
|
using Geekbot.net.Lib.RandomNumberGenerator;
|
||||||
|
|
||||||
namespace Geekbot.net.Commands.Games
|
namespace Geekbot.net.Commands.Games.Roll
|
||||||
{
|
{
|
||||||
public class Roll : ModuleBase
|
public class Roll : ModuleBase
|
||||||
{
|
{
|
||||||
|
@ -42,17 +42,18 @@ namespace Geekbot.net.Commands.Games
|
||||||
{
|
{
|
||||||
var kvKey = $"{Context.Guild.Id}:{Context.User.Id}:RollsPrevious";
|
var kvKey = $"{Context.Guild.Id}:{Context.User.Id}:RollsPrevious";
|
||||||
|
|
||||||
var prevRoll = _kvInMemoryStore.Get<int>(kvKey);
|
var prevRoll = _kvInMemoryStore.Get<RollTimeout>(kvKey);
|
||||||
if (prevRoll > 0)
|
|
||||||
|
if (prevRoll?.LastGuess == guess && prevRoll?.GuessedOn.AddDays(1) > DateTime.Now)
|
||||||
{
|
{
|
||||||
if (prevRoll == guess)
|
await ReplyAsync(transContext.GetString(
|
||||||
{
|
"NoPrevGuess",
|
||||||
await ReplyAsync(transContext.GetString("NoPrevGuess", Context.Message.Author.Mention));
|
Context.Message.Author.Mention,
|
||||||
return;
|
transContext.FormatDateTimeAsRemaining(prevRoll.GuessedOn.AddDays(1))));
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_kvInMemoryStore.Set(kvKey, guess);
|
_kvInMemoryStore.Set(kvKey, new RollTimeout { LastGuess = guess, GuessedOn = DateTime.Now });
|
||||||
|
|
||||||
await ReplyAsync(transContext.GetString("Rolled", Context.Message.Author.Mention, number, guess));
|
await ReplyAsync(transContext.GetString("Rolled", Context.Message.Author.Mention, number, guess));
|
||||||
if (guess == number)
|
if (guess == number)
|
10
Geekbot.net/Commands/Games/Roll/RollTimeout.cs
Normal file
10
Geekbot.net/Commands/Games/Roll/RollTimeout.cs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Geekbot.net.Commands.Games.Roll
|
||||||
|
{
|
||||||
|
public class RollTimeout
|
||||||
|
{
|
||||||
|
public int LastGuess { get; set; }
|
||||||
|
public DateTime GuessedOn { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -83,8 +83,8 @@ roll:
|
||||||
EN: "{0}, you rolled {1}"
|
EN: "{0}, you rolled {1}"
|
||||||
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, guess another number or wait {1}"
|
||||||
CHDE: ":red_circle: {0}, du chasch nid nomol es gliche rate"
|
CHDE: ":red_circle: {0}, du chasch nid nomol es gliche rate, rate öppis anders oder warte {1}"
|
||||||
cookies: &cookiesAlias
|
cookies: &cookiesAlias
|
||||||
GetCookies:
|
GetCookies:
|
||||||
EN: "You got {0} cookies, there are now {1} cookies in you cookie jar"
|
EN: "You got {0} cookies, there are now {1} cookies in you cookie jar"
|
||||||
|
|
Loading…
Reference in a new issue