using System; using System.Threading.Tasks; using Discord.Commands; using Geekbot.net.Lib; using Geekbot.net.Lib.ErrorHandling; using Geekbot.net.Lib.Localization; namespace Geekbot.net.Commands.Utils { public class Choose : GeekbotBase { private readonly IErrorHandler _errorHandler; public Choose(IErrorHandler errorHandler) { _errorHandler = errorHandler; } [Command("choose", RunMode = RunMode.Async)] [Summary("Let the bot choose for you, seperate options with a semicolon.")] public async Task Command([Remainder] [Summary("option1;option2")] string choices) { try { var choicesArray = choices.Split(';'); var choice = new Random().Next(choicesArray.Length); await ReplyAsync(Context.Translations.GetString("Choice", choicesArray[choice].Trim())); } catch (Exception e) { await _errorHandler.HandleCommandException(e, Context); } } } }