26 lines
890 B
C#
26 lines
890 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using ChaosBot.Models;
|
|
using ChaosBot.Services;
|
|
using Discord.Commands;
|
|
using Discord.WebSocket;
|
|
|
|
namespace ChaosBot.Discord.PreConditions
|
|
{
|
|
public class CheckCommandPerm : PreconditionAttribute
|
|
{
|
|
private readonly string _defaultRole;
|
|
public CheckCommandPerm(string defaultRole) => _defaultRole = defaultRole;
|
|
|
|
public override Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
|
|
{
|
|
if (CheckPermissions.CheckPerms(context, command.Name, _defaultRole))
|
|
return Task.FromResult(PreconditionResult.FromSuccess());
|
|
|
|
return Task.FromResult(PreconditionResult.FromError("No permission has been granted to your user or your role"));
|
|
}
|
|
}
|
|
}
|