mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-09 06:33:05 -04:00
fixes errors with ctx commands
This commit is contained in:
parent
11d20a8334
commit
d5d5f01cdc
4 changed files with 21 additions and 26 deletions
|
@ -1,6 +1,7 @@
|
||||||
const { renderMusicButtons } = require('#utils/buttons');
|
const { renderMusicButtons } = require('#utils/buttons');
|
||||||
const { createEmbed } = require('#utils/embed');
|
const { createEmbed } = require('#utils/embed');
|
||||||
const { acknowledge } = require('#utils/interactions');
|
const { acknowledge } = require('#utils/interactions');
|
||||||
|
const { editOrReply } = require('#utils/message');
|
||||||
|
|
||||||
const { ApplicationCommandTypes } = require("detritus-client/lib/constants");;
|
const { ApplicationCommandTypes } = require("detritus-client/lib/constants");;
|
||||||
|
|
||||||
|
@ -32,7 +33,7 @@ module.exports = {
|
||||||
let song = songlink.body.entitiesByUniqueId[songlink.body.entityUniqueId]
|
let song = songlink.body.entitiesByUniqueId[songlink.body.entityUniqueId]
|
||||||
|
|
||||||
let btns = renderMusicButtons(songlink.body.linksByPlatform)
|
let btns = renderMusicButtons(songlink.body.linksByPlatform)
|
||||||
return context.editOrRespond({embeds:[
|
return editOrReply(context, {embeds:[
|
||||||
createEmbed("default", context, {
|
createEmbed("default", context, {
|
||||||
author: {
|
author: {
|
||||||
name: `${song.title} by ${song.artistName}`.substr(0,1000),
|
name: `${song.title} by ${song.artistName}`.substr(0,1000),
|
||||||
|
@ -45,16 +46,14 @@ module.exports = {
|
||||||
})
|
})
|
||||||
], components: btns })
|
], components: btns })
|
||||||
}catch(e){
|
}catch(e){
|
||||||
return context.editOrRespond({ embeds: [createEmbed("warning", context, "No results found.")] })
|
return editOrReply(context, createEmbed("warning", context, "No results found."))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return context.editOrRespond({ embeds: [createEmbed("warning", context, "No urls found.")] })
|
return editOrReply(context, createEmbed("warning", context, "No urls found."))
|
||||||
}
|
}
|
||||||
}catch(e){
|
}catch(e){
|
||||||
console.log(e)
|
console.log(e)
|
||||||
await context.editOrRespond({
|
await editOrReply(context, createEmbed("error", context, "Unable to look up song url."))
|
||||||
embeds: [createEmbed("error", context, "Unable to look up song url.")]
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
|
@ -4,6 +4,7 @@ const { getMessageAttachment, validateAttachment } = require('#utils/attachment'
|
||||||
const { createEmbed } = require('#utils/embed');
|
const { createEmbed } = require('#utils/embed');
|
||||||
const { acknowledge } = require('#utils/interactions');
|
const { acknowledge } = require('#utils/interactions');
|
||||||
const { codeblock } = require('#utils/markdown');
|
const { codeblock } = require('#utils/markdown');
|
||||||
|
const { editOrReply } = require('#utils/message');
|
||||||
const { STATICS } = require('#utils/statics');
|
const { STATICS } = require('#utils/statics');
|
||||||
|
|
||||||
const { ApplicationCommandTypes, MessageFlags } = require("detritus-client/lib/constants");
|
const { ApplicationCommandTypes, MessageFlags } = require("detritus-client/lib/constants");
|
||||||
|
@ -31,27 +32,25 @@ module.exports = {
|
||||||
} else {
|
} else {
|
||||||
delete attachment;
|
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)
|
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({
|
await editOrReply(context, createEmbed("default", context, {
|
||||||
embeds: [createEmbed("default", context, {
|
thumbnail: {
|
||||||
thumbnail: {
|
url: attachment
|
||||||
url: attachment
|
},
|
||||||
},
|
description: codeblock("ansi", ["" + ocr.response.body.text.substr(0,3900)]),
|
||||||
description: codeblock("ansi", ["" + ocr.response.body.text.substr(0,3900)]),
|
footer: {
|
||||||
footer: {
|
iconUrl: STATICS.google,
|
||||||
iconUrl: STATICS.google,
|
text: `Google Cloud Vision • ${context.application.name} • Took ${ocr.timings}s`
|
||||||
text: `Google Cloud Vision • ${context.application.name} • Took ${ocr.timings}s`
|
}
|
||||||
}
|
}))
|
||||||
})]
|
|
||||||
})
|
|
||||||
}catch(e){
|
}catch(e){
|
||||||
console.log(e)
|
console.log(e)
|
||||||
await context.editOrRespond({
|
await editOrReply(context, {
|
||||||
embeds: [createEmbed("error", context, "Unable to perform Optical Character Recognition.")],
|
embeds: [createEmbed("error", context, "Unable to perform Optical Character Recognition.")],
|
||||||
flags: MessageFlags.EPHEMERAL
|
flags: MessageFlags.EPHEMERAL
|
||||||
})
|
})
|
||||||
|
|
|
@ -62,10 +62,7 @@ module.exports = {
|
||||||
}
|
}
|
||||||
}catch(e){
|
}catch(e){
|
||||||
console.log(e)
|
console.log(e)
|
||||||
await context.editOrRespond({
|
await editOrReply(context, createEmbed("error", context, "Unable to perform Optical Character Recognition."))
|
||||||
embeds: [createEmbed("error", context, "Unable to perform Optical Character Recognition.")],
|
|
||||||
flags: MessageFlags.EPHEMERAL
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
|
@ -56,7 +56,7 @@ module.exports = {
|
||||||
} else {
|
} else {
|
||||||
delete attachment;
|
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)
|
let search = await reverseImageSearch(context, attachment)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue