FIXED | discord.js im trying to do a command to the economy system using mongoose im using discord.js V13

Viewed 45

the command is about asking for coins. and i want to get the amount of coins that the user asked from the ask.js to the interactionCreate.js. to get the amount i tried

module.exports = {
    name: "ask",
    description: "ask for money",
    async execute(client, message, args, Discord, profileData) {
        let amount = args[1]
        amount.setCustomId(`amountID-${amount}`)
    if (!amount) return message.reply("Please enter a valid amount")
    if(isNaN(amount)) return message.reply("Please enter a valid amount!");
    if(amount < 1) return message.reply("You have to ask at least for one coin!");
    if (amount > 5000) return message.reply("You can\'t ask for more that 5000!");

    const embed = new MessageEmbed()
    .setColor("BLUE")
    .setTitle(`${message.author.username} is asking!`)
    .setDescription(`<:Hover_Bits:1019925128215277578>・${message.author.username} is asking for ${amount} coins!`);
    const row1 = new MessageActionRow()
    .addComponents(
        new MessageButton()
        .setCustomId('pay')
        .setLabel('Pay')
        .setStyle('SECONDARY')
    )

    const replied = await message.channel.send({
        embeds: [embed],
        components: [row1],
     })
   }
}

and its saying:

TypeError: Cannot read properties of undefined (reading 'setCustomId')

and that is my interactionCreate.js

if (interaction.customId == 'pay') {
     await interaction.deferUpdate()
     const amount = split[1]
}

every help will be great

1 Answers

If you're using djs v14 then it should be new ActionRowBuilder()

- const actionRow = new MessageActionRow(); //djs v13
+ const actionRow = new ActionRowBuilder(); //djs v14

You can look at their document for more changes v13 to v14: Click Here

Related