Translate common commands and fix bug in !urban
This commit is contained in:
parent
119ce579b7
commit
14fcf74aea
11 changed files with 182 additions and 44 deletions
|
@ -8,13 +8,17 @@ namespace Geekbot.net.Commands
|
|||
{
|
||||
public class Roll : ModuleBase
|
||||
{
|
||||
private readonly IDatabase redis;
|
||||
private readonly Random rnd;
|
||||
private readonly IDatabase _redis;
|
||||
private readonly Random _rnd;
|
||||
private readonly ITranslationHandler _translation;
|
||||
private readonly IErrorHandler _errorHandler;
|
||||
|
||||
public Roll(IDatabase redis, Random RandomClient)
|
||||
public Roll(IDatabase redis, Random RandomClient, IErrorHandler errorHandler, ITranslationHandler translation)
|
||||
{
|
||||
this.redis = redis;
|
||||
rnd = RandomClient;
|
||||
_redis = redis;
|
||||
_rnd = RandomClient;
|
||||
_translation = translation;
|
||||
_errorHandler = errorHandler;
|
||||
}
|
||||
|
||||
[Command("roll", RunMode = RunMode.Async)]
|
||||
|
@ -22,21 +26,29 @@ namespace Geekbot.net.Commands
|
|||
[Summary("Guess which number the bot will roll (1-100")]
|
||||
public async Task RollCommand([Remainder] [Summary("guess")] string stuff = "noGuess")
|
||||
{
|
||||
var number = rnd.Next(1, 100);
|
||||
var guess = 1000;
|
||||
int.TryParse(stuff, out guess);
|
||||
if (guess <= 100 && guess > 0)
|
||||
try
|
||||
{
|
||||
await ReplyAsync($"{Context.Message.Author.Mention} you rolled {number}, your guess was {guess}");
|
||||
if (guess == number)
|
||||
var number = _rnd.Next(1, 100);
|
||||
var guess = 1000;
|
||||
int.TryParse(stuff, out guess);
|
||||
var transDict = _translation.GetDict(Context);
|
||||
if (guess <= 100 && guess > 0)
|
||||
{
|
||||
await ReplyAsync($"Congratulations {Context.User.Username}, your guess was correct!");
|
||||
redis.HashIncrement($"{Context.Guild.Id}:Rolls", Context.User.Id.ToString());
|
||||
await ReplyAsync(string.Format(transDict["Rolled"], Context.Message.Author.Mention, number, guess));
|
||||
if (guess == number)
|
||||
{
|
||||
await ReplyAsync(string.Format(transDict["Gratz"], Context.Message.Author));
|
||||
_redis.HashIncrement($"{Context.Guild.Id}:Rolls", Context.User.Id.ToString());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
await ReplyAsync(string.Format(transDict["RolledNoGuess"], Context.Message.Author.Mention, number));
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (Exception e)
|
||||
{
|
||||
await ReplyAsync(Context.Message.Author.Mention + ", you rolled " + number);
|
||||
_errorHandler.HandleCommandException(e, Context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue