Adding Admin/User for default role

This commit is contained in:
Sean "Solao Bajiuik" Stoves 2020-08-05 17:58:57 -04:00
parent 2445566308
commit cb4cc8601f

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using ChaosBot.Models;
using ChaosBot.Repositories;
@ -13,6 +14,8 @@ namespace ChaosBot.Discord.PreConditions
public class CheckCommandPerm : PreconditionAttribute
{
private static ILogger _logger = Program.Logger;
private readonly string _defaultRole;
public CheckCommandPerm(string defaultRole) => _defaultRole = defaultRole;
public override Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
{
@ -65,7 +68,18 @@ namespace ChaosBot.Discord.PreConditions
}
else
{
_logger.Info("CheckCommandperm.CheckPermissionsAsync|commandPermissions: Null Value");
if (_defaultRole == "Admin")
{
if(gUser.GuildPermissions.Administrator)
return Task.FromResult(PreconditionResult.FromSuccess());
}
else if ( _defaultRole == "User")
{
if(gUser.GuildPermissions.SendMessages)
return Task.FromResult(PreconditionResult.FromSuccess());
}
else
_logger.Info($"CheckCommandperm.CheckPermissionsAsync|commandPermissions: No Default");
}
// Permission denied