Exemplo n.º 1
0
        private static string ReturnEventTypeString(DisciplinaryEventEnum eventType)
        {
            switch (eventType)
            {
            case DisciplinaryEventEnum.BanEvent:
                return("banned");

            case DisciplinaryEventEnum.BanCleanseEvent:
                return("bancleansed");

            case DisciplinaryEventEnum.KickEvent:
                return("kicked");

            case DisciplinaryEventEnum.MuteEvent:
                return("muted");

            case DisciplinaryEventEnum.LimitedUserEvent:
                return("limited");

            case DisciplinaryEventEnum.WarnEvent:
                return("warned");

            default:
                return("disciplined");
            }
        }
Exemplo n.º 2
0
        public static async Task ReapplyDisciplinaryAction(DisciplinaryEventEnum eventType, SocketGuildUser user)
        {
            try
            {
                IRole role;
                switch (eventType)
                {
                case DisciplinaryEventEnum.MuteEvent:
                    role = DiscordContextSeymour.GrabRole(MordhauRoleEnum.Muted);
                    await user.AddRoleAsync(role);

                    break;

                case DisciplinaryEventEnum.LimitedUserEvent:
                    role = DiscordContextSeymour.GrabRole(MordhauRoleEnum.LimitedUser);
                    await user.AddRoleAsync(role);

                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ErrMessages.AutomaticDisciplinaryReapplication, ex);
            }
        }
Exemplo n.º 3
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;
            }
        }
Exemplo n.º 4
0
        public async static Task CreateEvent(DisciplinaryEventEnum eventType, ulong moderatorId, string reason, ulong userId, string userName, DateTime end)
        {
            UserDisciplinaryEventStorage newEvent = new UserDisciplinaryEventStorage()
            {
                DateInserted         = DateTime.UtcNow,
                DateToRemove         = end,
                DiscipinaryEventType = eventType,
                ModeratorID          = moderatorId,
                Reason = reason,
                UserID = userId
            };
            UserStorage newUser = new UserStorage()
            {
                UserID   = userId,
                UserName = userName
            };

            await HandleEventCreated(newEvent, newUser);
        }
Exemplo n.º 5
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;
            }
        }
Exemplo n.º 6
0
        public static Embed BuildDefaultEmbed(DisciplinaryEventEnum eventType,
                                              TimeSpan timeSpan,
                                              string reason,
                                              string targetName,
                                              bool existing,
                                              string author = "Seymour")
        {
            try
            {
                switch (eventType)
                {
                case DisciplinaryEventEnum.KickEvent:
                    return(GenerateKickEmbed(eventType, author, reason, targetName));

                case DisciplinaryEventEnum.BanEvent:
                    break;

                case DisciplinaryEventEnum.BanCleanseEvent:
                    break;

                case DisciplinaryEventEnum.MuteEvent:
                    break;

                case DisciplinaryEventEnum.LimitedUserEvent:
                    break;

                case DisciplinaryEventEnum.WarnEvent:
                    break;

                default:
                    break;
                }

                return(GenerateDefaultEmbed(eventType, timeSpan, reason, targetName, existing, author));
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException($"{typeof(Utilities).GetType().FullName}: {ExceptionManager.GetAsyncMethodName()}", ex);
                throw;
            }
        }
Exemplo n.º 7
0
        public static async Task RemoveDisciplinaryEventAsync(ulong userID, DisciplinaryEventEnum type)
        {
            try
            {
                using (var db = new UserContext())
                {
                    //check event table first
                    UserDisciplinaryEventStorage[] existingEvents;

                    if (type == DisciplinaryEventEnum.BanEvent)
                    {
                        existingEvents = await db.UserDisciplinaryEventStorageTable.AsQueryable().Where(x => x.UserID == userID).ToArrayAsync();
                    }
                    else
                    {
                        existingEvents = await db.UserDisciplinaryEventStorageTable.AsQueryable().Where(x => x.UserID == userID &&
                                                                                                        x.DiscipinaryEventType == type).ToArrayAsync();
                    }

                    if (existingEvents.Count() > 0)
                    {
                        foreach (var item in existingEvents)
                        {
                            await TimedEventManager.RemoveEvent(item.DisciplineEventID);

                            db.UserDisciplinaryEventStorageTable.Remove(item);
                            var archivedEvent = new UserDisciplinaryEventArchive()
                            {
                                DateArchived      = DateTime.UtcNow,
                                DateInserted      = item.DateInserted,
                                DateToRemove      = item.DateToRemove,
                                DisciplineEventID = item.DisciplineEventID,
                                DisciplineType    = item.DiscipinaryEventType,
                                ModeratorID       = item.ModeratorID,
                                Reason            = item.Reason,
                                UserID            = item.UserID
                            };
                            await db.UserDisciplinaryEventArchiveTable.AddAsync(archivedEvent);
                        }
                    }
                    else //check permanent event table if can't find
                    {
                        UserDisciplinaryPermanentStorage[] existingPermaEvents;

                        if (type == DisciplinaryEventEnum.BanEvent)
                        {
                            existingPermaEvents = await db.UserDisciplinaryPermanentStorageTable.AsQueryable().Where(x => x.UserID == userID).ToArrayAsync();
                        }
                        else
                        {
                            existingPermaEvents = await db.UserDisciplinaryPermanentStorageTable.AsQueryable().Where(x => x.UserID == userID &&
                                                                                                                     x.DiscipinaryEventType == type).ToArrayAsync();
                        }

                        if (existingPermaEvents.Count() > 0)
                        {
                            foreach (var item in existingPermaEvents)
                            {
                                await TimedEventManager.RemoveEvent(item.DisciplineEventID);

                                db.UserDisciplinaryPermanentStorageTable.Remove(item);
                                var archivedEvent = new UserDisciplinaryEventArchive()
                                {
                                    DateArchived      = DateTime.UtcNow,
                                    DateInserted      = item.DateInserted,
                                    DisciplineEventID = item.DisciplineEventID,
                                    DisciplineType    = item.DiscipinaryEventType,
                                    ModeratorID       = item.ModeratorID,
                                    Reason            = item.Reason,
                                    UserID            = item.UserID
                                };
                                await db.UserDisciplinaryEventArchiveTable.AddAsync(archivedEvent);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException($"{typeof(StorageManager).GetType().FullName}: {ExceptionManager.GetAsyncMethodName()}", ex);
                throw ex;
            }
        }