Esempio n. 1
0
        private async Task UnmuteUserAsync(ulong userID)
        {
            try
            {
                SocketGuildUser user = Context.Guild.GetUser(userID);
                if (user == null)
                {
                    await Context.Channel.SendMessageAsync($"Unable to locate user {DiscordContextSeymour.GetEmoteAyySeymour()}");

                    return;
                }

                var role = user.Roles.FirstOrDefault(x => x.Id == ConfigManager.GetUlongProperty(PropertyItem.Role_Muted));

                if (role != null)
                {
                    await Context.Channel.SendMessageAsync("Cannot see muted role on that user");

                    return;
                }

                await user.RemoveRoleAsync(role);

                var embed = Utilities.BuildRemoveDisciplinaryEmbed($"Successfully unmuted", user.Username);
                await Context.Channel.SendMessageAsync("", false, embed);

                await StorageManager.RemoveDisciplinaryEventAsync(userID, DisciplinaryEventEnum.MuteEvent);

                await DiscordContextOverseer.LogModerationAction(userID, "Unmuted", Context.Message.Author.Id, "", "");
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ErrMessages.UnmuteException, ex);
            }
        }
Esempio n. 2
0
        private async Task UnblacklistUserAsync(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;
                }

                bool existing = await StorageManager.RemoveBlacklist(user.Id);

                if (existing)
                {
                    var embed = Utilities.BuildRemoveDisciplinaryEmbed("Successfully unblacklisted", user.Username);
                    await Context.Channel.SendMessageAsync("", false, embed);
                }
                else
                {
                    await Context.Channel.SendMessageAsync("Could not find that user within the blacklist");
                }
                await DiscordContextOverseer.LogModerationAction(user.Id, "Unblacklisted", Context.Message.Author.Id, "", "");
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ErrMessages.UnblacklistException, ex);
            }
        }
Esempio n. 3
0
        public async Task WarnUserAsync(ulong userID, SocketGuildChannel chnl, [Remainder] string reason = "")
        {
            try
            {
                SocketGuildUser user    = Context.Guild.GetUser(userID);
                var             channel = chnl as ITextChannel;
                if (user == null)
                {
                    await Context.Channel.SendMessageAsync($"Unable to locate user {DiscordContextSeymour.GetEmoteAyySeymour()}");

                    return;
                }
                if (await DiscordContextSeymour.IsUserDevOrAdminAsync(user as SocketGuildUser))
                {
                    return;
                }

                UserDisciplinaryEventStorage obj = new UserDisciplinaryEventStorage()
                {
                    DateInserted         = DateTime.UtcNow,
                    DateToRemove         = DateTime.UtcNow.AddDays(ConfigManager.GetIntegerProperty(PropertyItem.WarnDuration)),
                    DiscipinaryEventType = DisciplinaryEventEnum.WarnEvent,
                    ModeratorID          = Context.Message.Author.Id,
                    Reason = reason,
                    UserID = user.Id
                };
                UserStorage newUser = new UserStorage()
                {
                    UserID   = user.Id,
                    UserName = user.Username
                };
                await TimedEventManager.CreateEvent(obj, newUser);

                int warnCount = await StorageManager.GetRecentWarningsAsync(user.Id);

                string maxWarns = ConfigManager.GetProperty(PropertyItem.MaxWarns);
                if (string.IsNullOrEmpty(reason))
                {
                    await channel.SendMessageAsync($"{user.Mention} {BotDialogs.WarnMessageNoReason}🚫\n{warnCount}/{maxWarns} warnings.");
                }
                else
                {
                    await channel.SendMessageAsync($"{user.Mention} {BotDialogs.WarnMessageReason} 🚫\n{warnCount}/{maxWarns} warnings.\n{reason}");
                }
                await AutoModeratorManager.CheckForWarnThreshold(user, Context, warnCount, channel);
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ErrMessages.WarnException, ex);
            }
        }
Esempio n. 4
0
        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);
            }
        }
Esempio n. 5
0
        private async Task BanUserAsync(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(reason : reason);
                }
                else
                {
                    return;
                }

                var embed = Utilities.BuildDefaultEmbed(DisciplinaryEventEnum.BanEvent, timeSpan, reason, kickTargetName, false);
                await Context.Channel.SendMessageAsync("", false, embed);

                UserDisciplinaryEventStorage obj = new UserDisciplinaryEventStorage()
                {
                    DateInserted         = DateTime.UtcNow,
                    DateToRemove         = (DateTimeOffset.UtcNow + timeSpan).DateTime,
                    DiscipinaryEventType = DisciplinaryEventEnum.BanEvent,
                    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.BanException, ex);
            }
        }
Esempio n. 6
0
        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);
            }
        }
Esempio n. 7
0
        private async Task CleanChat()
        {
            try
            {
                int amount = 2;

                var messages = await Context.Channel.GetMessagesAsync(amount).FlattenAsync();

                var chnl = Context.Channel as ITextChannel;
                await chnl.DeleteMessagesAsync(messages);

                await Context.Channel.SendMessageAsync($"{DiscordContextSeymour.GetEmoteAyySeymour().ToString()}");
            }
            catch (System.Exception ex)
            {
                ExceptionManager.HandleException(ErrMessages.CleanseException, ex);
            }
        }
Esempio n. 8
0
        public static Embed BuildRemoveDisciplinaryEmbed(string action, string targetName)
        {
            try
            {
                var seymourEmote = DiscordContextSeymour.GetEmoteAyySeymour();

                var embed = new EmbedBuilder();
                embed.WithTitle($"{action} {targetName} {seymourEmote.ToString()} ");
                embed.WithColor(new Color(0, 255, 0));

                return(embed.Build());
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException($"{typeof(Utilities).GetType().FullName}: {ExceptionManager.GetAsyncMethodName()}", ex);
                throw;
            }
        }
Esempio n. 9
0
        private async Task PermaBanCleanseUser(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.BanAsync(7, reason);
                }
                else
                {
                    return;
                }

                var embed = Utilities.BuildDefaultEmbed(DisciplinaryEventEnum.BanCleanseEvent, new TimeSpan(), reason, kickTargetName, false);
                await DiscordContextSeymour.GetMainChannel().SendMessageAsync("", false, embed);

                await StorageManager.StoreDisciplinaryPermanentEventAsync(new UserDisciplinaryPermanentStorage()
                {
                    DateInserted         = DateTime.UtcNow,
                    DiscipinaryEventType = DisciplinaryEventEnum.BanCleanseEvent,
                    ModeratorID          = Context.Message.Author.Id,
                    Reason = reason,
                    UserID = Context.Message.Author.Id
                },
                                                                          new UserStorage()
                {
                    UserID   = user.Id,
                    UserName = user.Username,
                });
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ErrMessages.BancleanseException, ex);
            }
        }
Esempio n. 10
0
        private static Embed GenerateKickEmbed(DisciplinaryEventEnum eventType, string author, string reason, string targetName)
        {
            try
            {
                var seymourEmote = DiscordContextSeymour.GetEmoteAyySeymour();

                var embed = new EmbedBuilder();
                embed.WithTitle($"{author} booted {targetName} {seymourEmote.ToString()} ");
                embed.WithDescription($"reason: {reason}");
                embed.WithColor(new Color(255, 0, 0));

                return(embed.Build());
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException($"{typeof(Utilities).GetType().FullName}: {ExceptionManager.GetAsyncMethodName()}", ex);
                throw;
            }
        }
Esempio n. 11
0
        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);
            }
        }
Esempio n. 12
0
        private async Task CleanChatAmount(int amount)
        {
            try
            {
                if (amount > 0)
                {
                    var messages = await Context.Channel.GetMessagesAsync(amount + 1).FlattenAsync();

                    var chnl = Context.Channel as ITextChannel;

                    await chnl.DeleteMessagesAsync(messages);

                    var embed = new EmbedBuilder();
                    embed.WithTitle($"Cleansed {amount} messages {DiscordContextSeymour.GetEmoteAyySeymour().ToString()}");
                    embed.WithColor(new Color(0, 255, 0));

                    await Context.Channel.SendMessageAsync("", false, embed.Build());
                }
            }
            catch (System.Exception ex)
            {
                ExceptionManager.HandleException(ErrMessages.CleanseException, ex);
            }
        }
Esempio n. 13
0
        private async Task DeleteInfoCommand([Remainder] string UserInput)
        {
            try
            {
                bool existing = await StorageManager.DeleteInfoCommandAsync(UserInput.ToLower());

                if (existing)
                {
                    await Context.Channel.SendMessageAsync($"Deleted \"{UserInput}\" {DiscordContextSeymour.GetEmoteAyySeymour()}");
                }
                else
                {
                    await Context.Channel.SendMessageAsync($"Unable to find \"{UserInput}\" {DiscordContextSeymour.GetEmoteAyySeymour()}");
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ErrMessages.CustomCommand, ex);
            }
        }
Esempio n. 14
0
        private async Task StoreInfoCommandTest([Remainder] string UserInput)
        {
            try
            {
                bool    existing = false;
                Command command  = new Command(UserInput);
                if (!command.Error)
                {
                    existing = await StorageManager.StoreInfoCommandAsync(command);
                }

                if (existing)
                {
                    await Context.Channel.SendMessageAsync($"Updated {command.CommandName} {DiscordContextSeymour.GetEmoteAyySeymour()}");
                }
                else
                {
                    await Context.Channel.SendMessageAsync($"Added {command.CommandName} {DiscordContextSeymour.GetEmoteAyySeymour()}");
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ErrMessages.CustomCommand, ex);
            }
        }
Esempio n. 15
0
        private async Task CleanChatUser(SocketGuildUser user)
        {
            try
            {
                var usersocket     = user as SocketGuildUser;
                int amount         = 300;
                var msgsCollection = await Context.Channel.GetMessagesAsync(amount).FlattenAsync();

                var result = from m in msgsCollection
                             where m.Author == user
                             select m.Id;

                var chnl             = Context.Channel as ITextChannel;
                int amountOfMessages = result.Count();
                await chnl.DeleteMessagesAsync(result);

                var embed = new EmbedBuilder();
                embed.WithTitle($"Cleansed {amountOfMessages} messages from {user.Username} {DiscordContextSeymour.GetEmoteAyySeymour().ToString()}");
                embed.WithColor(new Color(0, 255, 0));

                await Context.Channel.SendMessageAsync("", false, embed.Build());
            }
            catch (System.Exception ex)
            {
                ExceptionManager.HandleException(ErrMessages.CleanseException, ex);
            }
        }
Esempio n. 16
0
        public static Embed BuildBlacklistEmbed(TimeSpan timeSpan, string username, bool existing, string author = "SeymourBot")
        {
            try
            {
                string commandName = "blacklisted";
                string duration    = "1 month";

                if (timeSpan.TotalDays >= 1)
                {
                    duration = $"{Math.Round(timeSpan.TotalDays, 2)} day{SAppend(timeSpan.TotalDays)}.";
                }
                else if (timeSpan.TotalHours >= 1)
                {
                    duration = $"{Math.Round(timeSpan.TotalHours, 2)} hour{SAppend(timeSpan.TotalHours)}.";
                }
                else if (timeSpan.TotalMinutes >= 1)
                {
                    duration = $"{Math.Round(timeSpan.TotalMinutes, 2)} min{SAppend(timeSpan.TotalMinutes)}.";
                }

                Emote emote = duration == "Permanent" ? DiscordContextSeymour.GetEmoteReee() : DiscordContextSeymour.GetEmoteAyySeymour();

                string existingDisciplinary = String.Empty;
                if (existing)
                {
                    existingDisciplinary = " updated to";
                }

                var embed = new EmbedBuilder();
                embed.WithTitle($"{author} {commandName} {username} {emote.ToString()}");
                embed.WithDescription($"Duration{existingDisciplinary}: {duration}");
                embed.WithColor(new Color(255, 0, 0));

                return(embed.Build());
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException($"{typeof(Utilities).GetType().FullName}: {ExceptionManager.GetAsyncMethodName()}", ex);
                throw;
            }
        }
Esempio n. 17
0
        private static Embed GenerateDefaultEmbed(DisciplinaryEventEnum eventType, TimeSpan timeSpan, string reason, string targetName, bool existing, string author)
        {
            try
            {
                string commandName = ReturnEventTypeString(eventType);
                string duration    = "Permanent.";

                if (timeSpan.TotalDays >= 1)
                {
                    duration = $"{Math.Round(timeSpan.TotalDays, 2)} day{SAppend(timeSpan.TotalDays)}.";
                }
                else if (timeSpan.TotalHours >= 1)
                {
                    duration = $"{Math.Round(timeSpan.TotalHours, 2)} hour{SAppend(timeSpan.TotalHours)}.";
                }
                else if (timeSpan.TotalMinutes >= 1)
                {
                    duration = $"{Math.Round(timeSpan.TotalMinutes, 2)} min{SAppend(timeSpan.TotalMinutes)}.";
                }
                else if (timeSpan.TotalSeconds >= 1)
                {
                    duration = $"{Math.Round(timeSpan.TotalSeconds, 2)} sec{SAppend(timeSpan.TotalSeconds)}.";
                }

                Emote emote = duration == "Permanent" ? DiscordContextSeymour.GetEmoteReee() : DiscordContextSeymour.GetEmoteAyySeymour();

                string existingDisciplinary = String.Empty;
                if (existing)
                {
                    existingDisciplinary = " updated to";
                }

                var embed = new EmbedBuilder();
                embed.WithTitle($"{author} {commandName} {targetName} {emote.ToString()}");
                embed.WithDescription($"Reason: {reason}\nDuration{existingDisciplinary}: {duration}");
                embed.WithColor(new Color(255, 0, 0));

                return(embed.Build());
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException($"{typeof(Utilities).GetType().FullName}: {ExceptionManager.GetAsyncMethodName()}", ex);
                throw;
            }
        }
Esempio n. 18
0
        private async Task RaidprotectDisableeAsync()
        {
            try
            {
                var chnl         = Context.Channel as ITextChannel;
                var permOverride = new OverwritePermissions(sendMessages: PermValue.Allow);
                await chnl.AddPermissionOverwriteAsync(Context.Guild.EveryoneRole, permOverride);

                await Context.Channel.SendMessageAsync($"The silence has been lifted. {DiscordContextSeymour.GetEmoteAyySeymour()}");
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ErrMessages.RaidprotectException, ex);
            }
        }
Esempio n. 19
0
        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);
            }
        }