Added the ability for sticker to check for stickers previously posted in a channel

This commit is contained in:
Essem 2021-10-05 16:48:26 -05:00
parent d54e4e0117
commit d42c67cde2
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C
2 changed files with 35 additions and 30 deletions

View file

@ -1,23 +1,24 @@
import Command from "../../classes/command.js";
import imagedetect from "../../utils/imagedetect.js";
class StickerCommand extends Command {
async run() {
if (!this.message.stickerItems) return "You need to provide a sticker!";
const sticker = this.message.stickerItems[0];
if (sticker.format_type === 1) { // PNG
return `https://cdn.discordapp.com/stickers/${sticker.id}.png`;
} else if (sticker.format_type === 2) { // APNG
const result = await imagedetect(this.client, this.message, false, false, true);
if (!result) return "You need to provide a sticker!";
if (result.format_type === 1) { // PNG
return `https://cdn.discordapp.com/stickers/${result.id}.png`;
} else if (result.format_type === 2) { // APNG
return {
embed: {
color: 16711680,
description: `[This sticker is an APNG; however, since Discord doesn't allow displaying APNGs outside of stickers, you'll have to save it or open it in your browser to view it.](https://cdn.discordapp.com/stickers/${sticker.id}.png)`,
description: `[This sticker is an APNG; however, since Discord doesn't allow displaying APNGs outside of stickers, you'll have to save it or open it in your browser to view it.](https://cdn.discordapp.com/stickers/${result.id}.png)`,
image: {
url: `https://cdn.discordapp.com/stickers/${sticker.id}.png`
url: `https://cdn.discordapp.com/stickers/${result.id}.png`
}
}
};
} else if (sticker.format_type === 3) { // Lottie
return `I can't display this sticker because it uses the Lottie animation format; however, I can give you the raw JSON link to it: https://cdn.discordapp.com/stickers/${sticker.id}.json`;
} else if (result.format_type === 3) { // Lottie
return `I can't display this sticker because it uses the Lottie animation format; however, I can give you the raw JSON link to it: https://cdn.discordapp.com/stickers/${result.id}.json`;
} else {
return "I don't recognize that sticker format!";
}