public async Task <PunishmentAction?> Warn(IGuild guild, ulong userId, string modName, string reason)
        {
            if (string.IsNullOrWhiteSpace(reason))
            {
                reason = "-";
            }

            var guildId = guild.Id;

            var warn = new Warning {
                UserId    = userId,
                GuildId   = guildId,
                Forgiven  = false,
                Reason    = reason,
                Moderator = modName,
            };

            var warnings = 1;
            List <WarningPunishment> ps;

            using (var uow = _db.UnitOfWork)
            {
                ps = uow.GuildConfigs.For(guildId, set => set.Include(x => x.WarnPunishments))
                     .WarnPunishments;

                warnings += uow.Warnings
                            .For(guildId, userId)
                            .Count(w => !w.Forgiven && w.UserId == userId);

                uow.Warnings.Add(warn);

                uow.Complete();
            }

            var p = ps.FirstOrDefault(x => x.Count == warnings);

            if (p == null)
            {
                return(null);
            }
            var user = await guild.GetUserAsync(userId);

            if (user == null)
            {
                return(null);
            }
            switch (p.Punishment)
            {
            case PunishmentAction.Mute:
                if (p.Time == 0)
                {
                    await _mute.MuteUser(user).ConfigureAwait(false);
                }
                else
                {
                    await _mute.TimedMute(user, TimeSpan.FromMinutes(p.Time)).ConfigureAwait(false);
                }
                break;

            case PunishmentAction.Kick:
                await user.KickAsync().ConfigureAwait(false);

                break;

            case PunishmentAction.Ban:
                await guild.AddBanAsync(user).ConfigureAwait(false);

                break;

            case PunishmentAction.Softban:
                await guild.AddBanAsync(user, 7).ConfigureAwait(false);

                try
                {
                    await guild.RemoveBanAsync(user).ConfigureAwait(false);
                }
                catch
                {
                    await guild.RemoveBanAsync(user).ConfigureAwait(false);
                }
                break;

            default:
                break;
            }
            return(p.Punishment);
        }
        private async Task PunishUsers(PunishmentAction action, ProtectionType pt, int muteTime, params IGuildUser[] gus)
        {
            _log.Info($"[{pt}] - Punishing [{gus.Length}] users with [{action}] in {gus[0].Guild.Name} guild");
            foreach (var gu in gus)
            {
                switch (action)
                {
                case PunishmentAction.Mute:
                    try
                    {
                        if (muteTime <= 0)
                        {
                            await _mute.MuteUser(gu).ConfigureAwait(false);
                        }
                        else
                        {
                            await _mute.TimedMute(gu, TimeSpan.FromSeconds(muteTime)).ConfigureAwait(false);
                        }
                    }
                    catch (Exception ex) { _log.Warn(ex, "I can't apply punishement"); }
                    break;

                case PunishmentAction.Kick:
                    try
                    {
                        await gu.KickAsync().ConfigureAwait(false);
                    }
                    catch (Exception ex) { _log.Warn(ex, "I can't apply punishement"); }
                    break;

                case PunishmentAction.Softban:
                    try
                    {
                        await gu.Guild.AddBanAsync(gu, 7).ConfigureAwait(false);

                        try
                        {
                            await gu.Guild.RemoveBanAsync(gu).ConfigureAwait(false);
                        }
                        catch
                        {
                            await gu.Guild.RemoveBanAsync(gu).ConfigureAwait(false);

                            // try it twice, really don't want to ban user if
                            // only kick has been specified as the punishement
                        }
                    }
                    catch (Exception ex) { _log.Warn(ex, "I can't apply punishment"); }
                    break;

                case PunishmentAction.Ban:
                    try
                    {
                        await gu.Guild.AddBanAsync(gu, 7).ConfigureAwait(false);
                    }
                    catch (Exception ex) { _log.Warn(ex, "I can't apply punishment"); }
                    break;
                }
            }
            await OnAntiProtectionTriggered(action, pt, gus).ConfigureAwait(false);
        }