feat: message buttons for training

This commit is contained in:
GramingFoxTeam
2023-03-20 23:51:53 +03:00
parent 4373ede855
commit 6551ca9dad
5 changed files with 80 additions and 45 deletions

View File

@@ -0,0 +1,43 @@
import {
ActionRowBuilder,
StringSelectMenuBuilder,
ComponentType
} from 'discord.js';
export default async function trainAISelectMenu(interaction, config, helper) {
const options = [];
for (const { label } of config.responses) {
options.push({
label: label,
description: `The ${label} label.`,
value: label.toLowerCase()
});
}
const row = new ActionRowBuilder().addComponents(
new StringSelectMenuBuilder()
.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) => {
helper.sendTrainData(
interaction.targetMessage.content.toLowerCase(),
i.values[0].toUpperCase()
);
i.reply({ content: 'Sent train data to server.', ephemeral: true });
});
}