mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-11 13:56:15 +00:00
fix: dislike button not working properly
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
import {
|
||||
ContextMenuCommandBuilder,
|
||||
ApplicationCommandType
|
||||
} from 'discord.js';
|
||||
import { ContextMenuCommandBuilder, ApplicationCommandType } from 'discord.js';
|
||||
import trainAISelectMenu from '../utils/trainAISelectMenu.js';
|
||||
|
||||
export default {
|
||||
@@ -13,11 +10,12 @@ export default {
|
||||
interaction.member.roles.highest.comparePositionTo(
|
||||
interaction.member.guild.roles.cache.get(config.discord.trainRole)
|
||||
) < 0
|
||||
) return interaction.reply({
|
||||
)
|
||||
return interaction.reply({
|
||||
content: 'You don\'t have the permission to do this.',
|
||||
ephemeral: true
|
||||
});
|
||||
|
||||
trainAISelectMenu(interaction, config, helper);
|
||||
trainAISelectMenu(interaction, config, helper);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } from 'discord.js';
|
||||
import {
|
||||
EmbedBuilder,
|
||||
ActionRowBuilder,
|
||||
ButtonBuilder,
|
||||
ButtonStyle
|
||||
} from 'discord.js';
|
||||
import trainAISelectMenu from '../../utils/trainAISelectMenu.js';
|
||||
|
||||
export default {
|
||||
@@ -52,12 +57,19 @@ export default {
|
||||
.setStyle(ButtonStyle.Danger)
|
||||
);
|
||||
|
||||
const reply = await message.reply({ embeds: [embed], components: [feedbackRow] });
|
||||
const filter = (i) => i.member.roles.highest.comparePositionTo(
|
||||
i.member.guild.roles.cache.get(config.discord.trainRole)
|
||||
) > 0
|
||||
const reply = await message.reply({
|
||||
embeds: [embed],
|
||||
components: [feedbackRow]
|
||||
});
|
||||
const filter = (i) =>
|
||||
i.member.roles.highest.comparePositionTo(
|
||||
i.member.guild.roles.cache.get(config.discord.trainRole)
|
||||
) > 0;
|
||||
|
||||
const collector = reply.createMessageComponentCollector({ filter, time: 15_000 });
|
||||
const collector = reply.createMessageComponentCollector({
|
||||
filter,
|
||||
time: 15_000
|
||||
});
|
||||
collector.on('collect', (i) => {
|
||||
if (i.customId == 'fb-like') {
|
||||
// We train it using the label the AI gave.
|
||||
@@ -65,9 +77,9 @@ export default {
|
||||
i.reply({ ephemeral: true, content: 'Sent train data to server.' });
|
||||
} else {
|
||||
// We ask the trainer to train it using the select menu.
|
||||
trainAISelectMenu(i, config, helper);
|
||||
trainAISelectMenu(i, config, helper, message);
|
||||
}
|
||||
})
|
||||
});
|
||||
return;
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
|
||||
@@ -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 });
|
||||
});
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ export default {
|
||||
`## ${response.reply.title}\n\n${response.reply.desc}\n\n_Confidence: ${intent.confidence}_\n\nThis bot is currently being tested in production. Ignore it, if it's wrong.`,
|
||||
{
|
||||
message_thread_id: ids[1],
|
||||
reply_to_message_id: ids[2],
|
||||
reply_to_message_id: ids[2]
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user