Adding Admin/User for default role
This commit is contained in:
parent
2445566308
commit
cb4cc8601f
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using ChaosBot.Models;
|
using ChaosBot.Models;
|
||||||
using ChaosBot.Repositories;
|
using ChaosBot.Repositories;
|
||||||
@ -13,6 +14,8 @@ namespace ChaosBot.Discord.PreConditions
|
|||||||
public class CheckCommandPerm : PreconditionAttribute
|
public class CheckCommandPerm : PreconditionAttribute
|
||||||
{
|
{
|
||||||
private static ILogger _logger = Program.Logger;
|
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)
|
public override Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
|
||||||
{
|
{
|
||||||
@ -65,7 +68,18 @@ namespace ChaosBot.Discord.PreConditions
|
|||||||
}
|
}
|
||||||
else
|
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
|
// Permission denied
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user