'TypeError [INVALID_TYPE]: Supplied data.type is not a valid MessageComponentType - Discord.js
hey im trying to make a slashCommand that generate random pics with button..
so when a user use the command it will sent an embed with button and then the button when a user clicked that, the embed will edited and load another picture
but It seems i was doing it wrong..
Node: v17.7.2
Discord.js: 13.2.0
here is my code
const { MessageEmbed, MessageActionRow, MessageButton } = require('discord.js');
const superagent = require('superagent');
const ee = require("../../config.json");
module.exports = {
name: 'waifu',
description: 'Give you a random anime waifus pics',
run: async (client, interaction, args) => {
let { body } = await superagent.get(`https://api.waifu.pics/sfw/waifu`);
const msg = await interaction.followUp({
embeds: [
new MessageEmbed()
.setColor(ee.color)
.setTitle("Waifu 😳")
.setImage(body.url)
.setTimestamp()
],
components: [
new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId('nextWaifu')
.setLabel('More Waifu')
.setStyle('SUCCESS')
)
],
fetchReply: true
});
let embed = msg.embeds
embed.color = ee.color;
embed.image = body.url;
let components = msg.components
return msg.edit({ embeds: [embed], components: [components], fetchReply: true });
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|