setting up subcommands.
This commit is contained in:
parent
dfe477d192
commit
5aff8c6f6d
@ -62,5 +62,14 @@ namespace BiblioTech
|
|||||||
public string Description { get; }
|
public string Description { get; }
|
||||||
public ApplicationCommandOptionType Type { get; }
|
public ApplicationCommandOptionType Type { get; }
|
||||||
public bool IsRequired { get; }
|
public bool IsRequired { get; }
|
||||||
|
|
||||||
|
public virtual SlashCommandOptionBuilder Build()
|
||||||
|
{
|
||||||
|
return new SlashCommandOptionBuilder()
|
||||||
|
.WithName(Name)
|
||||||
|
.WithDescription(Description)
|
||||||
|
.WithType(Type)
|
||||||
|
.WithRequired(IsRequired);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ namespace BiblioTech
|
|||||||
|
|
||||||
foreach (var option in c.Options)
|
foreach (var option in c.Options)
|
||||||
{
|
{
|
||||||
builder.AddOption(option.Name, option.Type, option.Description, isRequired: option.IsRequired);
|
builder.AddOption(option.Build());
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder;
|
return builder;
|
||||||
|
46
Tools/BiblioTech/Commands/AdminCommand.cs
Normal file
46
Tools/BiblioTech/Commands/AdminCommand.cs
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
using Discord;
|
||||||
|
using Discord.WebSocket;
|
||||||
|
|
||||||
|
namespace BiblioTech.Commands
|
||||||
|
{
|
||||||
|
public class SubCommandOption : CommandOption
|
||||||
|
{
|
||||||
|
private readonly CommandOption[] options;
|
||||||
|
|
||||||
|
public SubCommandOption(string name, string description, params CommandOption[] options)
|
||||||
|
: base(name, description, type: ApplicationCommandOptionType.SubCommand, isRequired: false)
|
||||||
|
{
|
||||||
|
this.options = options;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override SlashCommandOptionBuilder Build()
|
||||||
|
{
|
||||||
|
var builder = base.Build();
|
||||||
|
foreach (var option in options)
|
||||||
|
{
|
||||||
|
builder.AddOption(option.Build());
|
||||||
|
}
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AdminCommand : BaseCommand
|
||||||
|
{
|
||||||
|
public override string Name => "admin";
|
||||||
|
public override string StartingMessage => "...";
|
||||||
|
public override string Description => "Admins only.";
|
||||||
|
|
||||||
|
private readonly SubCommandOption aaa = new SubCommandOption("aaa", "does AAA", new EthAddressOption());
|
||||||
|
private readonly SubCommandOption bbb = new SubCommandOption("bbb", "does BBB", new UserOption("a user", true));
|
||||||
|
|
||||||
|
public override CommandOption[] Options => new CommandOption[]
|
||||||
|
{
|
||||||
|
aaa, bbb
|
||||||
|
};
|
||||||
|
|
||||||
|
protected override Task Invoke(SocketSlashCommand command)
|
||||||
|
{
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -51,12 +51,13 @@ namespace BiblioTech
|
|||||||
|
|
||||||
var associateCommand = new UserAssociateCommand();
|
var associateCommand = new UserAssociateCommand();
|
||||||
var handler = new CommandHandler(client,
|
var handler = new CommandHandler(client,
|
||||||
new ClearUserAssociationCommand(),
|
//new ClearUserAssociationCommand(),
|
||||||
new GetBalanceCommand(monitor, ci, associateCommand),
|
new GetBalanceCommand(monitor, ci, associateCommand),
|
||||||
new MintCommand(monitor, ci, associateCommand),
|
new MintCommand(monitor, ci, associateCommand),
|
||||||
new ReportHistoryCommand(),
|
//new ReportHistoryCommand(),
|
||||||
associateCommand,
|
associateCommand,
|
||||||
new DeploymentsCommand(monitor)
|
//new DeploymentsCommand(monitor),
|
||||||
|
new AdminCommand()
|
||||||
);
|
);
|
||||||
|
|
||||||
await client.LoginAsync(TokenType.Bot, Config.ApplicationToken);
|
await client.LoginAsync(TokenType.Bot, Config.ApplicationToken);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user