mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-11 05:46:16 +00:00
fix(bots/discord): pass non-empty out of scope label to discord
This commit is contained in:
@@ -39,7 +39,7 @@ export default new Command({
|
||||
custom_id: `tr_${trigger.targetMessage.channelId}_${trigger.targetId}`,
|
||||
options: [
|
||||
...labels.map(label => ({ label, value: label })),
|
||||
{ label: 'Out of scope', value: '', emoji: { name: '❌' } },
|
||||
{ label: 'Out of scope', value: OutOfScopeLabel, emoji: { name: '❌' } },
|
||||
],
|
||||
type: ComponentType.StringSelect,
|
||||
} satisfies APIStringSelectComponent,
|
||||
@@ -51,3 +51,5 @@ export default new Command({
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
export const OutOfScopeLabel = '<out of scope>'
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { MessageFlags, type TextBasedChannel } from 'discord.js'
|
||||
import { OutOfScopeLabel } from '$/commands/support/train/context-menu'
|
||||
import { createErrorEmbed, createStackTraceEmbed, createSuccessEmbed } from '$utils/discord/embeds'
|
||||
import { on, withContext } from '$utils/discord/events'
|
||||
|
||||
@@ -30,9 +31,11 @@ withContext(on, 'interactionCreate', async (context, interaction) => {
|
||||
flags: MessageFlags.Ephemeral,
|
||||
}))
|
||||
|
||||
// If selectedLabel is empty, it means "out of scope", so we pass undefined
|
||||
const selectedLabel = interaction.values[0] || undefined
|
||||
await context.api.client.trainMessage(msg.content, selectedLabel)
|
||||
const selectedLabel = interaction.values[0]
|
||||
await context.api.client.trainMessage(
|
||||
msg.content,
|
||||
selectedLabel === OutOfScopeLabel ? undefined : selectedLabel,
|
||||
)
|
||||
await interaction.reply({
|
||||
embeds: [
|
||||
createSuccessEmbed(
|
||||
|
||||
Reference in New Issue
Block a user