public static async Task MassMentionCheck(SocketCommandContext context) { try { if (context.Message.MentionedUsers.Count > 8) { SocketUser target = context.Message.Author; await context.Message.DeleteAsync(); await DiscordContextSeymour.AddRole(DiscordContextSeymour.GrabRole(MordhauRoleEnum.Muted), target.Id); await DiscordContextOverseer.LogModerationAction(target.Id, "Muted", "excessive pinging", Utilities.ShortTimeSpanFormatting(new TimeSpan(3, 0, 0, 0))); await TimedEventManager.CreateEvent(DisciplinaryEventEnum.MuteEvent, context.Client.CurrentUser.Id, "excessive pinging", target.Id, target.Username, (DateTimeOffset.UtcNow + new TimeSpan(0, 30, 0)).DateTime); await TimedEventManager.CreateEvent(DisciplinaryEventEnum.WarnEvent, context.Client.CurrentUser.Id, "AutoWarn : excessive pinging", target.Id, target.Username, DateTime.UtcNow.AddDays(ConfigManager.GetIntegerProperty(PropertyItem.WarnDuration))); if (context.Channel != null) { await DiscordContextOverseer.GetChannel(context.Channel.Id).SendMessageAsync($"{context.Message.Author.Mention}, Thou shall not say thy noble's names in vain. {DiscordContextSeymour.GetEmoteAyySeymour()}"); } } } catch (Exception ex) { ExceptionManager.HandleException($"{typeof(AutoModeratorManager).GetType().FullName}: {ExceptionManager.GetAsyncMethodName()}", ex); } }
public static async Task CheckForWarnThreshold(SocketGuildUser target, SocketCommandContext context, int warnCount, ITextChannel chnl = null) { try { if (warnCount >= (ConfigManager.GetIntegerProperty(PropertyItem.MaxWarns))) //more or equal the warn thresold { await DiscordContextSeymour.AddRole(DiscordContextSeymour.GrabRole(MordhauRoleEnum.Muted), target.Id); await DiscordContextOverseer.LogModerationAction(target.Id, "Muted", $"User has been warned {warnCount} times, exceeding the {ConfigManager.GetIntegerProperty(PropertyItem.MaxWarns)} warn threshold", Utilities.ShortTimeSpanFormatting(new TimeSpan(1, 0, 0, 0))); await TimedEventManager.CreateEvent(DisciplinaryEventEnum.MuteEvent, context.Client.CurrentUser.Id, $"User has been warned {warnCount} times, exceeding the {ConfigManager.GetIntegerProperty(PropertyItem.MaxWarns)} warn threshold", target.Id, target.Username, (DateTimeOffset.UtcNow + new TimeSpan(1, 0, 0, 0)).DateTime); if (chnl == null) { await DiscordContextOverseer.GetChannel(context.Channel.Id).SendMessageAsync($"Silence. {target.Mention}"); } else { await DiscordContextOverseer.GetChannel(chnl.Id).SendMessageAsync($"Silence. {target.Mention}"); } } else if (warnCount > (ConfigManager.GetIntegerProperty(PropertyItem.MaxWarns) / 2)) //more than half the warn thresold { await DiscordContextSeymour.AddRole(DiscordContextSeymour.GrabRole(MordhauRoleEnum.Muted), target.Id); await DiscordContextOverseer.LogModerationAction(target.Id, "Muted", $"User has been warned {warnCount} times, exceeding half of the {ConfigManager.GetIntegerProperty(PropertyItem.MaxWarns)} warn threshold", Utilities.ShortTimeSpanFormatting(new TimeSpan(0, 30, 0))); await TimedEventManager.CreateEvent(DisciplinaryEventEnum.MuteEvent, context.Client.CurrentUser.Id, $"User has been warned {warnCount} times, exceeding half of the {ConfigManager.GetIntegerProperty(PropertyItem.MaxWarns)} warn threshold", target.Id, target.Username, (DateTimeOffset.UtcNow + new TimeSpan(0, 30, 0)).DateTime); if (chnl == null) //channel specified check { await DiscordContextOverseer.GetChannel(context.Channel.Id).SendMessageAsync($"{target.Mention}, enough."); } else { await DiscordContextOverseer.GetChannel(chnl.Id).SendMessageAsync($"{target.Mention}, enough."); } } } catch (Exception ex) { ExceptionManager.HandleException(ErrMessages.CheckForWarnThresholdException, ex); } }
private async Task OverseerSayCustomMessage([Remainder] string input) { try { if (Context.Message.MentionedChannels.Count == 0) { await Context.Channel.SendMessageAsync("You must mention the channel: (#channel_name)"); return; } var targetChannel = Context.Message.MentionedChannels.FirstOrDefault() as ITextChannel; var targetChannelAsString = $"<#{targetChannel.Id}>"; var sanitizedInput = input.Replace(targetChannelAsString, string.Empty); var overseerTargetChannel = DiscordContextOverseer.GetChannel(targetChannel.Id); await overseerTargetChannel.SendMessageAsync(sanitizedInput); } catch (Exception ex) { ExceptionManager.HandleException(ErrMessages.SayException, ex); } }