feat(bots/discord)!: allow message scan response to be message payloads

This commit is contained in:
PalmDevs
2024-07-26 00:16:11 +07:00
parent 1f5c5a92a6
commit e86180fe29
8 changed files with 34 additions and 17 deletions

View File

@@ -24,16 +24,19 @@ export const createSuccessEmbed = (title: string | null, description?: string) =
)
export const createMessageScanResponseEmbed = (
response: ConfigMessageScanResponseMessage,
response: NonNullable<ConfigMessageScanResponseMessage['embeds']>[number],
mode: 'ocr' | 'nlp' | 'match',
) => {
// biome-ignore lint/style/noParameterAssign: While this is confusing, it is fine for this purpose
if ('toJSON' in response) response = response.toJSON()
const embed = new EmbedBuilder().setTitle(response.title ?? null)
if (response.description) embed.setDescription(response.description)
if (response.fields) embed.addFields(response.fields)
embed.setFooter({
text: `ReVanced • Done via ${MessageScanHumanizedMode[mode]}`,
text: `ReVanced • Via ${MessageScanHumanizedMode[mode]}`,
iconURL: ReVancedLogoURL,
})

View File

@@ -158,8 +158,10 @@ export const handleUserResponseCorrection = async (
correctedById: user.id,
})
.where(eq(responses.replyId, response.replyId))
await reply.edit({
embeds: [createMessageScanResponseEmbed(correctLabelResponse.response, 'nlp')],
...correctLabelResponse.response,
embeds: correctLabelResponse.response.embeds?.map(it => createMessageScanResponseEmbed(it, 'nlp')),
})
}