Files
revanced-bots/bots/discord/commands/trainMessage.js
2022-11-16 13:59:55 +03:00

50 lines
1.2 KiB
JavaScript

import {
ContextMenuCommandBuilder,
ApplicationCommandType,
ActionRowBuilder,
SelectMenuBuilder,
ComponentType
} from 'discord.js';
export default {
data: new ContextMenuCommandBuilder()
.setName('Train Message')
.setType(ApplicationCommandType.Message),
async execute(interaction) {
const options = [];
for (const { label } of global.config.responses) {
options.push({
label: label,
description: `The ${label} label.`,
value: label.toLowerCase()
});
}
const row = new ActionRowBuilder().addComponents(
new SelectMenuBuilder()
.setCustomId('select')
.setPlaceholder('Nothing selected')
.addOptions(options)
);
const reply = await interaction.reply({
content: 'Please select the corresponding label to train the bot.',
components: [row],
ephemeral: true
});
const collector = reply.createMessageComponentCollector({
componentType: ComponentType.StringSelect,
time: 15000
});
collector.on('collect', (i) => {
i.client.helper.sendTrainData(
interaction.targetMessage.content,
i.values[0].toUpperCase()
);
i.reply({ content: 'Sent train data to server.', ephemeral: true });
});
}
};