private async Task MuteUserAsync(ulong userID, TimeSpan timeSpan, [Remainder] string reason = "no reason specified") { try { SocketGuildUser user = Context.Guild.GetUser(userID); if (user == null) { await Context.Channel.SendMessageAsync($"Unable to locate user {DiscordContextSeymour.GetEmoteAyySeymour()}"); return; } if (await DiscordContextSeymour.IsUserDevOrAdminAsync(user as SocketGuildUser)) { return; } var mutedRole = DiscordContextSeymour.GrabRole(MordhauRoleEnum.Muted); await user.AddRoleAsync(mutedRole); UserDisciplinaryEventStorage newEvent = new UserDisciplinaryEventStorage() { DateInserted = DateTime.UtcNow, DateToRemove = (DateTimeOffset.UtcNow + timeSpan).DateTime, DiscipinaryEventType = DisciplinaryEventEnum.MuteEvent, ModeratorID = Context.Message.Author.Id, Reason = reason, UserID = user.Id }; UserStorage newUser = new UserStorage() { UserID = user.Id, UserName = user.Username }; bool existing = await TimedEventManager.CreateEvent(newEvent, newUser); await DiscordContextOverseer.LogModerationAction(userID, "Muted", Context.Message.Author.Id, reason, Utilities.ShortTimeSpanFormatting(timeSpan)); var embed = Utilities.BuildDefaultEmbed(DisciplinaryEventEnum.MuteEvent, timeSpan, reason, user.Username, existing); await DiscordContextSeymour.GetMainChannel().SendMessageAsync("", false, embed); } catch (Exception ex) { ExceptionManager.HandleException(ErrMessages.MuteException, ex); } }
private async Task PermaRestrictUserAsync(ulong userID, [Remainder] string reason = "no reason specified") { try { SocketGuildUser user = Context.Guild.GetUser(userID); if (user == null) { await Context.Channel.SendMessageAsync($"Unable to locate user {DiscordContextSeymour.GetEmoteAyySeymour()}"); return; } if (await DiscordContextSeymour.IsUserDevOrAdminAsync(user as SocketGuildUser)) { return; } var limitedRole = DiscordContextSeymour.GrabRole(MordhauRoleEnum.Restricted); await user.AddRoleAsync(limitedRole); UserDisciplinaryPermanentStorage newEvent = new UserDisciplinaryPermanentStorage() { DateInserted = DateTime.UtcNow, DiscipinaryEventType = DisciplinaryEventEnum.RestrictedUserEvent, ModeratorID = Context.Message.Author.Id, Reason = reason, UserID = user.Id }; UserStorage newUser = new UserStorage() { UserID = user.Id, UserName = user.Username }; bool existing = await StorageManager.StoreDisciplinaryPermanentEventAsync(newEvent, newUser); var embed = Utilities.BuildDefaultEmbed(DisciplinaryEventEnum.RestrictedUserEvent, new TimeSpan(), reason, user.Username, existing); await DiscordContextSeymour.GetMainChannel().SendMessageAsync("", false, embed); await DiscordContextOverseer.LogModerationAction(userID, "Restricted", Context.Message.Author.Id, reason, ""); } catch (Exception ex) { ExceptionManager.HandleException(ErrMessages.LimitException, ex); } }
private async Task BanCleanseUserAsync(ulong userID, TimeSpan timeSpan, [Remainder] string reason = "no reason specified") { try { SocketGuildUser user = Context.Guild.GetUser(userID); if (user == null) { await Context.Channel.SendMessageAsync($"Unable to locate user {DiscordContextSeymour.GetEmoteAyySeymour()}"); return; } string kickTargetName = user.Username; if (!await DiscordContextSeymour.IsUserDevOrAdminAsync(user as SocketGuildUser)) { await user.BanAsync(7, reason); } else { return; } var embed = Utilities.BuildDefaultEmbed(DisciplinaryEventEnum.BanCleanseEvent, timeSpan, reason, kickTargetName, false); await DiscordContextSeymour.GetMainChannel().SendMessageAsync("", false, embed); UserDisciplinaryEventStorage obj = new UserDisciplinaryEventStorage() { DateInserted = DateTime.UtcNow, DateToRemove = (DateTimeOffset.UtcNow + timeSpan).DateTime, DiscipinaryEventType = DisciplinaryEventEnum.BanCleanseEvent, ModeratorID = Context.Message.Author.Id, Reason = reason, UserID = Context.Message.Author.Id }; UserStorage newUser = new UserStorage() { UserID = Context.Message.Author.Id, UserName = Context.Message.Author.Username }; await TimedEventManager.CreateEvent(obj, newUser); } catch (Exception ex) { ExceptionManager.HandleException(ErrMessages.BancleanseException, ex); } }
private async Task KickUserAsync(ulong userID, [Remainder] string reason = "No reason specified") { try { SocketGuildUser user = Context.Guild.GetUser(userID); if (user == null) { await Context.Channel.SendMessageAsync($"Unable to locate user {DiscordContextSeymour.GetEmoteAyySeymour()}"); return; } string kickTargetName = user.Username; if (!await DiscordContextSeymour.IsUserDevOrAdminAsync(user as SocketGuildUser)) { await user.KickAsync(); } else { return; } await StorageManager.StoreDisciplinaryPermanentEventAsync(new UserDisciplinaryPermanentStorage() { DateInserted = DateTime.UtcNow, DiscipinaryEventType = DisciplinaryEventEnum.KickEvent, ModeratorID = Context.Message.Author.Id, Reason = reason, UserID = Context.Message.Author.Id }, new UserStorage() { UserID = user.Id, UserName = user.Username, }); var embed = Utilities.BuildDefaultEmbed(DisciplinaryEventEnum.KickEvent, new TimeSpan(), reason, kickTargetName, false); await DiscordContextSeymour.GetMainChannel().SendMessageAsync("", false, embed); } catch (Exception ex) { ExceptionManager.HandleException(ErrMessages.KickException, ex); } }
private async Task MonthBlacklistUserAsync(ulong userID) { try { SocketGuildUser user = await Context.Channel.GetUserAsync(userID) as SocketGuildUser; if (user == null) { await Context.Channel.SendMessageAsync($"Unable to locate user {DiscordContextSeymour.GetEmoteAyySeymour()}"); return; } if (await DiscordContextSeymour.IsUserDevOrAdminAsync(user as SocketGuildUser)) { return; } bool existing = await StorageManager.StoreBlacklistReturnIfExisting(new BlacklistUserStorage() { Username = user.Username, DateInserted = DateTime.UtcNow, ModeratorID = Context.Message.Author.Id, DateToRemove = DateTime.UtcNow.AddMonths(1), UserID = user.Id }, new UserStorage() { UserID = user.Id, UserName = user.Username, }); var embed = Utilities.BuildBlacklistEmbed(new TimeSpan(), user.Username, existing); await DiscordContextSeymour.GetMainChannel().SendMessageAsync("", false, embed); await DiscordContextOverseer.LogModerationAction(user.Id, "Blacklisted", Context.Message.Author.Id, "", DateTime.UtcNow.AddMonths(1).Subtract(DateTime.UtcNow).ToString()); } catch (Exception ex) { ExceptionManager.HandleException(ErrMessages.BlacklistException, ex); } }