From 96ba51102652d937ff3fa158460a4585ac566274 Mon Sep 17 00:00:00 2001 From: Ske Date: Sun, 20 Dec 2020 11:52:35 +0100 Subject: [PATCH] Secret soulscreams, because I'm bored --- PluralKit.Bot/Commands/CommandTree.cs | 2 ++ PluralKit.Bot/Commands/Member.cs | 34 ++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/PluralKit.Bot/Commands/CommandTree.cs b/PluralKit.Bot/Commands/CommandTree.cs index 3126dbbf..60f2426f 100644 --- a/PluralKit.Bot/Commands/CommandTree.cs +++ b/PluralKit.Bot/Commands/CommandTree.cs @@ -364,6 +364,8 @@ namespace PluralKit.Bot await ctx.Execute(MemberPrivacy, m => m.Privacy(ctx, target, PrivacyLevel.Private)); else if (ctx.Match("public", "shown", "show")) await ctx.Execute(MemberPrivacy, m => m.Privacy(ctx, target, PrivacyLevel.Public)); + else if (ctx.Match("soulscream")) + await ctx.Execute(MemberInfo, m => m.Soulscream(ctx, target)); else if (!ctx.HasNext()) // Bare command await ctx.Execute(MemberInfo, m => m.ViewMember(ctx, target)); else diff --git a/PluralKit.Bot/Commands/Member.cs b/PluralKit.Bot/Commands/Member.cs index 9998e1f5..001d46f7 100644 --- a/PluralKit.Bot/Commands/Member.cs +++ b/PluralKit.Bot/Commands/Member.cs @@ -1,9 +1,14 @@ -using System.Linq; using System.Threading.Tasks; -using System.Collections.Generic; +using System.Net; +using System.Net.Http; +using System.Web; using Dapper; +using DSharpPlus.Entities; + +using Newtonsoft.Json.Linq; + using PluralKit.Core; namespace PluralKit.Bot @@ -13,12 +18,14 @@ namespace PluralKit.Bot private readonly IDatabase _db; private readonly ModelRepository _repo; private readonly EmbedService _embeds; + private readonly HttpClient _client; - public Member(EmbedService embeds, IDatabase db, ModelRepository repo) + public Member(EmbedService embeds, IDatabase db, ModelRepository repo, HttpClient client) { _embeds = embeds; _db = db; _repo = repo; + _client = client; } public async Task NewMember(Context ctx) { @@ -66,5 +73,26 @@ namespace PluralKit.Bot var system = await _db.Execute(c => _repo.GetSystem(c, target.System)); await ctx.Reply(embed: await _embeds.CreateMemberEmbed(system, target, ctx.Guild, ctx.LookupContextFor(system))); } + + public async Task Soulscream(Context ctx, PKMember target) + { + // this is for a meme, please don't take this code seriously. :) + + var name = target.NameFor(ctx.LookupContextFor(target)); + var encoded = HttpUtility.UrlEncode(name); + + var resp = await _client.GetAsync($"https://onomancer.sibr.dev/api/generateStats2?name={encoded}"); + if (resp.StatusCode != HttpStatusCode.OK) + // lol + return; + + var data = JObject.Parse(await resp.Content.ReadAsStringAsync()); + var scream = data["soulscream"]!.Value(); + + var eb = new DiscordEmbedBuilder() + .WithColor(DiscordColor.Red) + .WithDescription($"[*{scream}*](https://onomancer.sibr.dev/reflect?name={encoded})"); + await ctx.Reply(embed: eb.Build()); + } } }