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] }); ; }, }; ```
5 Replies
d.js toolkit
d.js toolkit15mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Shuttle
Shuttle15mo ago
please show your code properly
Boat
BoatOP15mo ago
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] });
;
},


};
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] });
;
},


};
Shuttle
Shuttle15mo ago
const member = interaction.options.getMember('target') || interaction.member;
const member = interaction.options.getMember('target') || interaction.member;
also why you require discord.js 2 times
Boat
BoatOP15mo ago
thank you sir if only i understand this stuff enough to answer you oh it seem to still not work
Want results from more Discord servers?
Add your server