mirror of
https://github.com/Expand-sys/expandchatbotv2
synced 2025-12-17 14:32:15 +11:00
35 lines
No EOL
1.3 KiB
JavaScript
35 lines
No EOL
1.3 KiB
JavaScript
const { CommandInteraction, ApplicationCommandType, ApplicationCommandOptionType, EmbedBuilder } = require('discord.js');
|
|
const { sendResponse } = require('../../../utils/utils');
|
|
const path = require('path');
|
|
|
|
module.exports = {
|
|
name: `avatar`,
|
|
description: `Fetch a user's avatar and display it in an embed`,
|
|
cooldown: 5,
|
|
type: ApplicationCommandType.ChatInput,
|
|
options: [{
|
|
name: `username`,
|
|
description: `The user whos avatar you want to fetch`,
|
|
type: ApplicationCommandOptionType.User,
|
|
required: false,
|
|
}],
|
|
/**
|
|
* @param {CommandInteraction} interaction
|
|
*/
|
|
async execute(interaction) {
|
|
const { member, options } = interaction;
|
|
|
|
await interaction.deferReply({ ephemeral: true }).catch(err => console.error(`${path.basename(__filename)} There was a problem deferring an interaction: `, err));
|
|
|
|
const target = options.getMember(`username`) || member;
|
|
|
|
// Create an embed with the target user's avatar
|
|
const response = new EmbedBuilder()
|
|
.setColor('#32BEA6')
|
|
.setAuthor({ name: `${target?.user.tag}`, iconURL: target?.user.displayAvatarURL({ dynamic: true }) })
|
|
.setTitle(`AVATAR`)
|
|
.setImage(`${target.user.displayAvatarURL({ dynamic: true })}?size=256`)
|
|
|
|
sendResponse(interaction, ``, [response]);
|
|
}
|
|
} |