Fixed code inconsistencies and adding support for logging to sentryio

This commit is contained in:
Runebaas 2017-10-26 00:55:04 +02:00
parent 2e083bc188
commit 9efac29956
No known key found for this signature in database
GPG key ID: 2677AF508D0300D6
18 changed files with 228 additions and 161 deletions

View file

@ -7,11 +7,13 @@ namespace Geekbot.net.Commands
{
public class Choose : ModuleBase
{
private readonly Random rnd;
private readonly Random _rnd;
private readonly IErrorHandler _errorHandler;
public Choose(Random RandomClient)
public Choose(Random RandomClient, IErrorHandler errorHandler)
{
rnd = RandomClient;
_rnd = RandomClient;
_errorHandler = errorHandler;
}
[Command("choose", RunMode = RunMode.Async)]
@ -19,9 +21,16 @@ namespace Geekbot.net.Commands
[Summary("Let the bot choose for you, seperate options with a semicolon.")]
public async Task Command([Remainder] [Summary("option1;option2")] string choices)
{
var choicesArray = choices.Split(';');
var choice = rnd.Next(choicesArray.Length);
await ReplyAsync($"I choose **{choicesArray[choice]}**");
try
{
var choicesArray = choices.Split(';');
var choice = _rnd.Next(choicesArray.Length);
await ReplyAsync($"I choose **{choicesArray[choice]}**");
}
catch (Exception e)
{
_errorHandler.HandleCommandException(e, Context);
}
}
}
}