update translate header design (again, this time consistently)

This commit is contained in:
bignutty 2025-02-22 15:20:11 +01:00
parent e2075b8306
commit c5d49cf0f7
5 changed files with 109 additions and 69 deletions

View file

@ -4,12 +4,12 @@ const { TRANSLATE_DISPLAY_MAPPINGS, TRANSLATE_LANGUAGES, PERMISSION_GROUPS } = r
const { getMessageAttachment, validateAttachment } = require('#utils/attachment');
const { createEmbed } = require('#utils/embed');
const { acknowledge } = require('#utils/interactions');
const { codeblock, pill, icon, iconAsEmojiObject } = require('#utils/markdown');
const { codeblock, pill, icon, stringwrap} = require('#utils/markdown');
const { editOrReply } = require('#utils/message');
const { STATICS, STATIC_ACTIONS } = require('#utils/statics');
const { STATICS } = require('#utils/statics');
const { Context, Argument } = require('detritus-client/lib/command');
const { ApplicationCommandTypes, MessageFlags, InteractionContextTypes, ApplicationIntegrationTypes, MessageComponentTypes, InteractionCallbackTypes } = require("detritus-client/lib/constants");
const { ApplicationCommandTypes, MessageFlags, InteractionContextTypes, ApplicationIntegrationTypes, InteractionCallbackTypes } = require("detritus-client/lib/constants");
const { Components } = require('detritus-client/lib/utils');
module.exports = {
@ -39,13 +39,13 @@ module.exports = {
if(attachment && validateAttachment(attachment, "image")){
attachment = attachment.url
} else {
delete attachment;
attachment = false;
}
if(!attachment) return editOrReply(context, createEmbed("warning", context, "No images found."))
let ocr = await googleVisionOcr(context, attachment)
if(ocr.response.body.status == 1) return editOrReply(context, createEmbed("warning", context, ocr.response.body.text))
if(ocr.response.body.status === 1) return editOrReply(context, createEmbed("warning", context, ocr.response.body.text))
const components = new Components({
timeout: 100000,
@ -54,11 +54,11 @@ module.exports = {
let translate = await googleTranslate(context, ocr.response.body.text, "en", "auto")
let fromFlag = TRANSLATE_DISPLAY_MAPPINGS[translate.response.body.language.from || sourceLanguage] || ''
let fromFlag = TRANSLATE_DISPLAY_MAPPINGS[translate.response.body.language.from] || ''
let toFlag = TRANSLATE_DISPLAY_MAPPINGS[translate.response.body.language.to] || ''
return editOrReply(context, createEmbed("default", context, {
description: `${icon("locale")} ${fromFlag} ${pill(TRANSLATE_LANGUAGES[translate.response.body.language.from || sourceLanguage] || translate.response.body.language.from || "Detected Language")} ${icon("arrow_right")} ${toFlag} ${pill(TRANSLATE_LANGUAGES[translate.response.body.language.to] || translate.response.body.language.to)}\n${codeblock("ansi", [translate.response.body.translation])}`,
description: `-# ${icon("locale")} ${fromFlag} ${pill(TRANSLATE_LANGUAGES[translate.response.body.language.from] || translate.response.body.language.from || "Detected Language")} ${icon("arrow_right")} ${toFlag} ${pill(TRANSLATE_LANGUAGES[translate.response.body.language.to] || translate.response.body.language.to)}\n${codeblock("ansi", [stringwrap(translate.response.body.translation, 1900)])}`,
thumbnail: {
url: attachment
},