<commit_before>﻿using System;
using System.Linq;
using System.Threading.Tasks;
using CompatBot.Commands.Attributes;
using CompatBot.EventHandlers;
using CompatBot.Utils;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;

namespace CompatBot.Commands
{
    internal sealed partial class Moderation: BaseCommandModuleCustom
    {
        [Command("report"), RequiresWhitelistedRole]
        [Description("Adds specified message to the moderation queue")]
        public async Task Report(CommandContext ctx, [Description("Message ID from current channel to report")] ulong messageId, [RemainingText, Description("Optional report comment")] string? comment = null)
        {
            try
            {
                var msg = await ctx.Channel.GetMessageAsync(messageId).ConfigureAwait(false);
                await ReportMessage(ctx, comment, msg);
            }
            catch (Exception)
            {
                await ctx.ReactWithAsync(Config.Reactions.Failure, "Failed to report the message").ConfigureAwait(false);
            }
        }

        [Command("report"), RequiresWhitelistedRole]
        [Description("Adds specified message to the moderation queue")]
        public async Task Report(CommandContext ctx, [Description("Message link to report")] string messageLink, [RemainingText, Description("Optional report comment")] string? comment = null)
        {
            try
            {
                var msg = await ctx.GetMessageAsync(messageLink).ConfigureAwait(false);
                if (msg is null)
                {
                    await ctx.ReactWithAsync(Config.Reactions.Failure, "Can't find linked message").ConfigureAwait(false);
                    return;
                }
                
                await ReportMessage(ctx, comment, msg);
            }
            catch (Exception)
            {
                await ctx.ReactWithAsync(Config.Reactions.Failure, "Failed to report the message").ConfigureAwait(false);
            }
        }

        [Command("analyze"), Aliases("reanalyze", "parse", "a")]
        [Description("Make bot to look at the attached log again")]
        public async Task Reanalyze(CommandContext ctx, [Description("Message ID from the same channel")]ulong messageId)
        {
            try
            {
                var msg = await ctx.Channel.GetMessageAsync(messageId).ConfigureAwait(false);
                if (msg == null)
                    await ctx.ReactWithAsync(Config.Reactions.Failure).ConfigureAwait(false);
                else
                    LogParsingHandler.EnqueueLogProcessing(ctx.Client, ctx.Channel, msg, ctx.Member, true, true);
            }
            catch
            {
                await ctx.ReactWithAsync(Config.Reactions.Failure).ConfigureAwait(false);
            }
        }

        [Command("analyze")]
        public async Task Reanalyze(CommandContext ctx, [Description("Full message link")] string messageLink)
        {
            try
            {
                var msg = await ctx.GetMessageAsync(messageLink).ConfigureAwait(false);
                if (msg == null)
                    await ctx.ReactWithAsync(Config.Reactions.Failure).ConfigureAwait(false);
                else
                    LogParsingHandler.EnqueueLogProcessing(ctx.Client, ctx.Channel, msg, ctx.Member, true, true);
            }
            catch (Exception e)
            {
                Config.Log.Warn(e);
                await ctx.ReactWithAsync(Config.Reactions.Failure).ConfigureAwait(false);
            }
        }

        [Command("badupdate"), Aliases("bad", "recall"), RequiresBotModRole]
        [Description("Toggles new update announcement as being bad")]
        public async Task BadUpdate(CommandContext ctx, [Description("Link to the update announcement")] string updateMessageLink)
        {
            var msg = await ctx.GetMessageAsync(updateMessageLink).ConfigureAwait(false);
            var embed = msg?.Embeds?.FirstOrDefault();
            if (embed == null)
            {
                await ctx.ReactWithAsync(Config.Reactions.Failure, "Invalid update announcement link").ConfigureAwait(false);
                return;
            }

            await ToggleBadUpdateAnnouncementAsync(msg).ConfigureAwait(false);
            await ctx.ReactWithAsync(Config.Reactions.Success).ConfigureAwait(false);
        }

        public static async Task ToggleBadUpdateAnnouncementAsync(DiscordMessage? message)
        {
            var embed = message?.Embeds?.FirstOrDefault();
            if (message is null || embed is null)
                return;

            var result = new DiscordEmbedBuilder(embed);
            const string warningTitle = "Warning!";
            if (embed.Color.Value.Value == Config.Colors.UpdateStatusGood.Value)
            {<commit_msg>make !analyze work for very smart users<commit_after>﻿using System;
using System.Linq;
using System.Threading.Tasks;
using CompatBot.Commands.Attributes;
using CompatBot.EventHandlers;
using CompatBot.Utils;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;

namespace CompatBot.Commands
{
    internal sealed partial class Moderation: BaseCommandModuleCustom
    {
        [Command("report"), RequiresWhitelistedRole]
        [Description("Adds specified message to the moderation queue")]
        public async Task Report(CommandContext ctx, [Description("Message ID from current channel to report")] ulong messageId, [RemainingText, Description("Optional report comment")] string? comment = null)
        {
            try
            {
                var msg = await ctx.Channel.GetMessageAsync(messageId).ConfigureAwait(false);
                await ReportMessage(ctx, comment, msg);
            }
            catch (Exception)
            {
                await ctx.ReactWithAsync(Config.Reactions.Failure, "Failed to report the message").ConfigureAwait(false);
            }
        }

        [Command("report"), RequiresWhitelistedRole]
        [Description("Adds specified message to the moderation queue")]
        public async Task Report(CommandContext ctx, [Description("Message link to report")] string messageLink, [RemainingText, Description("Optional report comment")] string? comment = null)
        {
            try
            {
                var msg = await ctx.GetMessageAsync(messageLink).ConfigureAwait(false);
                if (msg is null)
                {
                    await ctx.ReactWithAsync(Config.Reactions.Failure, "Can't find linked message").ConfigureAwait(false);
                    return;
                }
                
                await ReportMessage(ctx, comment, msg);
            }
            catch (Exception)
            {
                await ctx.ReactWithAsync(Config.Reactions.Failure, "Failed to report the message").ConfigureAwait(false);
            }
        }

        [Command("analyze"), Aliases("reanalyze", "parse", "a")]
        [Description("Make bot to look at the attached log again")]
        public async Task Reanalyze(CommandContext ctx, [Description("Message ID from the same channel")]ulong messageId)
        {
            try
            {
                var msg = await ctx.Channel.GetMessageAsync(messageId).ConfigureAwait(false);
                if (msg == null)
                    await ctx.ReactWithAsync(Config.Reactions.Failure).ConfigureAwait(false);
                else
                    LogParsingHandler.EnqueueLogProcessing(ctx.Client, ctx.Channel, msg, ctx.Member, true, true);
            }
            catch
            {
                await ctx.ReactWithAsync(Config.Reactions.Failure).ConfigureAwait(false);
            }
        }

        [Command("analyze")]
        public async Task Reanalyze(CommandContext ctx, [Description("Full message link")] string messageLink)
        {
            try
            {
                var msg = await ctx.GetMessageAsync(messageLink).ConfigureAwait(false);
                if (msg == null)
                    await ctx.ReactWithAsync(Config.Reactions.Failure).ConfigureAwait(false);
                else
                    LogParsingHandler.EnqueueLogProcessing(ctx.Client, ctx.Channel, msg, ctx.Member, true, true);
            }
            catch (Exception e)
            {
                Config.Log.Warn(e);
                await ctx.ReactWithAsync(Config.Reactions.Failure).ConfigureAwait(false);
            }
        }
        
        
        [Command("analyze")]
        public async Task Reanalyze(CommandContext ctx)
        {
            try
            {
                LogParsingHandler.EnqueueLogProcessing(ctx.Client, ctx.Channel, ctx.Message, ctx.Member, true, true);
            }
            catch (Exception e)
            {
                Config.Log.Warn(e);
                await ctx.ReactWithAsync(Config.Reactions.Failure).ConfigureAwait(false);
            }
        }

        [Command("badupdate"), Aliases("bad", "recall"), RequiresBotModRole]
        [Description("Toggles new update announcement as being bad")]
        public async Task BadUpdate(CommandContext ctx, [Description("Link to the update announcement")] string updateMessageLink)
        {
            var msg = await ctx.GetMessageAsync(updateMessageLink).ConfigureAwait(false);
            var embed = msg?.Embeds?.FirstOrDefault();
            if (embed == null)
            {
                await ctx.ReactWithAsync(Config.Reactions.Failure, "Invalid update announcement link").ConfigureAwait(false);
                return;
            }

            await ToggleBadUpdateAnnouncementAsync(msg).ConfigureAwait(false);
            await ctx.ReactWithAsync(Config.Reactions.Success).ConfigureAwait(false);
        }

        public static async Task ToggleBadUpdateAnnouncementAsync(DiscordMessage? message)
        {
            var embed = message?.Embeds?.FirstOrDefault();
            if (message is null || embed is null)
                return;

            var result = new DiscordEmbedBuilder(embed);
            const string warningTitle = "Warning!";
            if (embed.Color.Value.Value == Config.Colors.UpdateStatusGood.Value)
            {
{'fraction_non_alphanumeric': 0.09157473396465879, 'fraction_numerical': 0.0, 'mean_word_length': 2.0883328308712694, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2740384', 'n_tokens_mistral': 2536, 'n_tokens_neox': 2511, 'n_words': 587}