const { ContextMenuCommandBuilder, ApplicationCommandType, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');
module.exports = {
data: new ContextMenuCommandBuilder()
.setName('Translate It v2')
.setType(ApplicationCommandType.Message),
async execute(interaction) {
const row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId('translate-en')
.setLabel('Translate to English')
.setStyle(ButtonStyle.Primary),
new ButtonBuilder()
.setCustomId('translate-es')
.setLabel('Translate to Spanish')
.setStyle(ButtonStyle.Primary)
);
await interaction.reply({ content: 'Choose the language to translate:', components: [row], ephemeral: true });
try {
const filter = i => i.user.id === interaction.user.id;
const buttonInteraction = await interaction.channel.awaitMessageComponent({ filter, time: 15000 });
...
const { ContextMenuCommandBuilder, ApplicationCommandType, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');
module.exports = {
data: new ContextMenuCommandBuilder()
.setName('Translate It v2')
.setType(ApplicationCommandType.Message),
async execute(interaction) {
const row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId('translate-en')
.setLabel('Translate to English')
.setStyle(ButtonStyle.Primary),
new ButtonBuilder()
.setCustomId('translate-es')
.setLabel('Translate to Spanish')
.setStyle(ButtonStyle.Primary)
);
await interaction.reply({ content: 'Choose the language to translate:', components: [row], ephemeral: true });
try {
const filter = i => i.user.id === interaction.user.id;
const buttonInteraction = await interaction.channel.awaitMessageComponent({ filter, time: 15000 });
...