Ejemplo n.º 1
0
        protected override async Task ExecuteGuild(IGuildCommandContext context, object argObj)
        {
            ArgumentContainer args = argObj as ArgumentContainer;

            GuildModerationLog  guildModerationLog = GuildModerationLog.GetOrCreateGuildModerationLog(context.Guild.Id);
            UserModerationLog   userModerationLog  = guildModerationLog.GetOrCreateUserModerationLog(args.UserId);
            UserModerationEntry moderationEntry    = new UserModerationEntry(context.Guild.Id, ModerationType.Note, null, context.GuildUser, args.Note);
            await userModerationLog.AddModerationEntry(moderationEntry);

            await context.Channel.SendEmbedAsync($"Added Note `{args.Note}` to modlogs for {(args.TargetUser == null ? Markdown.InlineCodeBlock(args.UserId.ToString()) : args.TargetUser.Mention)}");
        }
Ejemplo n.º 2
0
        protected override async Task ExecuteGuild(IGuildCommandContext context, object parsedArgs)
        {
            ArgumentContainer args = parsedArgs as ArgumentContainer;
            await context.Guild.RemoveBanAsync(args.UserId);

            GuildModerationLog guildLog = GuildModerationLog.GetOrCreateGuildModerationLog(context.Guild.Id);
            UserModerationLog  userLog  = guildLog.GetOrCreateUserModerationLog(args.UserId);
            var entry = new UserModerationEntry(context.Guild.Id, ModerationType.UnBanned, null, context.GuildUser, args.Reason);
            await userLog.UnBan(context.Guild, entry);

            await context.Channel.SendEmbedAsync($"Unbanned `{args.UserId}`");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Handles a mention event
        /// </summary>
        /// <param name="user">The user who sent the mentioning message</param>
        /// <param name="messageEMs">Amount of EMs inside that message</param>
        private static async Task HandleMention(SocketGuildUser user, int messageEMs)
        {
            bool firstInfraction = true;
            int  totalEMs        = messageEMs;


            List <MentionEvent> removeEvents = new List <MentionEvent>();

            foreach (MentionEvent oldEvent in MentionEvents)
            {
                if (!oldEvent.IsValid)
                {
                    removeEvents.Add(oldEvent);
                    continue;
                }
                if (oldEvent.UserId == user.Id)
                {
                    firstInfraction = false;
                    totalEMs       += oldEvent.EffectiveMentions;
                }
            }
            foreach (MentionEvent removeEvent in removeEvents)
            {
                MentionEvents.Remove(removeEvent);
            }

            MentionEvent mentionEvent = new MentionEvent(user.Id, messageEMs);

            MentionEvents.Add(mentionEvent);

            if (totalEMs >= EM_MUTE_LIMIT && !firstInfraction)
            {
                UserModerationLog userModLog = GuildModerationLog.GetOrCreateUserModerationLog(user.Guild.Id, user.Id, out GuildModerationLog guildModLog);

                await userModLog.AddMute(user, DateTimeOffset.MaxValue, null);

                IDMChannel dmChannel = await user.GetOrCreateDMChannelAsync();

                await dmChannel.SendMessageAsync(embed : MuteEmbed.Build());

                await AdminTaskInteractiveMessage.CreateAdminTaskMessage($"Muted User {user} for exceeding the EM limits", $"User: {user.Mention}\nEffective Mentions: `{totalEMs}/{EM_MUTE_LIMIT}`");
            }
            else if (totalEMs >= EM_WARNING_LIMIT)
            {
                // Handle Warning
                IDMChannel dmChannel = await user.GetOrCreateDMChannelAsync();

                await dmChannel.SendMessageAsync(embed : WarningEmbed.Build());
            }
        }
Ejemplo n.º 4
0
        protected override async Task ExecuteGuild(IGuildCommandContext context, object argObj)
        {
            ArgumentContainer args      = argObj as ArgumentContainer;
            IDMChannel        dmchannel = await args.TargetUser.GetOrCreateDMChannelAsync();

            await dmchannel.SendMessageAsync($"You have been warned on {context.Guild} for `{args.Warning}`!");

            GuildModerationLog  guildModerationLog = GuildModerationLog.GetOrCreateGuildModerationLog(context.Guild.Id);
            UserModerationLog   userModerationLog  = guildModerationLog.GetOrCreateUserModerationLog(args.TargetUser.Id);
            UserModerationEntry moderationEntry    = new UserModerationEntry(context.Guild.Id, ModerationType.Warning, null, context.GuildUser, args.Warning);
            await userModerationLog.AddModerationEntry(moderationEntry);

            await context.Channel.SendEmbedAsync($"Warned {args.TargetUser.Mention} with `{args.Warning}`");
        }
Ejemplo n.º 5
0
        protected override async Task ExecuteGuild(IGuildCommandContext context, object parsedArgs)
        {
            ArgumentContainer args    = parsedArgs as ArgumentContainer;
            UserModerationLog userLog = GuildModerationLog.GetOrCreateUserModerationLog(context.Guild.Id, args.TargetUser.Id, out _);

            try
            {
                UserModerationEntry entry = new UserModerationEntry(context.Guild.Id, ModerationType.UnMuted, null, context.GuildUser, args.Reason);
                await userLog.RemoveMute(args.TargetUser, entry);
            }
            catch (Exception e)
            {
                await context.Channel.SendEmbedAsync("Failed to manage roles: " + e.Message, true);
            }

            await context.Channel.SendEmbedAsync($"Unmuted {args.TargetUser.Mention} ({args.TargetUser.Id}) with reason `{args.Reason}`");
        }
Ejemplo n.º 6
0
        protected override async Task ExecuteGuild(IGuildCommandContext context, object argObj)
        {
            ArgumentContainer args = argObj as ArgumentContainer;

            IDMChannel dmchannel = await args.TargetUser.GetOrCreateDMChannelAsync();

            await dmchannel.SendMessageAsync($"You have been banned on {context.Guild} for `{args.Reason}`! {(args.BanEnds == DateTimeOffset.MaxValue ? "This is permanent." : $"You will be automatically unbanned in {args.Duration.ToHumanTimeString()} ({args.BanEnds.ToString("u")})")}");

            await args.TargetUser.BanAsync(reason : args.Reason);

            GuildModerationLog  guildModerationLog = GuildModerationLog.GetOrCreateGuildModerationLog(context.Guild.Id);
            UserModerationLog   userModerationLog  = guildModerationLog.GetOrCreateUserModerationLog(args.TargetUser.Id);
            UserModerationEntry moderationEntry    = new UserModerationEntry(context.Guild.Id, ModerationType.Banned, null, context.GuildUser, args.Reason, $"Duration: `{(args.BanEnds == DateTimeOffset.MaxValue ? "perma" : args.Duration.ToHumanTimeString())}`");
            await userModerationLog.AddBan(moderationEntry, args.BanEnds);

            await context.Channel.SendEmbedAsync($"Banned {args.TargetUser.Mention} for `{args.Reason}`");
        }
Ejemplo n.º 7
0
        protected override async Task ExecuteGuild(IGuildCommandContext context, object argObj)
        {
            ArgumentContainer args = argObj as ArgumentContainer;

            try
            {
                await args.ToBeKicked.KickAsync(args.Reason);

                GuildModerationLog  guildModerationLog = GuildModerationLog.GetOrCreateGuildModerationLog(context.Guild.Id);
                UserModerationLog   userModerationLog  = guildModerationLog.GetOrCreateUserModerationLog(args.ToBeKicked.Id);
                UserModerationEntry moderationEntry    = new UserModerationEntry(context.Guild.Id, ModerationType.Kicked, null, context.GuildUser, args.Reason);
                await userModerationLog.AddModerationEntry(moderationEntry);

                await context.Channel.SendEmbedAsync($"Kicked {args.ToBeKicked} for reason: `{args.Reason}`");
            }
            catch (HttpException e)
            {
                await context.Channel.SendEmbedAsync($"Failed to kick due to \"{e.Reason}\"!", true);
            }
        }
Ejemplo n.º 8
0
        protected override async Task ExecuteGuild(IGuildCommandContext context, object parsedArgs)
        {
            ArgumentContainer args = parsedArgs as ArgumentContainer;

            // Generate UserModerationEntry

            UserModerationEntry entry;

            if (args.MuteUntil == DateTimeOffset.MaxValue)
            {
                entry = new UserModerationEntry(context.Guild.Id, ModerationType.Muted, DateTimeOffset.UtcNow, context.GuildUser, args.Reason, "Duration: perma");
            }
            else
            {
                entry = new UserModerationEntry(context.Guild.Id, ModerationType.Muted, DateTimeOffset.UtcNow, context.GuildUser, args.Reason, "Duration: " + args.Duration.ToHumanTimeString());
            }
            UserModerationLog userLog = GuildModerationLog.GetOrCreateUserModerationLog(context.Guild.Id, args.TargetUser.Id, out _);

            await userLog.AddMute(args.TargetUser, args.MuteUntil, entry);

            // Report success

            await context.Channel.SendEmbedAsync($"Muted {args.TargetUser.Mention} ({args.TargetUser.Id}) for `{args.Reason}`");
        }
Ejemplo n.º 9
0
        protected override async Task ExecuteGuild(IGuildCommandContext context, object argObj)
        {
            ArgumentContainer args = argObj as ArgumentContainer;

            GuildModerationLog guildModerationLog = GuildModerationLog.GetOrCreateGuildModerationLog(context.Guild.Id);
            UserModerationLog  userModerationLog  = guildModerationLog.GetOrCreateUserModerationLog(args.UserId);

            AutoExpandingMessage embed;

            if (args.TargetUser == null)
            {
                embed = new AutoExpandingMessage()
                {
                    Color  = BotCore.EmbedColor,
                    Author = new EmbedAuthorBuilder()
                    {
                        Name = args.UserId.ToString()
                    },
                };
            }
            else
            {
                embed = new AutoExpandingMessage()
                {
                    Color  = BotCore.EmbedColor,
                    Author = new EmbedAuthorBuilder()
                    {
                        Name    = args.TargetUser.ToString(),
                        IconUrl = args.TargetUser.GetDefaultAvatarUrl(),
                        Url     = args.TargetUser.GetDefaultAvatarUrl()
                    },
                };
            }

            string description = string.Empty;

            if (args.TargetUser != null)
            {
                description += $"**User Information:** Mention: {args.TargetUser.Mention}, ID: `{args.UserId}`\n";
            }
            else
            {
                description += $"**User Information:** ID: `{args.UserId}`\n";
            }

            string userStatus;

            if (userModerationLog.IsBanned)
            {
                if (userModerationLog.BannedUntil == DateTimeOffset.MaxValue)
                {
                    userStatus = "**Banned** permanently\n";
                }
                else
                {
                    userStatus = $"**Banned** until `{userModerationLog.BannedUntil.Value.ToString("u")} - ({userModerationLog.BanTimeRemaining.ToHumanTimeString()} remaining)`\n";
                }
            }
            else
            {
                if (userModerationLog.IsMuted)
                {
                    if (userModerationLog.MutedUntil == DateTimeOffset.MaxValue)
                    {
                        userStatus = "**Muted** until further notice\n";
                    }
                    else
                    {
                        userStatus = $"**Muted** until `{userModerationLog.MutedUntil.Value.ToString("u")} - ({userModerationLog.MuteTimeRemaining.ToHumanTimeString()} remaining)`\n";
                    }
                }
                else
                {
                    userStatus = $"No Infraction\n";
                }
            }
            description += $"**Status:** {userStatus}\n\n**Moderation Entries**: {userModerationLog.ModerationEntries.Count}";

            embed.Description = description;

            foreach (UserModerationEntry entry in userModerationLog.ModerationEntries)
            {
                embed.AddLine(entry);
            }

            await embed.Send(context.Channel);
        }