TravBot-v3/src/commands/fun/pat.ts

44 lines
1.7 KiB
TypeScript
Raw Permalink Normal View History

2021-05-17 17:24:54 +00:00
import {MessageAttachment, User} from "discord.js";
import {NamedCommand, Command, RestCommand, getUserByNickname} from "onion-lasers";
2021-05-17 17:24:54 +00:00
import petPetGif from "pet-pet-gif";
export default new NamedCommand({
description: "Generates a pat GIF of the provided attachment image OR the avatar of the mentioned user.",
usage: "(@user)",
async run({message, send, author}) {
if (message.attachments.size !== 0) {
const attachment = message.attachments.first()!;
const gif = await petPetGif(attachment.url);
const file = new MessageAttachment(gif, "pat.gif");
2021-12-12 23:39:32 +00:00
send({files: [file]});
2021-05-17 17:24:54 +00:00
} else {
const gif = await petPetGif(author.displayAvatarURL({format: "png"}));
const file = new MessageAttachment(gif, "pat.gif");
2021-12-12 23:39:32 +00:00
send({files: [file]});
2021-05-17 17:24:54 +00:00
}
},
id: "user",
user: new Command({
description: "User to generate a GIF of.",
async run({send, args}) {
const user: User = args[0];
const gif = await petPetGif(user.displayAvatarURL({format: "png"}));
const file = new MessageAttachment(gif, "pat.gif");
2021-12-12 23:39:32 +00:00
send({files: [file]});
2021-05-17 17:24:54 +00:00
}
}),
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");
2021-12-12 23:39:32 +00:00
send({files: [file]});
}
}
2021-05-17 17:24:54 +00:00
})
});