Fixed code inconsistencies and adding support for logging to sentryio
This commit is contained in:
parent
2e083bc188
commit
9efac29956
18 changed files with 228 additions and 161 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue