Adds required admin permission for admin commands.
This commit is contained in:
parent
ef83441b2f
commit
1ed93bbdde
|
@ -9,13 +9,8 @@ namespace BiblioTech
|
||||||
public abstract string Name { get; }
|
public abstract string Name { get; }
|
||||||
public abstract string StartingMessage { get; }
|
public abstract string StartingMessage { get; }
|
||||||
public abstract string Description { get; }
|
public abstract string Description { get; }
|
||||||
public virtual CommandOption[] Options
|
public virtual CommandOption[] Options => Array.Empty<CommandOption>();
|
||||||
{
|
public virtual bool IsAdminCommand => false;
|
||||||
get
|
|
||||||
{
|
|
||||||
return Array.Empty<CommandOption>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task SlashCommandHandler(SocketSlashCommand command)
|
public async Task SlashCommandHandler(SocketSlashCommand command)
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,6 +30,11 @@ namespace BiblioTech
|
||||||
.WithName(c.Name)
|
.WithName(c.Name)
|
||||||
.WithDescription(c.Description);
|
.WithDescription(c.Description);
|
||||||
|
|
||||||
|
if (c.IsAdminCommand)
|
||||||
|
{
|
||||||
|
builder.WithDefaultMemberPermissions(GuildPermission.Administrator);
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var option in c.Options)
|
foreach (var option in c.Options)
|
||||||
{
|
{
|
||||||
builder.AddOption(option.Build());
|
builder.AddOption(option.Build());
|
||||||
|
|
|
@ -25,6 +25,7 @@ namespace BiblioTech.Commands
|
||||||
public override string Name => "admin";
|
public override string Name => "admin";
|
||||||
public override string StartingMessage => "...";
|
public override string StartingMessage => "...";
|
||||||
public override string Description => "Admins only.";
|
public override string Description => "Admins only.";
|
||||||
|
public override bool IsAdminCommand => true;
|
||||||
|
|
||||||
public override CommandOption[] Options => new CommandOption[]
|
public override CommandOption[] Options => new CommandOption[]
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue