3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

simplified avatar cmd

This commit is contained in:
almeidx 2021-07-29 01:22:37 +01:00
parent 0f5162ee21
commit 80f2dacb7f
No known key found for this signature in database
GPG key ID: 8558FBFF849BD664

View file

@ -16,15 +16,12 @@ export const AvatarCmd = utilityCmd({
async run({ message: msg, args, pluginData }) {
const user = args.user || msg.author;
if (!(user instanceof UnknownUser)) {
const avatar = user.displayAvatarURL();
let extension = avatar.slice(avatar.lastIndexOf("."), avatar.lastIndexOf("?"));
// Some pngs can have the .jpg extention for some reason, so we always use .png for static images
extension = extension === ".gif" ? extension : ".png";
const avatarUrl = avatar.slice(0, avatar.lastIndexOf("."));
const embed: MessageEmbedOptions = {
image: { url: avatarUrl + `${extension}?size=2048` },
image: {
url: user.displayAvatarURL({ dynamic: true, format: "png", size: 2048 }),
},
title: `Avatar of ${user.tag}:`,
};
embed.title = `Avatar of ${user.tag}:`;
msg.channel.send({ embeds: [embed] });
} else {
sendErrorMessage(pluginData, msg.channel, "Invalid user ID");