Exemplo n.º 1
0
        public async Task DeleteInfraction(int InfractionID)
        {
            Infraction Infraction = InfractionsDB.Infractions.Find(InfractionID);

            Infraction.EntryType = EntryType.Revoke;

            SocketGuildUser Issuer = Context.Guild.GetUser(Infraction.Issuer);
            SocketGuildUser Warned = Context.Guild.GetUser(Infraction.User);

            DexterProfile DexterProfile = InfractionsDB.GetOrCreateProfile(Infraction.User);

            DexterProfile.InfractionAmount += Infraction.PointCost;

            if (DexterProfile.InfractionAmount > ModerationConfiguration.MaxPoints)
            {
                DexterProfile.InfractionAmount = ModerationConfiguration.MaxPoints;
            }

            if (Infraction.PointCost > 2)
            {
                await RemoveMutedRole(new() { { "UserID", Infraction.User.ToString() } });
            }

            InfractionsDB.SaveChanges();

            await BuildEmbed(EmojiEnum.Love)
            .WithTitle($"Infraction Revoked! New Points: {DexterProfile.InfractionAmount}.")
            .WithDescription($"Heya! I revoked an infraction issued from {(Warned == null ? $"Unknown ({Infraction.User})" : Warned.GetUserInformation())}")
            .AddField("Issued by", Issuer == null ? $"Unknown ({Infraction.Issuer})" : Issuer.GetUserInformation())
            .AddField("Revoked by", Context.User.GetUserInformation())
            .AddField("Reason", Infraction.Reason)
            .WithCurrentTimestamp()
            .SendEmbed(Context.Channel);
        }
Exemplo n.º 2
0
        /// <summary>
        /// The PurgeWarningsCallback fires on an admin approving a purge confirmation. It sets all warnings to a revoked state.
        /// </summary>
        /// <param name="CallbackInformation">The callback information is a dictionary of parameters parsed to the original callback statement.
        ///     UserID = Specifies the UserID who will have their warnings purged.
        /// </param>
        /// <returns>A <c>Task</c> object, which can be awaited until this method completes successfully.</returns>

        public async void PurgeWarningsCallback(Dictionary <string, string> CallbackInformation)
        {
            ulong UserID = Convert.ToUInt64(CallbackInformation["UserID"]);

            int Count = InfractionsDB.GetInfractions(UserID).Length;

            await InfractionsDB.Infractions.AsQueryable().Where(Warning => Warning.User == UserID).ForEachAsync(Warning => Warning.EntryType = EntryType.Revoke);

            InfractionsDB.SaveChanges();

            await BuildEmbed(EmojiEnum.Love)
            .WithTitle("Infractions Purged")
            .WithDescription($"Heya! I've purged {Count} warnings from your account. You now have a clean slate! <3")
            .WithCurrentTimestamp()
            .SendEmbed(await Client.GetUser(UserID).GetOrCreateDMChannelAsync());
        }
Exemplo n.º 3
0
        public async Task DeleteInfraction(IGuildUser User)
        {
            DexterProfile DexterProfile = InfractionsDB.GetOrCreateProfile(User.Id);

            DexterProfile.CurrentPointTimer = string.Empty;

            await RemoveMutedRole(new() { { "UserID", User.Id.ToString() } });

            InfractionsDB.SaveChanges();

            await BuildEmbed(EmojiEnum.Love)
            .WithTitle($"Successfully Unmuted {User.Username}.")
            .WithDescription($"Heya! I have successfully unmuted {User.GetUserInformation()}. Give them a headpat. <3")
            .WithCurrentTimestamp()
            .SendEmbed(Context.Channel);
        }
Exemplo n.º 4
0
        public async Task IssueFinalWarn(IGuildUser User, TimeSpan MuteDuration, [Remainder] string Reason)
        {
            short PointsDeducted = ModerationConfiguration.FinalWarningPointsDeducted;

            if (FinalWarnsDB.IsUserFinalWarned(User))
            {
                await BuildEmbed(EmojiEnum.Annoyed)
                .WithTitle("User is already final warned!")
                .WithDescription($"The target user, {User.GetUserInformation()}, already has an active final warn. If you wish to overwrite this final warn, first remove the already existing one.")
                .SendEmbed(Context.Channel);

                return;
            }

            DexterProfile DexterProfile = InfractionsDB.GetOrCreateProfile(User.Id);

            DexterProfile.InfractionAmount -= PointsDeducted;

            if (!TimerService.TimerExists(DexterProfile.CurrentPointTimer))
            {
                DexterProfile.CurrentPointTimer = await CreateEventTimer(IncrementPoints, new() { { "UserID", User.Id.ToString() } }, ModerationConfiguration.SecondsTillPointIncrement, TimerType.Expire);
            }


            ulong WarningLogID = 0;

            if (ModerationConfiguration.FinalWarningsManageRecords)
            {
                WarningLogID = (await(DiscordSocketClient.GetChannel(ModerationConfiguration.FinalWarningsChannelID) as ITextChannel).SendMessageAsync(
                                    $"**Final Warning Issued >>>** <@&{BotConfiguration.ModeratorRoleID}>\n" +
                                    $"**User**: {User.GetUserInformation()}\n" +
                                    $"**Issued on**: {DateTime.Now:MM/dd/yyyy}\n" +
                                    $"**Reason**: {Reason}")).Id;
            }

            FinalWarnsDB.SetOrCreateFinalWarn(PointsDeducted, Context.User as IGuildUser, User, MuteDuration, Reason, WarningLogID);

            await MuteUser(User, MuteDuration);

            try {
                await BuildEmbed(EmojiEnum.Annoyed)
                .WithTitle($"🚨 You were issued a **FINAL WARNING** from {Context.Guild.Name}! 🚨")
                .WithDescription(Reason)
                .AddField("Points Deducted:", PointsDeducted, true)
                .AddField("Mute Duration:", MuteDuration.Humanize(), true)
                .WithCurrentTimestamp()
                .SendEmbed(await User.GetOrCreateDMChannelAsync());

                await BuildEmbed(EmojiEnum.Love)
                .WithTitle("Message sent successfully!")
                .WithDescription($"The target user, {User.GetUserInformation()}, has been informed of their current status.")
                .AddField("Mute Duration:", MuteDuration.Humanize(), true)
                .AddField("Points Deducted:", PointsDeducted, true)
                .AddField("Issued By:", Context.User.GetUserInformation())
                .AddField("Reason:", Reason)
                .WithCurrentTimestamp()
                .SendEmbed(Context.Channel);
            }
            catch (HttpException) {
                await BuildEmbed(EmojiEnum.Annoyed)
                .WithTitle("Message failed!")
                .WithDescription($"The target user, {User.GetUserInformation()}, might have DMs disabled or might have blocked me... :c\nThe final warning has been recorded to the database regardless.")
                .SendEmbed(Context.Channel);
            }

            InfractionsDB.SaveChanges();
        }