Exemplo n.º 1
0
        private async Task ConfirmAndReplyWithCountsAsync(ulong userId)
        {
            await Context.AddConfirmation();

            // If the channel is public, do not list the infraction embed that occurs after a user has reached 3 infractions
            if ((Context.Channel as IGuildChannel)?.IsPublic() is true)
            {
                return;
            }

            var counts = await ModerationService.GetInfractionCountsForUserAsync(userId);

            //TODO: Make this configurable
            if (counts.Values.Any(count => count >= 3))
            {
                // https://modix.gg/infractions?subject=12345
                var url = new UriBuilder(Config.WebsiteBaseUrl)
                {
                    Path  = "/infractions",
                    Query = $"subject={userId}"
                }.RemoveDefaultPort().ToString();

                await ReplyAsync(embed : new EmbedBuilder()
                                 .WithTitle("Infraction Count Notice")
                                 .WithColor(Color.Orange)
                                 .WithDescription(FormatUtilities.FormatInfractionCounts(counts))
                                 .WithUrl(url)
                                 .Build());
            }
        }
Exemplo n.º 2
0
        private async Task AddInfractionsToEmbed(ulong userId, StringBuilder builder)
        {
            builder.AppendLine();
            builder.AppendLine($"**\u276F Infractions [See here](https://mod.gg/infractions?subject={userId})**");

            var counts = await ModerationService.GetInfractionCountsForUserAsync(userId);

            builder.AppendLine(FormatUtilities.FormatInfractionCounts(counts));
        }
Exemplo n.º 3
0
        private async Task ConfirmAndReplyWithCountsAsync(ulong userId)
        {
            await Context.AddConfirmation();

            var counts = await ModerationService.GetInfractionCountsForUserAsync(userId);

            //TODO: Make this configurable
            if (counts.Values.Any(count => count >= 3))
            {
                await ReplyAsync(embed : new EmbedBuilder()
                                 .WithTitle("Infraction Count Notice")
                                 .WithColor(Color.Orange)
                                 .WithDescription(FormatUtilities.FormatInfractionCounts(counts))
                                 .Build());
            }
        }
Exemplo n.º 4
0
        private async Task AddInfractionsToEmbedAsync(ulong userId, StringBuilder builder)
        {
            builder.AppendLine();
            builder.AppendLine($"**\u276F Infractions [See here](https://mod.gg/infractions?subject={userId})**");

            if (!(Context.Channel as IGuildChannel).IsPublic())
            {
                var counts = await ModerationService.GetInfractionCountsForUserAsync(userId);

                builder.AppendLine(FormatUtilities.FormatInfractionCounts(counts));
            }
            else
            {
                builder.AppendLine("Infractions cannot be listed in public channels.");
            }
        }
Exemplo n.º 5
0
        public async Task SearchAsync(
            [Summary("The user whose infractions are to be displayed.")]
            DiscordUserEntity subjectEntity)
        {
            var requestor = Context.User.Mention;
            var subject   = await UserService.GetGuildUserSummaryAsync(Context.Guild.Id, subjectEntity.Id);

            var infractions = await ModerationService.SearchInfractionsAsync(
                new InfractionSearchCriteria
            {
                GuildId   = Context.Guild.Id,
                SubjectId = subjectEntity.Id,
                IsDeleted = false
            },
                new[]
            {
                new SortingCriteria()
                {
                    PropertyName = nameof(InfractionSummary.CreateAction.Created),
                    Direction    = SortDirection.Descending,
                },
            });

            if (infractions.Count == 0)
            {
                await ReplyAsync(Format.Code("No infractions"));

                return;
            }

            var infractionQuery = infractions.Select(infraction => new
            {
                Id        = infraction.Id,
                Created   = infraction.CreateAction.Created.ToUniversalTime().ToString("yyyy MMM dd"),
                Type      = infraction.Type.ToString(),
                Subject   = infraction.Subject.Username,
                Creator   = infraction.CreateAction.CreatedBy.GetFullUsername(),
                Reason    = infraction.Reason,
                Rescinded = infraction.RescindAction != null
            }).OrderBy(s => s.Type);

            var counts = await ModerationService.GetInfractionCountsForUserAsync(subjectEntity.Id);

            var builder = new EmbedBuilder()
                          .WithTitle($"Infractions for user: {subject.GetFullUsername()}")
                          .WithDescription(FormatUtilities.FormatInfractionCounts(counts))
                          .WithUrl($"https://mod.gg/infractions/?subject={subject.UserId}")
                          .WithColor(new Color(0xA3BF0B))
                          .WithTimestamp(DateTimeOffset.UtcNow);

            foreach (var infraction in infractionQuery)
            {
                builder.AddField(
                    $"#{infraction.Id} - {infraction.Type} - Created: {infraction.Created}{(infraction.Rescinded ? " - [RESCINDED]" : "")}",
                    Format.Url($"Reason: {infraction.Reason}", $"https://mod.gg/infractions/?id={infraction.Id}")
                    );
            }

            var embed = builder.Build();

            await Context.Channel.SendMessageAsync(
                $"Requested by {requestor}",
                embed : embed)
            .ConfigureAwait(false);
        }
Exemplo n.º 6
0
        public async Task SearchAsync(
            [Summary("The user whose infractions are to be displayed.")]
            DiscordUserOrMessageAuthorEntity subjectEntity)
        {
            var requestor = Context.User.Mention;
            var subject   = await UserService.GetGuildUserSummaryAsync(Context.Guild.Id, subjectEntity.UserId);

            var infractions = await ModerationService.SearchInfractionsAsync(
                new InfractionSearchCriteria
            {
                GuildId   = Context.Guild.Id,
                SubjectId = subjectEntity.UserId,
                IsDeleted = false
            },
                new[]
            {
                new SortingCriteria()
                {
                    PropertyName = nameof(InfractionSummary.CreateAction.Created),
                    Direction    = SortDirection.Descending,
                },
            });

            if (infractions.Count == 0)
            {
                await ReplyAsync(Format.Code("No infractions"));

                return;
            }

            var infractionQuery = infractions.Select(infraction => new
            {
                Id        = infraction.Id,
                Created   = infraction.CreateAction.Created.ToUniversalTime().ToString("yyyy MMM dd"),
                Type      = infraction.Type,
                Reason    = infraction.Reason,
                Rescinded = infraction.RescindAction != null
            });

            var counts = await ModerationService.GetInfractionCountsForUserAsync(subjectEntity.UserId);

            // https://modix.gg/infractions?subject=12345
            var url = new UriBuilder(Config.WebsiteBaseUrl)
            {
                Path  = "/infractions",
                Query = $"subject={subject.UserId}"
            }.RemoveDefaultPort().ToString();

            var builder = new EmbedBuilder()
                          .WithTitle($"Infractions for user: {subject.GetFullUsername()}")
                          .WithDescription(FormatUtilities.FormatInfractionCounts(counts))
                          .WithUrl(url)
                          .WithColor(new Color(0xA3BF0B));

            foreach (var infraction in infractionQuery)
            {
                // https://modix.gg/infractions?id=123
                var infractionUrl = new UriBuilder(Config.WebsiteBaseUrl)
                {
                    Path  = "/infractions",
                    Query = $"id={infraction.Id}"
                }.ToString();

                var emoji = GetEmojiForInfractionType(infraction.Type);

                builder.AddField(
                    $"#{infraction.Id} - \\{emoji} {infraction.Type} - Created: {infraction.Created}{(infraction.Rescinded ? " - [RESCINDED]" : "")}",
                    Format.Url($"Reason: {infraction.Reason}", infractionUrl)
                    );
            }

            var embed = builder.Build();

            await Context.Channel.SendMessageAsync(
                $"Requested by {requestor}",
                embed : embed)
            .ConfigureAwait(false);
        }