diff --git a/commands/interaction/context/audio.js b/commands/interaction/context/audio.js index 837f253..18e00f6 100644 --- a/commands/interaction/context/audio.js +++ b/commands/interaction/context/audio.js @@ -1,6 +1,7 @@ const { renderMusicButtons } = require('#utils/buttons'); const { createEmbed } = require('#utils/embed'); const { acknowledge } = require('#utils/interactions'); +const { editOrReply } = require('#utils/message'); const { ApplicationCommandTypes } = require("detritus-client/lib/constants");; @@ -32,7 +33,7 @@ module.exports = { let song = songlink.body.entitiesByUniqueId[songlink.body.entityUniqueId] let btns = renderMusicButtons(songlink.body.linksByPlatform) - return context.editOrRespond({embeds:[ + return editOrReply(context, {embeds:[ createEmbed("default", context, { author: { name: `${song.title} by ${song.artistName}`.substr(0,1000), @@ -45,16 +46,14 @@ module.exports = { }) ], components: btns }) }catch(e){ - return context.editOrRespond({ embeds: [createEmbed("warning", context, "No results found.")] }) + return editOrReply(context, createEmbed("warning", context, "No results found.")) } } else { - return context.editOrRespond({ embeds: [createEmbed("warning", context, "No urls found.")] }) + return editOrReply(context, createEmbed("warning", context, "No urls found.")) } }catch(e){ console.log(e) - await context.editOrRespond({ - embeds: [createEmbed("error", context, "Unable to look up song url.")] - }) + await editOrReply(context, createEmbed("error", context, "Unable to look up song url.")) } }, }; \ No newline at end of file diff --git a/commands/interaction/context/ocr.js b/commands/interaction/context/ocr.js index 6f8b54d..eb30f0a 100644 --- a/commands/interaction/context/ocr.js +++ b/commands/interaction/context/ocr.js @@ -4,6 +4,7 @@ const { getMessageAttachment, validateAttachment } = require('#utils/attachment' const { createEmbed } = require('#utils/embed'); const { acknowledge } = require('#utils/interactions'); const { codeblock } = require('#utils/markdown'); +const { editOrReply } = require('#utils/message'); const { STATICS } = require('#utils/statics'); const { ApplicationCommandTypes, MessageFlags } = require("detritus-client/lib/constants"); @@ -31,27 +32,25 @@ module.exports = { } else { delete attachment; } - if(!attachment) return context.editOrRespond({ embeds: [createEmbed("warning", context, "No images found.")] }) + if(!attachment) return editOrReply(context, createEmbed("warning", context, "No images found.")) let ocr = await googleVisionOcr(context, attachment) - if(ocr.response.body.status == 1) return context.editOrRespond({ embeds: [createEmbed("warning", context, ocr.response.body.text)] }) + if(ocr.response.body.status == 1) return editOrReply(context, createEmbed("warning", context, ocr.response.body.text)) - await context.editOrRespond({ - embeds: [createEmbed("default", context, { - thumbnail: { - url: attachment - }, - description: codeblock("ansi", ["​" + ocr.response.body.text.substr(0,3900)]), - footer: { - iconUrl: STATICS.google, - text: `Google Cloud Vision • ${context.application.name} • Took ${ocr.timings}s` - } - })] - }) + await editOrReply(context, createEmbed("default", context, { + thumbnail: { + url: attachment + }, + description: codeblock("ansi", ["​" + ocr.response.body.text.substr(0,3900)]), + footer: { + iconUrl: STATICS.google, + text: `Google Cloud Vision • ${context.application.name} • Took ${ocr.timings}s` + } + })) }catch(e){ console.log(e) - await context.editOrRespond({ + await editOrReply(context, { embeds: [createEmbed("error", context, "Unable to perform Optical Character Recognition.")], flags: MessageFlags.EPHEMERAL }) diff --git a/commands/interaction/context/ocrtr.js b/commands/interaction/context/ocrtr.js index f2187fb..390a4f8 100644 --- a/commands/interaction/context/ocrtr.js +++ b/commands/interaction/context/ocrtr.js @@ -62,10 +62,7 @@ module.exports = { } }catch(e){ console.log(e) - await context.editOrRespond({ - embeds: [createEmbed("error", context, "Unable to perform Optical Character Recognition.")], - flags: MessageFlags.EPHEMERAL - }) + await editOrReply(context, createEmbed("error", context, "Unable to perform Optical Character Recognition.")) } }, }; \ No newline at end of file diff --git a/commands/interaction/context/reverse-image.js b/commands/interaction/context/reverse-image.js index fd4c65e..031ccb0 100644 --- a/commands/interaction/context/reverse-image.js +++ b/commands/interaction/context/reverse-image.js @@ -56,7 +56,7 @@ module.exports = { } else { delete attachment; } - if(!attachment) return context.editOrRespond({ embeds: [createEmbed("warning", context, "No images found.")] }) + if(!attachment) return editOrReply(context, createEmbed("warning", context, "No images found.")) let search = await reverseImageSearch(context, attachment)