-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathavatar.js
64 lines (57 loc) · 2.28 KB
/
avatar.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import {
MessageFlags,
EmbedBuilder,
ContextMenuCommandBuilder,
ApplicationCommandType,
InteractionContextType,
ApplicationIntegrationType,
UserContextMenuCommandInteraction // eslint-disable-line no-unused-vars
} from 'discord.js';
import { link } from '@lib/discord.js';
// Set the command as a Global Application Command.
// Include the command when registering global application commands.
export const global = true;
// Create API-compatible JSON data for the command.
export const data = new ContextMenuCommandBuilder()
.setName('Get avatar')
.setNameLocalizations({
'es-ES': 'Obtener avatar'
})
.setType(ApplicationCommandType.User)
.setContexts(InteractionContextType.Guild)
.setIntegrationTypes(
ApplicationIntegrationType.UserInstall,
ApplicationIntegrationType.GuildInstall
);
/**
* Represents a user context menu interaction.
* @param {UserContextMenuCommandInteraction} interaction
*/
export async function execute(interaction) {
const options = { size: 4096 };
const userAvatar = interaction.targetUser.avatarURL(options);
const memberAvatar = interaction.targetMember?.avatarURL?.(options);
const userBanner = interaction.targetUser.bannerURL(options);
const memberBanner = interaction.targetMember?.bannerURL?.(options);
const userDisplayAvatar = interaction.targetUser.displayAvatarURL(options);
const memberDisplayAvatar = interaction.targetMember?.displayAvatarURL?.(options);
await interaction.reply({
embeds: [
new EmbedBuilder({
author: {
name: interaction.targetUser.tag,
url: userDisplayAvatar,
iconURL: userDisplayAvatar
},
description:
link('User avatar', userAvatar) +
(memberAvatar ? ` | [Member avatar](${memberAvatar})` : '') +
(userBanner ? ` | ${link('User banner', userBanner)}` : '') +
(memberBanner ? ` | ${link('Member banner', memberBanner)}` : ''),
image: { url: memberDisplayAvatar || userDisplayAvatar },
footer: { text: `ID:⠀${interaction.targetUser.id}` }
})
],
flags: MessageFlags.Ephemeral
});
}