mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-08 06:03:04 -04:00
[cmd] screenshot
This commit is contained in:
parent
2498e8ac93
commit
35b16e22b1
1 changed files with 51 additions and 0 deletions
51
commands/message/utils/screenshot.js
Normal file
51
commands/message/utils/screenshot.js
Normal file
|
@ -0,0 +1,51 @@
|
|||
const { screenshot } = require("../../../labscore/api");
|
||||
const { createEmbed } = require("../../../labscore/utils/embed");
|
||||
const { editOrReply } = require("../../../labscore/utils/message");
|
||||
|
||||
module.exports = {
|
||||
label: "url",
|
||||
name: "screenshot",
|
||||
aliases: ['ss'],
|
||||
metadata: {
|
||||
description: 'screenshot website',
|
||||
examples: ['ss google.com'],
|
||||
category: 'util',
|
||||
usage: 'screenshot <url>'
|
||||
},
|
||||
run: async (context, args) => {
|
||||
context.triggerTyping();
|
||||
if(!args.url) return editOrReply(context, { embeds: [createEmbed("warning", context, "No images found.")] })
|
||||
try{
|
||||
let ss = await screenshot(context, args.url)
|
||||
if(ss.response.body.status){
|
||||
if(ss.response.body.image){ // Invalid Domain or Blocked, use server-provided error image.
|
||||
return editOrReply(context, { embeds: [createEmbed("default", context, {
|
||||
image: {
|
||||
url: ss.response.body.image
|
||||
},
|
||||
footer: {
|
||||
iconUrl: `https://cdn.discordapp.com/avatars/${context.application.id}/${context.application.icon}.png?size=256`,
|
||||
text: `${context.application.name} • Took ${ss.timings}s`
|
||||
}
|
||||
})]})
|
||||
} else {
|
||||
return editOrReply(context, { embeds: [createEmbed("error", context, "Unable to create screenshot.")] })
|
||||
}
|
||||
}
|
||||
return editOrReply(context, { embeds: [createEmbed("default", context, {
|
||||
image: {
|
||||
url: `attachment://screenshot.png`
|
||||
},
|
||||
footer: {
|
||||
iconUrl: `https://cdn.discordapp.com/avatars/${context.application.id}/${context.application.icon}.png?size=256`,
|
||||
text: `${context.application.name} • Took ${ss.timings}s`
|
||||
}
|
||||
})], files: [{
|
||||
filename: "screenshot.png",
|
||||
value: ss.response.body
|
||||
}]})
|
||||
} catch(e){
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue