63 lines
1.7 KiB
JavaScript
63 lines
1.7 KiB
JavaScript
|
const { Command } = require('../../../../interfaces/');
|
||
|
|
||
|
class AvatarCommand extends Command {
|
||
|
|
||
|
constructor(client) {
|
||
|
|
||
|
super(client, {
|
||
|
name: 'avatar',
|
||
|
module: 'utility',
|
||
|
aliases: [
|
||
|
'pfp'
|
||
|
],
|
||
|
arguments: [
|
||
|
{
|
||
|
name: 'size',
|
||
|
type: 'INTEGER',
|
||
|
types: ['VERBAL', 'FLAG'],
|
||
|
options: [ 16, 32, 64, 128, 256, 512, 1024, 2048 ],
|
||
|
default: 512,
|
||
|
required: true
|
||
|
},
|
||
|
{
|
||
|
name: 'format',
|
||
|
type: 'STRING',
|
||
|
types: ['VERBAL', 'FLAG'],
|
||
|
options: [ 'webp', 'png', 'jpeg', 'jpg', 'gif' ],
|
||
|
default: 'webp',
|
||
|
required: true
|
||
|
}
|
||
|
]
|
||
|
});
|
||
|
|
||
|
this.client = client;
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
async execute(message, { params, args }) {
|
||
|
|
||
|
let user = params.length ? await this.client.resolver.resolveUser(params[0]) : message.author;
|
||
|
if (!user) user = message.author;
|
||
|
let avatar = null;
|
||
|
try {
|
||
|
avatar = user.displayAvatarURL({ format: args.format?.value || 'webp', size: args.size?.value || 512, dynamic: true });
|
||
|
} catch(error) {
|
||
|
message.respond(message.format('C_AVATAR_FORMATERROR'), { emoji: 'failure' });
|
||
|
return undefined;
|
||
|
}
|
||
|
|
||
|
return await message.embed({
|
||
|
author: {
|
||
|
name: user.tag
|
||
|
},
|
||
|
image: {
|
||
|
url: avatar
|
||
|
}
|
||
|
});
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
module.exports = AvatarCommand;
|