fix: dislike button not working properly

This commit is contained in:
GramingFoxTeam
2023-03-21 19:57:22 +03:00
parent a9ff00394a
commit 85eba55424
4 changed files with 63 additions and 48 deletions

View File

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