mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-10 07:03:08 -04:00
38 lines
No EOL
1.4 KiB
JavaScript
38 lines
No EOL
1.4 KiB
JavaScript
const { getRecentImage } = require("../../../../labscore/utils/attachment");
|
|
const { createEmbed } = require("../../../../labscore/utils/embed");
|
|
const { editOrReply } = require("../../../../labscore/utils/message");
|
|
|
|
const { waifu2x } = require('../../../../labscore/api')
|
|
|
|
const { Permissions } = require("detritus-client/lib/constants");
|
|
|
|
module.exports = {
|
|
name: 'waifu2x',
|
|
aliases: ['w2x'],
|
|
metadata: {
|
|
description: 'Processes an image with Waifu2x.',
|
|
description_short: 'Waifu2x upscaling',
|
|
category: 'image',
|
|
usage: 'waifu2x <image>'
|
|
},
|
|
permissionsClient: [Permissions.EMBED_LINKS, Permissions.SEND_MESSAGES, Permissions.USE_EXTERNAL_EMOJIS, Permissions.ATTACH_FILES, Permissions.READ_MESSAGE_HISTORY],
|
|
run: async (context) => {
|
|
context.triggerTyping();
|
|
try{
|
|
let image = await getRecentImage(context, 50)
|
|
if(!image) return editOrReply(context, createEmbed("warning", context, "No images found."))
|
|
|
|
let res = await waifu2x(context, image)
|
|
|
|
if(res.response.body.status == 1) return editOrReply(context, createEmbed("warning", context, res.response.body.errors[0]))
|
|
|
|
return editOrReply(context, createEmbed("image", context, {
|
|
url: res.response.body.image,
|
|
time: res.timings
|
|
}))
|
|
}catch(e){
|
|
console.log(e)
|
|
return editOrReply(context, createEmbed("error", context, `Waifu2x timed out.`))
|
|
}
|
|
},
|
|
}; |