forked from Galactic/galactic-bot
flag to fetch user's banner with avatar command
This commit is contained in:
parent
c32ef40d0c
commit
d664e98909
@ -8,6 +8,9 @@ Use the member option to display their server avatar.
|
|||||||
[COMMAND_AVATAR_FORMATERROR]
|
[COMMAND_AVATAR_FORMATERROR]
|
||||||
Unable to find an avatar with those arguments, try a different size or format.
|
Unable to find an avatar with those arguments, try a different size or format.
|
||||||
|
|
||||||
|
[COMMAND_AVATAR_NOBANNER]
|
||||||
|
User doesn't have a banner.
|
||||||
|
|
||||||
[COMMAND_REMIND_CONFIRM]
|
[COMMAND_REMIND_CONFIRM]
|
||||||
Will remind you about '{reminder}' in {time}
|
Will remind you about '{reminder}' in {time}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ class AvatarCommand extends SlashCommand {
|
|||||||
name: 'size',
|
name: 'size',
|
||||||
description: 'The width/height value',
|
description: 'The width/height value',
|
||||||
// type: 'INTEGER',
|
// type: 'INTEGER',
|
||||||
choices: [16, 32, 64, 128, 256, 512, 1024, 2048].map((i) => {
|
choices: [16, 32, 64, 128, 256, 512, 1024, 2048, 4096].map((i) => {
|
||||||
return { name: `${i}`, value: `${i}` };
|
return { name: `${i}`, value: `${i}` };
|
||||||
}),
|
}),
|
||||||
flag: true
|
flag: true
|
||||||
@ -32,19 +32,29 @@ class AvatarCommand extends SlashCommand {
|
|||||||
description: 'Use this for the user\'s server avatar',
|
description: 'Use this for the user\'s server avatar',
|
||||||
type: 'MEMBER',
|
type: 'MEMBER',
|
||||||
flag: true
|
flag: true
|
||||||
|
}, {
|
||||||
|
name: 'banner',
|
||||||
|
type: 'BOOLEAN',
|
||||||
|
description: 'Fetch the user\'s banner',
|
||||||
|
flag: true, valueOptional: true, defaultValue: true
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(invoker, { format, size, user, member }) {
|
async execute(invoker, { format, size, user, member, banner }) {
|
||||||
|
|
||||||
const target = member?.value || user?.value || invoker.member || invoker.author;
|
const _target = member?.value || user?.value || invoker.member || invoker.author;
|
||||||
|
const target = await _target.fetch();
|
||||||
format = format?.value || 'webp';
|
format = format?.value || 'webp';
|
||||||
size = parseInt(size?.value || 256);
|
size = parseInt(size?.value || 256);
|
||||||
|
banner = banner?.value || false;
|
||||||
|
|
||||||
let avatar = null;
|
let imageUrl = null;
|
||||||
try {
|
try {
|
||||||
avatar = target.displayAvatarURL({ format, size, dynamic: true });
|
if (banner) {
|
||||||
|
imageUrl = target.bannerURL({ format, size, dynamic: true });
|
||||||
|
if(!target.banner) return { emoji: 'failure', index: 'COMMAND_AVATAR_NOBANNER' };
|
||||||
|
} else imageUrl = target.displayAvatarURL({ format, size, dynamic: true });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return { emoji: 'failure', index: 'COMMAND_AVATAR_FORMATERROR' };
|
return { emoji: 'failure', index: 'COMMAND_AVATAR_FORMATERROR' };
|
||||||
}
|
}
|
||||||
@ -52,8 +62,8 @@ class AvatarCommand extends SlashCommand {
|
|||||||
return {
|
return {
|
||||||
embed: {
|
embed: {
|
||||||
title: target.user?.tag || target.tag,
|
title: target.user?.tag || target.tag,
|
||||||
description: `[**Link**](${avatar})`,
|
description: `[**Link**](${imageUrl})`,
|
||||||
image: { url: avatar },
|
image: { url: imageUrl },
|
||||||
footer: { text: `• Format: .${format} | Size: ${size}` }
|
footer: { text: `• Format: .${format} | Size: ${size}` }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user