Boat
DIAdiscord.js - Imagine an app
•Created by Boat on 9/2/2023 in #djs-questions
avatar options
I want it to get the target avatar when the command user put it in but if there is no target then it would get the command user avatar. It works fine when there is a target but doesnt when there is no target. I believe the problem area is this part " interaction.user.avatarURL()" when used on its own the avatar shows but when i put it in that line it doesnt work.
```js
const { SlashCommandBuilder } = require('discord.js');
const { EmbedBuilder } = require('discord.js')
module.exports = {
data: new SlashCommandBuilder()
.setName('avatar')
.setDescription('Embed Format Test')
.addUserOption(option => option.setName('target').setDescription('Display avatar of target'))
,
category: 'user',
async execute(interaction) {
//get target user avatar url const avatar = interaction.options.getMember('target').user.displayAvatarURL() interaction.user.avatarURL(); const exampleEmbed = new EmbedBuilder() .setColor(0x0099FF).setImage(avatar).setTimestamp() .setFooter({ text: interaction.options.getMember('target').user.username || interaction.member.username }) return interaction.reply({ embeds: [exampleEmbed] }); ; }, }; ```
//get target user avatar url const avatar = interaction.options.getMember('target').user.displayAvatarURL() interaction.user.avatarURL(); const exampleEmbed = new EmbedBuilder() .setColor(0x0099FF).setImage(avatar).setTimestamp() .setFooter({ text: interaction.options.getMember('target').user.username || interaction.member.username }) return interaction.reply({ embeds: [exampleEmbed] }); ; }, }; ```
9 replies