Ejemplo n.º 1
0
        public async Task GetPendingForGuild()
        {
            var query = VerificationFormDataHandler.GetPendingVerificationFormsByGuild(Context.Guild.Id);

            var embed = new EmbedBuilder
            {
                Author = new EmbedAuthorBuilder
                {
                    Name    = "Pending Verifications",
                    IconUrl = Context.Client.CurrentUser.GetAvatarUrl()
                },
                Color     = Color.Blue,
                Timestamp = DateTime.UtcNow
            };



            foreach (var form in query)
            {
                var field = new EmbedFieldBuilder
                {
                    Name  = Context.Guild.GetUser(form.Verified).Username,
                    Value = $"Verifier: { Context.Guild.GetUser(form.Verifier).Username } \n Issued: { form.IssuedUtc.ToString(format: "dd/MM/yyyy HH:mm") }"
                };

                embed.AddField(field);
            }

            await _replyservice.ReplyEmbedAsync(context : Context, embed : embed);
        }
Ejemplo n.º 2
0
        public async Task DenyUser(IGuildUser user)
        {
            var invokingUser = DiscordUserDataHandler.GetGuildUserById(Context.User.Id, Context.Guild.Id);

            if (invokingUser == null || invokingUser.PermissionLevel != DiscordGuildUser.PermissionLevels.Approve)
            {
                await _replyservice.ReplyEmbedAsync(context : Context,
                                                    message : "You do not have permissions to invoke this command.");

                return;
            }

            var query = VerificationFormDataHandler.GetPendingVerificationFormsByGuild(Context.Guild.Id).Where(x => x.Verified == user.Id);

            if (query.Count() < 1)
            {
                await _replyservice.ReplyEmbedAsync(context : Context,
                                                    message : $"No pending verification for user { user.Username }");

                return;
            }

            var form = query.FirstOrDefault();

            form.Approver   = Context.User.Id;
            form.IsApproved = false;
            await VerificationFormDataHandler.AddFullVerificationForm(form);

            Log.Information(
                "User {ExecutingUserID} denied by {UserID} in guild {GuildID}",
                user.Id, Context.User.Id, Context.Guild.Id
                );

            await _replyservice.ReplyEmbedAsync(context : Context,
                                                message : $"User {user.Username} has been denied verification.");
        }
Ejemplo n.º 3
0
        public async Task ApproveAll()
        {
            var invokingUser = DiscordUserDataHandler.GetGuildUserById(Context.User.Id, Context.Guild.Id);

            if (invokingUser == null || invokingUser.PermissionLevel != DiscordGuildUser.PermissionLevels.Approve)
            {
                await _replyservice.ReplyEmbedAsync(context : Context,
                                                    message : "You do not have permissions to invoke this command.");

                return;
            }

            var query = VerificationFormDataHandler.GetPendingVerificationFormsByGuild(Context.Guild.Id);

            if (query.Count() < 1)
            {
                await _replyservice.ReplyEmbedAsync(context : Context,
                                                    message : $"No pending verifications");

                return;
            }

            var roleQuery = DiscordRoleDataHandler.GetGuildRoles(Context.Guild.Id);

            var toBeAddedQuery   = roleQuery.Where(x => x.Action == DiscordRole.ActionType.Add);
            var toBeRemovedQuery = roleQuery.Where(x => x.Action == DiscordRole.ActionType.Remove);

            List <IRole> toBeAdded   = new List <IRole>();
            List <IRole> toBeRemoved = new List <IRole>();

            foreach (var role in toBeAddedQuery)
            {
                var socketRole = Context.Guild.GetRole(role.RoleId);

                toBeAdded.Add(socketRole);
            }

            foreach (var role in toBeRemovedQuery)
            {
                var socketRole = Context.Guild.GetRole(role.RoleId);

                toBeRemoved.Add(socketRole);
            }

            foreach (var form in query)
            {
                var user = Context.Guild.GetUser(form.Verified);

                await user.AddRolesAsync(toBeAdded);

                await user.RemoveRolesAsync(toBeRemoved);

                form.Approver   = Context.User.Id;
                form.IsApproved = true;
                await VerificationFormDataHandler.AddFullVerificationForm(form);
            }

            Log.Information(
                "Bulk approval ({FormCount} forms) by {UserID} in guild {GuildID}",
                query.Count(), Context.User.Id, Context.Guild.Id
                );

            await _replyservice.ReplyEmbedAsync(context : Context,
                                                message : $"The pending forms ({ query.Count() }) have been bulk approved by { Context.User.Username }");
        }