Added pat command

This commit is contained in:
Alyxia Sother 2021-05-17 17:24:54 +00:00
parent f643f61f29
commit 58858c5d09
No known key found for this signature in database
GPG key ID: 355968D14144B739
4 changed files with 70 additions and 0 deletions

35
package-lock.json generated
View file

@ -21,6 +21,7 @@
"moment": "^2.29.1",
"ms": "^2.1.3",
"onion-lasers": "^1.1.2",
"pet-pet-gif": "^1.0.8",
"relevant-urban": "^2.0.0",
"translate-google": "^1.4.3",
"weather-js": "^2.0.0"
@ -3015,6 +3016,14 @@
"assert-plus": "^1.0.0"
}
},
"node_modules/gifencoder": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/gifencoder/-/gifencoder-2.0.1.tgz",
"integrity": "sha512-x19DcyWY10SkshBpokqFOo/HBht9GB75evRYvaLMbez9p+yB/o+kt0fK9AwW59nFiAMs2UUQsjv1lX/hvu9Ong==",
"dependencies": {
"canvas": "^2.2.0"
}
},
"node_modules/glob": {
"version": "7.1.6",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
@ -5334,6 +5343,15 @@
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
"integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns="
},
"node_modules/pet-pet-gif": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/pet-pet-gif/-/pet-pet-gif-1.0.8.tgz",
"integrity": "sha512-xmQM2DhlSPb1Wo4L5Z6Er4QdzVUjblyUg6LgtvGGtXnwnuhOZBQ0JhNyM+1CL6zxJAG5CQFLhIXxxQa28YpBdg==",
"dependencies": {
"gifencoder": "^2.0.1",
"lodash": "^4.17.21"
}
},
"node_modules/picomatch": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.3.tgz",
@ -10179,6 +10197,14 @@
"assert-plus": "^1.0.0"
}
},
"gifencoder": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/gifencoder/-/gifencoder-2.0.1.tgz",
"integrity": "sha512-x19DcyWY10SkshBpokqFOo/HBht9GB75evRYvaLMbez9p+yB/o+kt0fK9AwW59nFiAMs2UUQsjv1lX/hvu9Ong==",
"requires": {
"canvas": "^2.2.0"
}
},
"glob": {
"version": "7.1.6",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
@ -11988,6 +12014,15 @@
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
"integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns="
},
"pet-pet-gif": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/pet-pet-gif/-/pet-pet-gif-1.0.8.tgz",
"integrity": "sha512-xmQM2DhlSPb1Wo4L5Z6Er4QdzVUjblyUg6LgtvGGtXnwnuhOZBQ0JhNyM+1CL6zxJAG5CQFLhIXxxQa28YpBdg==",
"requires": {
"gifencoder": "^2.0.1",
"lodash": "^4.17.21"
}
},
"picomatch": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.3.tgz",

View file

@ -24,6 +24,7 @@
"moment": "^2.29.1",
"ms": "^2.1.3",
"onion-lasers": "^1.1.2",
"pet-pet-gif": "^1.0.8",
"relevant-urban": "^2.0.0",
"translate-google": "^1.4.3",
"weather-js": "^2.0.0"

30
src/commands/fun/pat.ts Normal file
View file

@ -0,0 +1,30 @@
import {MessageAttachment, User} from "discord.js";
import {NamedCommand, Command} from "onion-lasers";
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");
send(file);
} else {
const gif = await petPetGif(author.displayAvatarURL({format: "png"}));
const file = new MessageAttachment(gif, "pat.gif");
send(file);
}
},
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");
send(file);
}
})
});

4
src/defs/petpet.d.ts vendored Normal file
View file

@ -0,0 +1,4 @@
declare module "pet-pet-gif" {
function petPetGif(image: string): Promise<Buffer>;
export = petPetGif;
}