diff options
author | Vendicated <vendicated@riseup.net> | 2022-10-12 05:51:09 +0200 |
---|---|---|
committer | Vendicated <vendicated@riseup.net> | 2022-10-12 05:55:44 +0200 |
commit | 8dff79d3f7997c40d6e0c553f9c13681270bb173 (patch) | |
tree | b87a676a21f1a1f58e6b5a454805a2a086298ee5 | |
parent | 9b7ebe4680465361542f2cf956bd2f1ef47eca8b (diff) | |
download | Vencord-8dff79d3f7997c40d6e0c553f9c13681270bb173.tar.gz Vencord-8dff79d3f7997c40d6e0c553f9c13681270bb173.tar.bz2 Vencord-8dff79d3f7997c40d6e0c553f9c13681270bb173.zip |
petpet: fix guild pfps
-rw-r--r-- | src/plugins/petpet.ts | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/plugins/petpet.ts b/src/plugins/petpet.ts index fb8c5de..6b0fd4f 100644 --- a/src/plugins/petpet.ts +++ b/src/plugins/petpet.ts @@ -42,7 +42,7 @@ function loadImage(source: File | string) { }); } -async function resolveImage(options: Argument[], ctx: CommandContext): Promise<File | string | null> { +async function resolveImage(options: Argument[], ctx: CommandContext, noServerPfp: boolean): Promise<File | string | null> { for (const opt of options) { switch (opt.name) { case "image": @@ -57,7 +57,7 @@ async function resolveImage(options: Argument[], ctx: CommandContext): Promise<F case "user": try { const user = await fetchUser(opt.value); - return user.getAvatarURL(ctx.guild, 2048).replace(/\?size=\d+$/, "?size=2048"); + return user.getAvatarURL(noServerPfp ? void 0 : ctx.guild?.id, 2048).replace(/\?size=\d+$/, "?size=2048"); } catch (err) { console.error("[petpet] Failed to fetch user\n", err); throw "Failed to fetch user. Check the console for more info."; @@ -102,14 +102,20 @@ export default definePlugin({ name: "user", description: "User whose avatar to use as image", type: ApplicationCommandOptionType.USER + }, + { + name: "no-server-pfp", + description: "Use the normal avatar instead of the server specific one when using the 'user' option", + type: ApplicationCommandOptionType.BOOLEAN } ], execute: suppressErrors("petpetExecute", async (opts, cmdCtx) => { const { GIFEncoder, quantize, applyPalette } = await getGifEncoder(); const frames = await getFrames(); + const noServerPfp = findOption(opts, "no-server-pfp", false); try { - var url = await resolveImage(opts, cmdCtx); + var url = await resolveImage(opts, cmdCtx, noServerPfp); if (!url) throw "No Image specified!"; } catch (err) { // Todo make this send a clyde message once that PR is done |