Пример #1
0
        public async override Task <bool> CheckPermissionsAsync(CommandRequirements required)
        {
            var perms = required.Discord;

            if (perms.User != Permissions.None)
            {
                var member = (DiscordMember)User;
                if (!member.Permissions.HasPermission(perms.User))
                {
                    await ReplyAsync("You do not have permission to execute that command!", ReplyOption.InPrivate);

                    return(false);
                }
            }

            if (perms.Bot != Permissions.None)
            {
                if (Guild is null)
                {
                    await ReplyAsync("Command needs to be run in a channel!", ReplyOption.InPrivate);

                    return(false);
                }

                var selfMember = await Guild.GetMemberAsync(Client.CurrentUser.Id);

                if (!Channel.PermissionsFor(selfMember).HasPermission(perms.Bot))
                {
                    await ReplyAsync("Bot do not have permission to execute that command!", ReplyOption.InPrivate);

                    return(false);
                }
            }

            if (perms.FafStaff)
            {
                var             config   = Services.GetService <IConfiguration>();
                HashSet <ulong> fafStaff = new(from child in config?.GetSection("Roles:FafStaff").GetChildren()
                                               where ulong.TryParse(child.Value, out _)
                                               select ulong.Parse(child.Value));

                if (!fafStaff.Contains(User.Id))
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #2
0
 public abstract Task <bool> CheckPermissionsAsync(CommandRequirements required);