2020-07-06 02:47:39 +03:00
|
|
|
import { utilityCmd } from "../types";
|
|
|
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
2020-07-06 02:57:21 +03:00
|
|
|
import { UnknownUser } from "../../../utils";
|
2020-07-06 02:47:39 +03:00
|
|
|
import { sendErrorMessage } from "../../../pluginUtils";
|
2020-07-06 02:57:21 +03:00
|
|
|
import { EmbedOptions } from "eris";
|
2020-07-06 02:47:39 +03:00
|
|
|
|
|
|
|
export const AvatarCmd = utilityCmd({
|
|
|
|
trigger: "avatar",
|
|
|
|
description: "Retrieves a user's profile picture",
|
|
|
|
permission: "can_avatar",
|
|
|
|
|
|
|
|
signature: {
|
2020-08-19 00:53:59 +03:00
|
|
|
user: ct.resolvedUserLoose({ required: false }),
|
2020-07-06 02:47:39 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
async run({ message: msg, args, pluginData }) {
|
|
|
|
const user = args.user || msg.author;
|
|
|
|
if (!(user instanceof UnknownUser)) {
|
2020-08-05 02:42:40 +03:00
|
|
|
let extension = user.avatarURL.slice(user.avatarURL.lastIndexOf("."), user.avatarURL.lastIndexOf("?"));
|
|
|
|
// Some pngs can have the .jpg extention for some reason, so we always use .png for static images
|
|
|
|
extension = extension === ".gif" ? extension : ".png";
|
2020-07-06 02:47:39 +03:00
|
|
|
const avatarUrl = user.avatarURL.slice(0, user.avatarURL.lastIndexOf("."));
|
|
|
|
const embed: EmbedOptions = {
|
2020-08-05 02:42:40 +03:00
|
|
|
image: { url: avatarUrl + `${extension}?size=2048` },
|
2020-07-06 02:47:39 +03:00
|
|
|
};
|
|
|
|
embed.title = `Avatar of ${user.username}#${user.discriminator}:`;
|
|
|
|
msg.channel.createMessage({ embed });
|
|
|
|
} else {
|
|
|
|
sendErrorMessage(pluginData, msg.channel, "Invalid user ID");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|