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
        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.º 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 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.º 5
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.º 6
0
 private CustomGuild(SocketGuild guild)
 {
     ModerationLog = GuildModerationLog.GetOrCreateGuildModerationLog(guild.Id);
 }
Ejemplo n.º 7
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);
        }