Abstracted out command arguments a bit
This commit is contained in:
@ -12,6 +12,7 @@ using NadekoBot.Modules.Gambling.Common.AnimalRacing;
|
||||
using NadekoBot.Modules.Gambling.Services;
|
||||
using NadekoBot.Core.Modules.Gambling.Common.AnimalRacing;
|
||||
using CommandLine;
|
||||
using NadekoBot.Core.Common;
|
||||
|
||||
namespace NadekoBot.Modules.Gambling
|
||||
{
|
||||
@ -38,10 +39,8 @@ namespace NadekoBot.Modules.Gambling
|
||||
[NadekoOptions(typeof(RaceOptions))]
|
||||
public Task Race(params string[] args)
|
||||
{
|
||||
var options = new RaceOptions();
|
||||
var res = Parser.Default.ParseArguments<RaceOptions>(args);
|
||||
options = res.MapResult(x => x, x => options);
|
||||
options.NormalizeOptions();
|
||||
var options = OptionsParser.Default.ParseFrom(new RaceOptions(), args);
|
||||
|
||||
var ar = new AnimalRace(options, _cs, _bc.BotConfig.RaceAnimals.Shuffle().ToArray());
|
||||
if (!_service.AnimalRaces.TryAdd(Context.Guild.Id, ar))
|
||||
return Context.Channel.SendErrorAsync(GetText("animal_race"), GetText("animal_race_already_started"));
|
||||
|
@ -1,8 +1,9 @@
|
||||
using CommandLine;
|
||||
using NadekoBot.Core.Common;
|
||||
|
||||
namespace NadekoBot.Core.Modules.Gambling.Common.AnimalRacing
|
||||
{
|
||||
public class RaceOptions
|
||||
public class RaceOptions : INadekoCommandOptions
|
||||
{
|
||||
[Option('s', "start-time", Default = 20, Required = false)]
|
||||
public int StartTime { get; set; } = 20;
|
||||
|
Reference in New Issue
Block a user