Adds required admin permission for admin commands.

This commit is contained in:
benbierens 2023-11-09 10:37:57 +01:00
parent ef83441b2f
commit 1ed93bbdde
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
3 changed files with 8 additions and 7 deletions

View File

@ -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)
{ {

View File

@ -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());

View File

@ -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[]
{ {