mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-07 13:43:06 -04:00
55 lines
No EOL
2.3 KiB
JavaScript
55 lines
No EOL
2.3 KiB
JavaScript
const { getRecentImage } = require("#utils/attachment");
|
|
const { createEmbed } = require("#utils/embed");
|
|
const { editOrReply } = require("#utils/message");
|
|
const { STATICS } = require("#utils/statics");
|
|
|
|
// TODO: Turn this into a general purpose permissions constant
|
|
const { Permissions } = require("detritus-client/lib/constants");
|
|
|
|
const { circuitBoard } = require("../../../../service/makesweet");
|
|
const { link } = require("#utils/markdown");
|
|
|
|
module.exports = {
|
|
name: 'circuitboard',
|
|
label: 'text',
|
|
metadata: {
|
|
description: 'Generates an animated gif with the MakeSweet circuit board template.',
|
|
description_short: 'Animated circuit board generation',
|
|
category: 'image',
|
|
usage: 'circuitboard <image>'
|
|
},
|
|
permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.ATTACH_FILES, Permissions.READ_MESSAGE_HISTORY],
|
|
run: async (context, args) => {
|
|
|
|
return editOrReply(context, createEmbed("default", context, {
|
|
description: `Image manipulation commands are **no longer supported** in ${context.client.application.name}.\n\nIf you're looking for a suitable replacement, check out ${link("https://canary.discord.com/oauth2/authorize?client_id=571661221854707713", "Assyst", "Invite Assyst Bot")}.`,
|
|
image: {
|
|
url: "https://cdn.discordapp.com/attachments/1029331568315093043/1282814251005775902/attachment.gif?ex=66e0b95e&is=66df67de&hm=81087808fd9bcd31886050280cae535827c274efdf6d04a318a073c40dc5a554&"
|
|
}
|
|
}))
|
|
let image = await getRecentImage(context, 50)
|
|
if(!image) return editOrReply(context, createEmbed("warning", context, "No images found."))
|
|
|
|
await editOrReply(context, createEmbed("loading", context, `Generating image...`))
|
|
|
|
if(!args.text) args.text = ""
|
|
try {
|
|
const timings = Date.now();
|
|
let mkswt = await circuitBoard(image)
|
|
|
|
return await editOrReply(context, {
|
|
embeds: [createEmbed("image", context, {
|
|
url: "makesweet.gif",
|
|
time: ((Date.now() - timings) / 1000).toFixed(2),
|
|
provider: {
|
|
icon: STATICS.makesweet,
|
|
text: "MakeSweet"
|
|
}
|
|
})],
|
|
files: [{ filename: "makesweet.gif", value: mkswt.body }]
|
|
})
|
|
} catch (e) {
|
|
await editOrReply(context, createEmbed("error", context, e))
|
|
}
|
|
}
|
|
} |