Use structs instead of enums for interaction option names
This commit is contained in:
parent
913ea23732
commit
616ac5e430
2 changed files with 14 additions and 14 deletions
|
@ -25,11 +25,11 @@ namespace Geekbot.Web.Commands
|
||||||
_highscoreManager = highscoreManager;
|
_highscoreManager = highscoreManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum Options
|
private struct Options
|
||||||
{
|
{
|
||||||
Counter,
|
internal const string Counter = "counter";
|
||||||
Amount,
|
internal const string Amount = "amount";
|
||||||
Season
|
internal const string Season = "season";
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Command GetCommandInfo()
|
public override Command GetCommandInfo()
|
||||||
|
@ -43,7 +43,7 @@ namespace Geekbot.Web.Commands
|
||||||
{
|
{
|
||||||
new ()
|
new ()
|
||||||
{
|
{
|
||||||
Name = Options.Counter.ToString().ToLower(),
|
Name = Options.Counter,
|
||||||
Description = "The counter to show",
|
Description = "The counter to show",
|
||||||
Required = true,
|
Required = true,
|
||||||
Type = OptionType.String,
|
Type = OptionType.String,
|
||||||
|
@ -57,14 +57,14 @@ namespace Geekbot.Web.Commands
|
||||||
},
|
},
|
||||||
new ()
|
new ()
|
||||||
{
|
{
|
||||||
Name = Options.Amount.ToString().ToLower(),
|
Name = Options.Amount,
|
||||||
Description = "Amount of positions to show in the list",
|
Description = "Amount of positions to show in the list",
|
||||||
Required = false,
|
Required = false,
|
||||||
Type = OptionType.Integer
|
Type = OptionType.Integer
|
||||||
},
|
},
|
||||||
new ()
|
new ()
|
||||||
{
|
{
|
||||||
Name = Options.Season.ToString().ToLower(),
|
Name = Options.Season,
|
||||||
Description = "Select the season, only applies for the seasons counter",
|
Description = "Select the season, only applies for the seasons counter",
|
||||||
Required = false,
|
Required = false,
|
||||||
Type = OptionType.String
|
Type = OptionType.String
|
||||||
|
@ -75,9 +75,9 @@ namespace Geekbot.Web.Commands
|
||||||
|
|
||||||
public override Task<InteractionResponse> Exec(Interaction interaction)
|
public override Task<InteractionResponse> Exec(Interaction interaction)
|
||||||
{
|
{
|
||||||
var counterTypeOption = interaction.Data.Options.Find(o => o.Name == Options.Counter.ToString().ToLower());
|
var counterTypeOption = interaction.Data.Options.Find(o => o.Name == Options.Counter);
|
||||||
var amountOption = interaction.Data.Options.Find(o => o.Name == Options.Amount.ToString().ToLower());
|
var amountOption = interaction.Data.Options.Find(o => o.Name == Options.Amount);
|
||||||
var seasonOption = interaction.Data.Options.Find(o => o.Name == Options.Season.ToString().ToLower());
|
var seasonOption = interaction.Data.Options.Find(o => o.Name == Options.Season);
|
||||||
|
|
||||||
var res = new Geekbot.Commands.Rank(_database, _emojiConverter, _highscoreManager)
|
var res = new Geekbot.Commands.Rank(_database, _emojiConverter, _highscoreManager)
|
||||||
.Run(
|
.Run(
|
||||||
|
|
|
@ -22,9 +22,9 @@ namespace Geekbot.Web.Commands
|
||||||
_randomNumberGenerator = randomNumberGenerator;
|
_randomNumberGenerator = randomNumberGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum Options
|
private struct Options
|
||||||
{
|
{
|
||||||
Guess
|
internal const string Guess = "guess";
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Command GetCommandInfo()
|
public override Command GetCommandInfo()
|
||||||
|
@ -38,7 +38,7 @@ namespace Geekbot.Web.Commands
|
||||||
{
|
{
|
||||||
new Option()
|
new Option()
|
||||||
{
|
{
|
||||||
Name = Options.Guess.ToString().ToLower(),
|
Name = Options.Guess,
|
||||||
Description = "A number between 1 and 100 (inclusive)",
|
Description = "A number between 1 and 100 (inclusive)",
|
||||||
Required = true,
|
Required = true,
|
||||||
Type = OptionType.Integer
|
Type = OptionType.Integer
|
||||||
|
@ -49,7 +49,7 @@ namespace Geekbot.Web.Commands
|
||||||
|
|
||||||
public override async Task<InteractionResponse> Exec(Interaction interaction)
|
public override async Task<InteractionResponse> Exec(Interaction interaction)
|
||||||
{
|
{
|
||||||
var guessOption = interaction.Data.Options.Find(o => o.Name == Options.Guess.ToString().ToLower());
|
var guessOption = interaction.Data.Options.Find(o => o.Name == Options.Guess);
|
||||||
var guess = guessOption.Value.GetInt32();
|
var guess = guessOption.Value.GetInt32();
|
||||||
|
|
||||||
var res = await new Geekbot.Commands.Roll.Roll(_kvInMemoryStore, _database, _randomNumberGenerator)
|
var res = await new Geekbot.Commands.Roll.Roll(_kvInMemoryStore, _database, _randomNumberGenerator)
|
||||||
|
|
Loading…
Reference in a new issue