Added screenshot, fixed coalesce issue with gamexplain
This commit is contained in:
parent
c0bbc1533c
commit
5e394d101d
7 changed files with 315 additions and 17 deletions
|
@ -11,7 +11,7 @@ exports.run = async (message) => {
|
|||
const template = "./assets/images/gamexplain.png";
|
||||
const path = `/tmp/${Math.random().toString(36).substring(2, 15)}.${image.type}`;
|
||||
require("util").promisify(fs.writeFile)(path, image.data);
|
||||
const command = gm(template).background("white").out("null:").out("(").out(path).out("-virtual-pixel", "transparent").resize("1181x571!").coalesce().out(")").compose("over").gravity("Center").out("-geometry", "+0+40").out("-layers", "composite").out("-layers", "optimize");
|
||||
const command = gm(template).background("white").out("null:").out("(").out(path).coalesce().out("-virtual-pixel", "transparent").resize("1181x571!").out(")").compose("over").gravity("Center").out("-geometry", "+0+40").out("-layers", "composite").out("-layers", "optimize");
|
||||
return message.channel.createMessage("", {
|
||||
file: await gmToBuffer(command, image.type),
|
||||
name: `gamexplain.${image.type}`
|
||||
|
|
30
commands/screenshot.js
Normal file
30
commands/screenshot.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
const urlRegex = /(?:\w+:)?\/\/(\S+)/;
|
||||
const puppeteer = require("puppeteer-core");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
exports.run = async (message, args) => {
|
||||
message.channel.sendTyping();
|
||||
if (args.length === 0) return `${message.author.mention}, you need to provide a URL to screenshot!`;
|
||||
const getEndpoint = await fetch("http://192.168.99.100:9222/json/version");
|
||||
const endpoint = await getEndpoint.json();
|
||||
const url = urlRegex.test(args[0]) ? args[0] : `http://${args[0]}`;
|
||||
const browser = await puppeteer.connect({
|
||||
browserWSEndpoint: endpoint.webSocketDebuggerUrl,
|
||||
defaultViewport: {
|
||||
width: 1280,
|
||||
height: 720
|
||||
}
|
||||
});
|
||||
const page = await browser.newPage();
|
||||
await page.goto(url);
|
||||
const screenshot = await page.screenshot();
|
||||
await page.close();
|
||||
return message.channel.createMessage("", {
|
||||
file: screenshot,
|
||||
name: "screenshot.png"
|
||||
});
|
||||
};
|
||||
|
||||
exports.aliases = ["webshot", "ss", "shot", "page"];
|
||||
exports.category = 5;
|
||||
exports.help = "Screenshots a webpage";
|
Loading…
Add table
Add a link
Reference in a new issue