public async Task RevokeFinalWarn(IGuildUser User, [Remainder] string Reason = "") { if (!FinalWarnsDB.TryRevokeFinalWarn(User, out FinalWarn Warn)) { await BuildEmbed(EmojiEnum.Annoyed) .WithTitle("No active final warn found!") .WithDescription($"Wasn't able to revoke final warning for user {User.GetUserInformation()}, since no active warn exists.") .SendEmbed(Context.Channel); return; } if (Warn.MessageID != 0) { await(await(DiscordSocketClient.GetChannel(ModerationConfiguration.FinalWarningsChannelID) as ITextChannel).GetMessageAsync(Warn.MessageID))?.DeleteAsync(); } await BuildEmbed(EmojiEnum.Love) .WithTitle("Final warn successfully revoked.") .WithDescription($"Successfully revoked final warning for user {User.GetUserInformation()}. You can still query records about this final warning.") .AddField(Reason.Length > 0, "Reason:", Reason) .WithCurrentTimestamp() .SendEmbed(Context.Channel); try { await BuildEmbed(EmojiEnum.Love) .WithTitle("Your final warning has been revoked!") .WithDescription("The staff team has convened and decided to revoke your final warning. Be careful, you can't receive more than two final warnings! A third one is an automatic ban.") .AddField(Reason.Length > 0, "Reason:", Reason) .WithCurrentTimestamp() .SendEmbed(await User.GetOrCreateDMChannelAsync()); } catch (HttpException) { await Context.Channel.SendMessageAsync("This user either has closed DMs or has me blocked! I wasn't able to inform them of this."); } }
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(); }