mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-11 21:56:17 +00:00
fix: dislike button not working properly
This commit is contained in:
@@ -1,7 +1,4 @@
|
|||||||
import {
|
import { ContextMenuCommandBuilder, ApplicationCommandType } from 'discord.js';
|
||||||
ContextMenuCommandBuilder,
|
|
||||||
ApplicationCommandType
|
|
||||||
} from 'discord.js';
|
|
||||||
import trainAISelectMenu from '../utils/trainAISelectMenu.js';
|
import trainAISelectMenu from '../utils/trainAISelectMenu.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -13,11 +10,12 @@ export default {
|
|||||||
interaction.member.roles.highest.comparePositionTo(
|
interaction.member.roles.highest.comparePositionTo(
|
||||||
interaction.member.guild.roles.cache.get(config.discord.trainRole)
|
interaction.member.guild.roles.cache.get(config.discord.trainRole)
|
||||||
) < 0
|
) < 0
|
||||||
) return interaction.reply({
|
)
|
||||||
|
return interaction.reply({
|
||||||
content: 'You don\'t have the permission to do this.',
|
content: 'You don\'t have the permission to do this.',
|
||||||
ephemeral: true
|
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';
|
import trainAISelectMenu from '../../utils/trainAISelectMenu.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -52,12 +57,19 @@ export default {
|
|||||||
.setStyle(ButtonStyle.Danger)
|
.setStyle(ButtonStyle.Danger)
|
||||||
);
|
);
|
||||||
|
|
||||||
const reply = await message.reply({ embeds: [embed], components: [feedbackRow] });
|
const reply = await message.reply({
|
||||||
const filter = (i) => i.member.roles.highest.comparePositionTo(
|
embeds: [embed],
|
||||||
i.member.guild.roles.cache.get(config.discord.trainRole)
|
components: [feedbackRow]
|
||||||
) > 0
|
});
|
||||||
|
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) => {
|
collector.on('collect', (i) => {
|
||||||
if (i.customId == 'fb-like') {
|
if (i.customId == 'fb-like') {
|
||||||
// We train it using the label the AI gave.
|
// 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.' });
|
i.reply({ ephemeral: true, content: 'Sent train data to server.' });
|
||||||
} else {
|
} else {
|
||||||
// We ask the trainer to train it using the select menu.
|
// We ask the trainer to train it using the select menu.
|
||||||
trainAISelectMenu(i, config, helper);
|
trainAISelectMenu(i, config, helper, message);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
return;
|
return;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
|||||||
@@ -1,43 +1,48 @@
|
|||||||
import {
|
import {
|
||||||
ActionRowBuilder,
|
ActionRowBuilder,
|
||||||
StringSelectMenuBuilder,
|
StringSelectMenuBuilder,
|
||||||
ComponentType
|
ComponentType
|
||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
|
|
||||||
export default async function trainAISelectMenu(interaction, config, helper) {
|
export default async function trainAISelectMenu(
|
||||||
const options = [];
|
interaction,
|
||||||
|
config,
|
||||||
|
helper,
|
||||||
|
message
|
||||||
|
) {
|
||||||
|
const options = [];
|
||||||
|
|
||||||
for (const { label } of config.responses) {
|
for (const { label } of config.responses) {
|
||||||
options.push({
|
options.push({
|
||||||
label: label,
|
label: label,
|
||||||
description: `The ${label} label.`,
|
description: `The ${label} label.`,
|
||||||
value: label.toLowerCase()
|
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({
|
const row = new ActionRowBuilder().addComponents(
|
||||||
componentType: ComponentType.StringSelect,
|
new StringSelectMenuBuilder()
|
||||||
time: 15000
|
.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) => {
|
const collector = reply.createMessageComponentCollector({
|
||||||
helper.sendTrainData(
|
componentType: ComponentType.StringSelect,
|
||||||
interaction.targetMessage.content.toLowerCase(),
|
time: 15000
|
||||||
i.values[0].toUpperCase()
|
});
|
||||||
);
|
|
||||||
|
|
||||||
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.`,
|
`## ${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],
|
message_thread_id: ids[1],
|
||||||
reply_to_message_id: ids[2],
|
reply_to_message_id: ids[2]
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user