From 6003367a6b170742a04255978afcdc6fd9f64da1 Mon Sep 17 00:00:00 2001 From: Alyxia Sother Date: Mon, 17 May 2021 19:49:10 +0200 Subject: [PATCH] Apply suggestions from code review Co-authored-by: WatDuhHekBro --- src/commands/fun/pat.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/commands/fun/pat.ts b/src/commands/fun/pat.ts index be8070d..f60b41b 100644 --- a/src/commands/fun/pat.ts +++ b/src/commands/fun/pat.ts @@ -1,5 +1,5 @@ import {MessageAttachment, User} from "discord.js"; -import {NamedCommand, Command} from "onion-lasers"; +import {NamedCommand, Command, RestCommand, getUserByNickname} from "onion-lasers"; import petPetGif from "pet-pet-gif"; export default new NamedCommand({ @@ -26,5 +26,18 @@ export default new NamedCommand({ const file = new MessageAttachment(gif, "pat.gif"); send(file); } + }), + any: new RestCommand({ + description: "User to generate a GIF of.", + async run({send, combined, guild}) { + const user = await getUserByNickname(combined, guild); + + if (typeof user === "string") send(user); + else { + const gif = await petPetGif(user.displayAvatarURL({format: "png"})); + const file = new MessageAttachment(gif, "pat.gif"); + send(file); + } + } }) });