public async Task WarnPunish(int number, PunishmentAction punish, StoopidTime time = null) { // this should never happen. Addrole has its own method with higher priority if (punish == PunishmentAction.AddRole) { return; } var success = _service.WarnPunish(ctx.Guild.Id, number, punish, time); if (!success) { return; } if (time is null) { await ReplyConfirmLocalizedAsync("warn_punish_set", Format.Bold(punish.ToString()), Format.Bold(number.ToString())).ConfigureAwait(false); } else { await ReplyConfirmLocalizedAsync("warn_punish_set_timed", Format.Bold(punish.ToString()), Format.Bold(number.ToString()), Format.Bold(time.Input)).ConfigureAwait(false); } }
public async Task WarnPunish(int number, PunishmentAction punish, int time = 0) { if (punish != PunishmentAction.Mute && time != 0) { return; } if (number <= 0) { return; } using (var uow = DbHandler.UnitOfWork()) { var ps = uow.GuildConfigs.For(Context.Guild.Id, set => set.Include(x => x.WarnPunishments)).WarnPunishments; ps.RemoveAll(x => x.Count == number); ps.Add(new WarningPunishment() { Count = number, Punishment = punish, Time = time, }); uow.Complete(); } await ReplyConfirmLocalized("warn_punish_set", Format.Bold(punish.ToString()), Format.Bold(number.ToString())).ConfigureAwait(false); }
public async Task WarnPunish(int number, PunishmentAction punish, StoopidTime time = null) { if ((punish != PunishmentAction.Ban && punish != PunishmentAction.Mute) && time != null) { return; } if (number <= 0 || (time != null && time.Time > TimeSpan.FromDays(49))) { return; } using (var uow = _db.UnitOfWork) { var ps = uow.GuildConfigs.ForId(Context.Guild.Id, set => set.Include(x => x.WarnPunishments)).WarnPunishments; ps.RemoveAll(x => x.Count == number); ps.Add(new WarningPunishment() { Count = number, Punishment = punish, Time = (int?)(time?.Time.TotalMinutes) ?? 0, }); uow.Complete(); } await ReplyConfirmLocalized("warn_punish_set", Format.Bold(punish.ToString()), Format.Bold(number.ToString())).ConfigureAwait(false); }
public async Task WarnPunish(int number, PunishmentAction punish, StoopidTime time = null) { var success = _service.WarnPunish(Context.Guild.Id, number, punish, time); if (!success) { return; } await ReplyConfirmLocalizedAsync("warn_punish_set", Format.Bold(punish.ToString()), Format.Bold(number.ToString())).ConfigureAwait(false); }
public async Task WarnPunish(int number, PunishmentAction punish, int time = 0) { if (punish != PunishmentAction.Mute && time != 0) { return; } if (number <= 0) { return; } using (var uow = DbHandler.UnitOfWork()) { var ps = uow.GuildConfigs.For(Context.Guild.Id).WarnPunishments; var p = ps.FirstOrDefault(x => x.Count == number); if (p == null) { ps.Add(new WarningPunishment() { Count = number, Punishment = punish, Time = time, }); } else { p.Count = number; p.Punishment = punish; p.Time = time; uow._context.Update(p); } uow.Complete(); } await ReplyConfirmLocalized("warn_punish_set", Format.Bold(punish.ToString()), Format.Bold(number.ToString())).ConfigureAwait(false); }
public async Task WarnPunish(int numberOfWarns, PunishmentAction punish, int time = 0) { if ((punish == PunishmentAction.Mute || time == 0) && numberOfWarns > 0) { var warnPunishments = uow.GuildConfigs.For(Context.Guild.Id, set => set.Include(x => x.WarnPunishments)).WarnPunishments; warnPunishments.RemoveAll(x => x.Count == numberOfWarns); warnPunishments.Add(new WarningPunishment { Count = numberOfWarns, Punishment = punish, Time = time, }); uow.SaveChanges(false); await ConfirmLocalized("userpunish_warnpunish_warn_punish_set", Format.Bold(punish.ToString()), Format.Bold(numberOfWarns.ToString())).ConfigureAwait(false); } }