diff --git a/commands/message/dev/update.js b/commands/message/dev/update.js index 7fd9ce6..247ab4b 100644 --- a/commands/message/dev/update.js +++ b/commands/message/dev/update.js @@ -24,13 +24,13 @@ module.exports = { const t = Date.now() if(args.force) execSync("git checkout .") const r = execSync("git pull") - if(r.toString().includes("Already up to date.")) return await response.edit({embeds: [createEmbed("warning", context, "Already up to date.")]}) + if(r.toString().includes("Already up to date.")) return await editOrReply(context, {embeds: [createEmbed("warning", context, "Already up to date.")]}) let com = r.toString().match(/([a-z0-9]{7})\.\.([a-z0-9]{7})/) - return await response.edit({ content: `${icon("success_simple")} Updated ${highlight(com[1] + ' -> ' + com[2])} in ${((Date.now() - t) / 1000).toFixed(2)}s`, embeds: []}) + return await editOrReply(context, { content: `${icon("success_simple")} Updated ${highlight(com[1] + ' -> ' + com[2])} in ${((Date.now() - t) / 1000).toFixed(2)}s`, embeds: []}) }catch(e){ console.log(e) - return await response.edit({embeds: [createEmbed("error", context, "Update failed.")]}) + return await editOrReply(context, createEmbed("error", context, "Update failed.")) } } }; \ No newline at end of file diff --git a/commands/message/fun/art.js b/commands/message/fun/art.js index 55bddbc..b4daff3 100644 --- a/commands/message/fun/art.js +++ b/commands/message/fun/art.js @@ -87,7 +87,7 @@ module.exports = { const image = await superagent.get(res.image_link) - await response.edit({ + return await editOrReply(context, { embeds: [createEmbed("image", context, { url: res.hash, description: `${codeblock(`py`, [`${DEFAULT_BOT_PREFIX}art -type ${args.type.toLowerCase()} -seed ${seed} -variance ${variance} -rotate ${rotate}`])}`, @@ -97,7 +97,7 @@ module.exports = { }) }catch(e){ console.log(e) - return editOrReply(context, {embeds:[createEmbed("error", context, `Unable to generate image.`)]}) + return await editOrReply(context, {embeds:[createEmbed("error", context, `Unable to generate image.`)]}) } } }; \ No newline at end of file diff --git a/commands/message/image/dalle.js b/commands/message/image/dalle.js index 2c78f20..ef213e3 100644 --- a/commands/message/image/dalle.js +++ b/commands/message/image/dalle.js @@ -30,7 +30,7 @@ module.exports = { emb.footer = { text: "This might take several minutes to complete." }; - response.edit({ embeds: [ emb ] }); + editOrReply(context, { embeds: [ emb ] }); }, 30000) try{ @@ -54,10 +54,10 @@ module.exports = { }) } - await response.edit({ embeds, files }) + await editOrReply(context, { embeds, files }) }catch(e){ - if(e.response.status == 503) return await response.edit({embeds:[createEmbed("error", context, `DALL-E server is busy, try again later.`)]}) - await response.edit({embeds:[createEmbed("error", context, `Image generation failed.`)]}) + if(e.response.status == 503) return await editOrReply(context, createEmbed("error", context, `DALL-E Mini server is busy, try again later.`)) + await editOrReply(context, createEmbed("error", context, `Image generation failed.`)) } }, }; \ No newline at end of file diff --git a/commands/message/image/makesweet/billboard.js b/commands/message/image/makesweet/billboard.js index 56f0a76..d5b985c 100644 --- a/commands/message/image/makesweet/billboard.js +++ b/commands/message/image/makesweet/billboard.js @@ -31,7 +31,7 @@ module.exports = { const timings = Date.now(); let mkswt = await billboardCityscape(image) - return await response.edit({ + return await editOrReply(context, { embeds: [createEmbed("image", context, { url: "makesweet.gif", time: ((Date.now() - timings) / 1000).toFixed(2), @@ -44,7 +44,7 @@ module.exports = { }) } catch (e) { console.log(e) - await response.edit({ embeds: [createEmbed("error", context, "Something went wrong.")] }) + await editOrReply(context, { embeds: [createEmbed("error", context, "Something went wrong.")] }) } }, } \ No newline at end of file diff --git a/commands/message/image/makesweet/circuitboard.js b/commands/message/image/makesweet/circuitboard.js index e9f20f7..a47d844 100644 --- a/commands/message/image/makesweet/circuitboard.js +++ b/commands/message/image/makesweet/circuitboard.js @@ -31,7 +31,7 @@ module.exports = { const timings = Date.now(); let mkswt = await circuitBoard(image) - return await response.edit({ + return await editOrReply(context, { embeds: [createEmbed("image", context, { url: "makesweet.gif", time: ((Date.now() - timings) / 1000).toFixed(2), @@ -43,7 +43,7 @@ module.exports = { files: [{ filename: "makesweet.gif", value: mkswt.body }] }) } catch (e) { - await response.edit({ embeds: [createEmbed("error", context, e)] }) + await editOrReply(context, createEmbed("error", context, e)) } } } \ No newline at end of file diff --git a/commands/message/image/makesweet/flag.js b/commands/message/image/makesweet/flag.js index bf0f0b3..23ab50e 100644 --- a/commands/message/image/makesweet/flag.js +++ b/commands/message/image/makesweet/flag.js @@ -31,7 +31,7 @@ module.exports = { const timings = Date.now(); let mkswt = await flag(image) - return await response.edit({ + return await editOrReply(context, { embeds: [createEmbed("image", context, { url: "makesweet.gif", time: ((Date.now() - timings) / 1000).toFixed(2), @@ -43,7 +43,7 @@ module.exports = { files: [{ filename: "makesweet.gif", value: mkswt.body }] }) } catch (e) { - await response.edit({ embeds: [createEmbed("error", context, e)] }) + await editOrReply(context, createEmbed("error", context, e)) } }, } \ No newline at end of file diff --git a/commands/message/image/makesweet/heartlocket.js b/commands/message/image/makesweet/heartlocket.js index e6d844a..8364cef 100644 --- a/commands/message/image/makesweet/heartlocket.js +++ b/commands/message/image/makesweet/heartlocket.js @@ -31,7 +31,7 @@ module.exports = { const timings = Date.now(); let mkswt = await heartLocket(args.text, image) - return await response.edit({ + return await editOrReply(context, { embeds: [createEmbed("image", context, { url: "makesweet.gif", time: ((Date.now() - timings) / 1000).toFixed(2), @@ -43,7 +43,7 @@ module.exports = { files: [{ filename: "makesweet.gif", value: mkswt.body }] }) } catch (e) { - await response.edit({ embeds: [createEmbed("error", context, e)] }) + await editOrReply(context, createEmbed("error", context, e)) } } } \ No newline at end of file diff --git a/commands/message/utils/qr.js b/commands/message/utils/qr.js index 473521b..c81b5e6 100644 --- a/commands/message/utils/qr.js +++ b/commands/message/utils/qr.js @@ -34,7 +34,7 @@ module.exports = { "data": args.text }) - return await response.edit({ + return await editOrReply(context, { embeds: [createEmbed("image", context, { url: "qrcode.png", time: ((Date.now() - t) / 1000).toFixed(2) @@ -42,7 +42,7 @@ module.exports = { files: [{ filename: "qrcode.png", value: res.body }] }) }catch(e){ - return await response.edit({ embeds: [createEmbed("error", context, `Unable to generate qr code.`) ] }) + return await editOrReply(context, createEmbed("error", context, `Unable to generate qr code.`)) } } diff --git a/commands/message/utils/screenshot.js b/commands/message/utils/screenshot.js index 03c7d2c..7b8bd24 100644 --- a/commands/message/utils/screenshot.js +++ b/commands/message/utils/screenshot.js @@ -36,29 +36,29 @@ module.exports = { let ss = await screenshot(context, args.url, context.channel.nsfw) if(ss.response.body.status && ss.response.body.status !== 3){ - if(ss.response.body.image) return await response.edit({ + if(ss.response.body.image) return await editOrReply(context, { embeds: [createEmbed("image", context, { url: ss.response.body.image, time: ((Date.now() - t) / 1000).toFixed(2) })] }) - return await response.edit({ embeds: [createEmbed("error", context, "Unable to create screenshot.")] }) + return await editOrReply(context, createEmbed("error", context, "Unable to create screenshot.")) } let job = await processJob(ss.response.body.job) if(job.status){ if(!job.image) job = await processJob(ss.response.body.job) - if(job.image) return await response.edit({ + if(job.image) return await editOrReply(context, { embeds: [createEmbed("image", context, { url: job.image, time: ((Date.now() - t) / 1000).toFixed(2) })] }) - return await response.edit({ embeds: [createEmbed("error", context, "Unable to create screenshot.")] }) + return await editOrReply(context, createEmbed("error", context, "Unable to create screenshot.")) } - return await response.edit({ + return await editOrReply(context, { embeds: [createEmbed("image", context, { url: "screenshot.png", time: ((Date.now() - t) / 1000).toFixed(2) @@ -67,11 +67,9 @@ module.exports = { }) } catch(e){ console.log(e) - return await response.edit({ - embeds: [createEmbed("image", context, { - url: "https://derpystuff.gitlab.io/webstorage4/v2/assets/screenshot/screenshot_error.png" - })] - }) + return await editOrReply(context, createEmbed("image", context, { + url: "https://derpystuff.gitlab.io/webstorage4/v2/assets/screenshot/screenshot_error.png" + })) } } }; \ No newline at end of file diff --git a/labscore/paginator/structures/BasePaginator.js b/labscore/paginator/structures/BasePaginator.js index ff00e3d..094de38 100644 --- a/labscore/paginator/structures/BasePaginator.js +++ b/labscore/paginator/structures/BasePaginator.js @@ -41,10 +41,10 @@ module.exports = class BasePaginator extends EventEmitter { async update(data) { if (this.isShared) { for (const m of this.commandMessage.values()) { - await m.edit(data); + if(!m.deleted) await m.edit(data); } } else if (this.commandMessage) { - this.commandMessage.edit(data); + if(!this.commandMessage.deleted) this.commandMessage.edit(data); } } diff --git a/labscore/utils/message.js b/labscore/utils/message.js index b867a92..b090982 100644 --- a/labscore/utils/message.js +++ b/labscore/utils/message.js @@ -4,5 +4,6 @@ module.exports.editOrReply = function(context, message, disableReference = false if(!message.message_reference && !disableReference) message.reference = true // Disable mentions if(!message.allowedMentions) message.allowedMentions = {parse: [], repliedUser: false} - return context.editOrReply(message) + // Only respond if the command is still available. + if(!context.message.deleted) return context.editOrReply(message) } \ No newline at end of file