예제 #1
0
        public async Task Mute(IGuildUser userToMute, [Remainder] string reason = null)
        {
            var mutedRole = Context.Guild.GetRole(Context.DbGuild.MutedRoleId);

            if (mutedRole == null)
            {
                ReplyError($"You may not mute users if the muted role is not valid.\nPlease use the " +
                           $"`{Context.Prefix}SetMutedRole` command to change that.");
            }
            else if (_moderationService.GetPermLevel(Context, userToMute) > 0)
            {
                ReplyError("You cannot mute another mod.");
            }

            await userToMute.AddRoleAsync(mutedRole);

            await _muteRepo.InsertMuteAsync(userToMute, TimeSpan.FromDays(365));

            await SendAsync($"{Context.User.Boldify()} has successfully muted {userToMute.Boldify()}.");

            await _moderationService.InformSubjectAsync(Context.User, "Mute", userToMute, reason);

            await _moderationService.ModLogAsync(Context, "Mute", new Color(255, 114, 14), reason, userToMute, null);
        }
예제 #2
0
        public async Task HandleWarningAsync(IGuildUser user, Context context)
        {
            var dbUser = await _userRepository.GetUserAsync(user.Id, user.GuildId);

            if (dbUser.Warnings.Count >= context.DbGuild.MaxmimumWarningsBeforeAction)
            {
                switch (context.DbGuild.WarnPunishment)
                {
                case "mute":
                    var mutedRole = context.Guild.GetRole(context.DbGuild.MutedRoleId);

                    if (mutedRole == null)
                    {
                        await _text.ReplyErrorAsync(context.User, context.Channel, $"there is no muted role set for this server. Please use the `{Configuration.Prefix}SetMutedRole` command to remedy this error.");

                        return;
                    }

                    await user.AddRoleAsync(mutedRole);

                    await _muteRepository.InsertMuteAsync(user, TimeSpan.FromHours(context.DbGuild.WarnMuteLength));

                    await ModLogAsync(context.DbGuild, context.Guild, "Mute", Configuration.MuteColor, "Exceeded maximum warnings before automatic action.", (IGuildUser)context.User, user);

                    break;

                case "kick":
                    await user.KickAsync("Exceeded maximum warnings before automatic action.");

                    await ModLogAsync(context.DbGuild, context.Guild, "Kick", Configuration.KickColor, "Exceeded maximum warnings before automatic action.", (IGuildUser)context.User, user);

                    break;

                case "ban":
                    await user.BanAsync(reason : "Exceeded maximum warnings before automatic action.");

                    await ModLogAsync(context.DbGuild, context.Guild, "Ban", Configuration.BanColor, "Exceeded maximum warnings before automatic action.", (IGuildUser)context.User, user);

                    break;

                default:
                    return;
                }
            }
        }