Beispiel #1
0
        public override Task <bool> ExecuteCheckAsync(CommandContext context, bool help)
        {
            GuildSettingsContext settingsContext = (GuildSettingsContext)context.Services.GetService(typeof(GuildSettingsContext));

            if (settingsContext == null)
            {
                return(Task.FromResult(true));
            }
            bool  result  = true;
            var   command = context.Command;
            ulong guildId = context.GetGuild().Id;

            while (command != null)
            {
                result  = !settingsContext.IsCommandDisabled(guildId, command.QualifiedName);
                command = result ? command.Parent : null;
            }

            if (result)
            {
                var userRestrictions = settingsContext.GetUserRestriction(guildId, context.User.Id);
                if (userRestrictions?.RestrictedCommands != null)
                {
                    result = userRestrictions.FindCommandRestriction(context.Command.QualifiedName) == null;
                }
            }
            return(Task.FromResult(result || help));
        }
Beispiel #2
0
        public override Task <bool> ExecuteCheckAsync(CommandContext context, bool help)
        {
            if (help)
            {
                return(Task.FromResult(true));
            }

            var guild      = context.GetGuild();
            var member     = guild.Members[context.User.Id];
            var isBotOwner = context.Client.CurrentApplication.Owners.Contains(context.User);

            if ((member != null && member.IsOwner) || isBotOwner)
            {
                return(Task.FromResult(true));
            }

            if (_context == null)
            {
                _context = (GuildSettingsContext)context.Services.GetService(typeof(GuildSettingsContext));
            }
            return(Task.FromResult(
                       _context.IsAdminRole(guild.Id, member?.Roles)
                       ));
        }
Beispiel #3
0
 public AdminCommands(GuildSettingsContext dbContext, GaussConfig config)
 {
     this._context = dbContext;
     this._config  = config;
 }
Beispiel #4
0
 public CommandAdminCommands(GuildSettingsContext dbContext)
 {
     this._context = dbContext;
 }