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: {
|
|
|
|
user: ct.resolvedUserLoose(),
|
|
|
|
},
|
|
|
|
|
|
|
|
async run({ message: msg, args, pluginData }) {
|
|
|
|
const user = args.user || msg.author;
|
|
|
|
if (!(user instanceof UnknownUser)) {
|
|
|
|
const extention = user.avatarURL.slice(user.avatarURL.lastIndexOf("."), user.avatarURL.lastIndexOf("?"));
|
|
|
|
const avatarUrl = user.avatarURL.slice(0, user.avatarURL.lastIndexOf("."));
|
|
|
|
const embed: EmbedOptions = {
|
|
|
|
image: { url: avatarUrl + `${extention}?size=2048` },
|
|
|
|
};
|
|
|
|
embed.title = `Avatar of ${user.username}#${user.discriminator}:`;
|
|
|
|
msg.channel.createMessage({ embed });
|
|
|
|
} else {
|
|
|
|
sendErrorMessage(pluginData, msg.channel, "Invalid user ID");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|