我有一个嵌入,我想添加一个按钮到它。我有下面的代码,我不知道如何添加一个按钮到它,当点击它应该运行命令a.buy(lowerclass)
(https://i.stack.imgur.com/67rP6.jpg)](https://i.stack.imgur.com/w9LXM.png)
我已经使用discohook进行了嵌入,但无法自定义按钮以运行命令
kmbjn2e31#
const {EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, Events} = require('discord.js'); const embed = new EmbedBuilder() .setTitle("Embed Title") .setDescription("Embed Description") .setColor("Embed color") const row = new ActionRowBuilder() .addComponents( new ButtonBuilder() .setCustomId('buton-id') .setLabel('Text that on button') .setStyle(ButtonStyle.Primary), ); //for message message.channel.send({embeds:[embed], components:[row]}) //for interaction interaction.channel.send({embeds:[embed], components:[row]}) // Button handle client.on(Events.InteractionCreate, async interaction => { if (interaction.isButton()) { if (interaction.customId === "buton-id") { someFunction() interaction.reply("Reply or something...") } } })
更多信息:按钮,嵌入
1条答案
按热度按时间kmbjn2e31#
更多信息:按钮,嵌入