diff --git a/commands/interaction/context/ocr.js b/commands/interaction/context/ocr.js index 0029a06..5c1aef1 100644 --- a/commands/interaction/context/ocr.js +++ b/commands/interaction/context/ocr.js @@ -4,11 +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 } = require('#utils/markdown'); +const { codeblock, pill, icon, iconAsEmojiObject } = require('#utils/markdown'); const { editOrReply } = require('#utils/message'); const { STATICS, STATIC_ACTIONS } = require('#utils/statics'); +const { Context, Argument } = require('detritus-client/lib/command'); -const { ApplicationCommandTypes, MessageFlags, InteractionContextTypes, ApplicationIntegrationTypes } = require("detritus-client/lib/constants"); +const { ApplicationCommandTypes, MessageFlags, InteractionContextTypes, ApplicationIntegrationTypes, MessageComponentTypes, InteractionCallbackTypes } = require("detritus-client/lib/constants"); const { Components } = require('detritus-client/lib/utils'); module.exports = { @@ -22,6 +23,12 @@ module.exports = { integrationTypes: [ ApplicationIntegrationTypes.USER_INSTALL ], + /** + * + * @param {Context} context + * @param {Argument} args + * @returns + */ run: async (context, args) => { try{ await acknowledge(context, false, [...PERMISSION_GROUPS.baseline_slash]); @@ -44,10 +51,6 @@ module.exports = { timeout: 100000, run: async (ctx) => { if (ctx.userId !== context.userId) return await ctx.respond(InteractionCallbackTypes.DEFERRED_UPDATE_MESSAGE); - - await ctx.editOrRespond({ - embeds: [createEmbed("ai_custom", context, STATIC_ACTIONS.translate)] - }) let translate = await googleTranslate(context, ocr.response.body.text, "en", "auto") @@ -75,7 +78,7 @@ module.exports = { }) await editOrReply(context, createEmbed("default", context, { - embeds: [{ + embeds: [createEmbed("default", context, { thumbnail: { url: attachment }, @@ -84,7 +87,7 @@ module.exports = { iconUrl: STATICS.googlelens, text: `Google Lens • ${context.application.name} • Took ${ocr.timings}s` } - }], + })], components })) }catch(e){ diff --git a/commands/message/core/help.js b/commands/message/core/help.js index c3bf922..d70c0e3 100644 --- a/commands/message/core/help.js +++ b/commands/message/core/help.js @@ -109,12 +109,12 @@ function createCommandPage(context, prefix, command, slashCommands) { // These categories will be displayed to users, add them in the correct order const categories = { - "core": `${icon("home")} Core Commands`, + "core": `${icon("home")} System Commands`, "info": `${icon("information")} Information Commands`, "search": `${icon("mag")} Search Commands`, "utils": `${icon("tools")} Utility Commands`, "fun": `${icon("stars")} Fun Commands`, - "mod": `${icon("shield")} "Moderation Command}` + "mod": `${icon("shield")} Moderation Command` } module.exports = { diff --git a/labscore/utils/message.js b/labscore/utils/message.js index a95f091..5832fef 100644 --- a/labscore/utils/message.js +++ b/labscore/utils/message.js @@ -48,33 +48,37 @@ module.exports.editOrReply = function(context, message, disableReference = false } return context.editOrRespond(message).catch(async (e)=>{ - const errorData = await e.response.json(); - if(MESSAGE_BLOCK_REASONS[errorData.code]){ - // Delete the public response - await context.deleteResponse(); - - message.flags = MessageFlags.EPHEMERAL + try{ - // Create a notice - if(message.content){ - if(message.embeds && message.embeds.length <= 4){ - message.embeds.unshift({ - description: `${icon("flask_incognito")} ​ ​ This response has been made incognito due to ${MESSAGE_BLOCK_REASONS[errorData.code].message}.`, - color: COLORS.incognito - }) + const errorData = await e.response.json(); + if(MESSAGE_BLOCK_REASONS[errorData.code]){ + // Delete the public response + await context.deleteResponse(); + + message.flags = MessageFlags.EPHEMERAL + + // Create a notice + if(message.content){ + if(message.embeds && message.embeds.length <= 4){ + message.embeds.unshift({ + description: `${icon("flask_incognito")} ​ ​ This response has been made incognito due to ${MESSAGE_BLOCK_REASONS[errorData.code].message}.`, + color: COLORS.incognito + }) + } + } else { + // Uses new subtext formatting to look more "native" + message.content = `-# ${icon("flask_mini")} This response has been made incognito due to ${MESSAGE_BLOCK_REASONS[errorData.code].message} • ${link("https://support.discord.com/hc/en-us/articles/" + MESSAGE_BLOCK_REASONS[errorData.code].support_article, "Learn More", "Support Article")}` } - } else { - // Uses new subtext formatting to look more "native" - message.content = `-# ${icon("flask_mini")} This response has been made incognito due to ${MESSAGE_BLOCK_REASONS[errorData.code].message} • ${link("https://support.discord.com/hc/en-us/articles/" + MESSAGE_BLOCK_REASONS[errorData.code].support_article, "Learn More", "Support Article")}` - } - - let replacementMessage = await context.createMessage(message); - - if(!context._meta) context._meta = {} - context._meta.replacementMessageId = replacementMessage.id; - return replacementMessage; - + let replacementMessage = await context.createMessage(message); + + if(!context._meta) context._meta = {} + context._meta.replacementMessageId = replacementMessage.id; + + return replacementMessage; + } + }catch(e){ + console.log(e) } basecamp(formatErrorMessage(3, "SHARD_MESSAGE_ERROR", `\`[Shard ${context.client.shardId}]\` Command \`${context.command.name}\` failed to respond: @ \`${Date.now()}\`\nGuild: \`${context.guild?.id}\`\nChannel: \`${context.channel?.id}\`\nUser: \`${context.user?.id}\`\`\`\`js\n${e}\`\`\``), message); })