.setImage EmbedBuilder

im learning to interact with api's and im having trouble with setImage for the embedbuilder theres alway a url in the data for a image but no matter what i do it will not set the image ive tried with just using the Random.data.icon_url in the setImage and still nothing there are no errors in the console it just doesnt set the image Node: 18.5.0 Discord: 14.9.0
run: async ({ interaction }) => {
const { user } = interaction;
const BaseURL = 'https://api.chucknorris.io/jokes';
const chuckAPI = axios.create({
baseURL: BaseURL,
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
'User-Agent': '(Personal) learning to interact with api\'s'
}
});

/**
* /random
* /random/category?{category}
* /search?query={query}
*/

const Random = await chuckAPI.get<IChuck>('/random');
const Category = await chuckAPI.get<ICategory>('/categories');
// const Search = await chuckAPI.get('/search?query=${query}');

console.log(Random.data);

const chuckEmbed = new EmbedBuilder()
.setTitle('ChuckNorris API')
.setAuthor({ name: user.username, iconURL: user.displayAvatarURL({ size: 512 }) })
.setDescription(`\`${Random.data.value}\``)
.setImage(`${Random.data.icon_url}`)
.setColor('Green')
.setTimestamp();

await interaction.reply({ embeds: [chuckEmbed], ephemeral: true });
}
run: async ({ interaction }) => {
const { user } = interaction;
const BaseURL = 'https://api.chucknorris.io/jokes';
const chuckAPI = axios.create({
baseURL: BaseURL,
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
'User-Agent': '(Personal) learning to interact with api\'s'
}
});

/**
* /random
* /random/category?{category}
* /search?query={query}
*/

const Random = await chuckAPI.get<IChuck>('/random');
const Category = await chuckAPI.get<ICategory>('/categories');
// const Search = await chuckAPI.get('/search?query=${query}');

console.log(Random.data);

const chuckEmbed = new EmbedBuilder()
.setTitle('ChuckNorris API')
.setAuthor({ name: user.username, iconURL: user.displayAvatarURL({ size: 512 }) })
.setDescription(`\`${Random.data.value}\``)
.setImage(`${Random.data.icon_url}`)
.setColor('Green')
.setTimestamp();

await interaction.reply({ embeds: [chuckEmbed], ephemeral: true });
}
2 Replies
d.js toolkit
d.js toolkit14mo ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
CanadienDragon
CanadienDragon14mo ago
Returned Data, the icon_url is always set to the same png
{
categories: [],
created_at: '2020-01-05 13:42:22.089095',
icon_url: 'https://assets.chucknorris.host/img/avatar/chuck-norris.png',
id: 'qIcQkkkaRC6ZbbyrT1i-Pg',
updated_at: '2020-01-05 13:42:22.089095',
url: 'https://api.chucknorris.io/jokes/qIcQkkkaRC6ZbbyrT1i-Pg',
value: 'This Chuck Norris infant picture was sold to People magazine for $54 billions.'
}
{
categories: [],
created_at: '2020-01-05 13:42:22.089095',
icon_url: 'https://assets.chucknorris.host/img/avatar/chuck-norris.png',
id: 'qIcQkkkaRC6ZbbyrT1i-Pg',
updated_at: '2020-01-05 13:42:22.089095',
url: 'https://api.chucknorris.io/jokes/qIcQkkkaRC6ZbbyrT1i-Pg',
value: 'This Chuck Norris infant picture was sold to People magazine for $54 billions.'
}