public async Task WarnHistory(CommandContext ctx, [Description("User to list his warns")] DiscordUser target) { await ctx.Channel.TriggerTypingAsync(); using (var botContext = new BotContext()) { var kuvuGuild = await ctx.Guild.GetKuvuGuild(botContext); var kuvuUser = await target.GetKuvuUser(kuvuGuild, botContext); if (kuvuUser.Warns.Count > 0) { await new ModernEmbedBuilder { AuthorIcon = target.AvatarUrl, Title = $"{target.Username}'s warns", Fields = new List <DuckField> { ($"{kuvuUser.Warns.Count} warns, {kuvuUser.Warns.Select(w => w.Weight).Sum()} total weight", kuvuUser.Warns.Select(w => $"[{w.Date.ToString("g", CultureInfo.CreateSpecificCulture("pl-PL"))}] Warning `{ctx.Client.GetUserAsync(w.Warning).Result.Name()}` Weight: `{w.Weight}` Reason: `{w.Reason}`").Join("\n")) } }.AddGeneratedForFooter(ctx).Send(ctx.Message.Channel);
public async Task Warn(CommandContext ctx, [Description("User to warn")] DiscordUser target, [Description("Weight of warn")] int weight, [Description("Reason")][RemainingText] string reason) { reason.RequireRemainingText(); await ctx.Channel.TriggerTypingAsync(); var botContext = new BotContext(); var kuvuGuild = await ctx.Guild.GetKuvuGuild(botContext); var kuvuUser = await target.GetKuvuUser(kuvuGuild, botContext); var warn = new KuvuWarn { Date = DateTime.Now, User = kuvuUser, Warning = ctx.User.Id, Weight = weight, Reason = reason, }; await botContext.Warns.AddAsync(warn); await botContext.SaveChangesAsync(); await ctx.RespondAsync($"Warned {target.Mention} for `{warn.Reason}` (`{warn.Weight}`)"); }