Пример #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)}");
        }
Пример #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}`");
        }
Пример #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}`");
        }
Пример #4
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}`");
        }
Пример #5
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}`");
        }
Пример #6
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);
            }
        }
Пример #7
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}`");
        }
Пример #8
0
        private static Task GuildModerationLog_OnUserUnMuted(GuildModerationLog guildLog, UserModerationLog userLog, UserModerationEntry entry)
        {
            SocketGuild guild = BotCore.Client.GetGuild(guildLog.GuildId);

            if ((guild != null) && TryGetLogChannel(guild, ModerationType.Note, out SocketTextChannel logChannel, out EmbedBuilder embed))
            {
                embed.Title       = $"Unmuted User {getUserString(userLog.UserId, guild)}";
                embed.Description =
                    $"Actor: {getUserString(entry.ActorId, guild)}\n" +
                    $"Reason: {entry.Reason}";
                return(logChannel.SendEmbedAsync(embed));
            }
            return(Task.CompletedTask);
        }