Reverted caption, allow using a plain text username with userinfo

This commit is contained in:
TheEssem 2020-03-05 09:28:10 -06:00
parent c28c575b48
commit f87b1afb38
2 changed files with 19 additions and 5 deletions

View file

@ -8,9 +8,11 @@ exports.run = async (message, args) => {
if (image === undefined) return `${message.author.mention}, you need to provide an image/GIF to add a caption!`; if (image === undefined) return `${message.author.mention}, you need to provide an image/GIF to add a caption!`;
if (args.length === 0) return `${message.author.mention}, you need to provide some text to add a caption!`; if (args.length === 0) return `${message.author.mention}, you need to provide some text to add a caption!`;
const processMessage = await message.channel.createMessage("<a:processing:479351417102925854> Processing... This might take a while"); const processMessage = await message.channel.createMessage("<a:processing:479351417102925854> Processing... This might take a while");
const output = await gm(image.path).out("-size", "%[fx:w]x").background("white").fill("black").font("./assets/caption.otf", "%[fx:w/10]").out("-delete", "0--1").gravity("Center").out(`caption:${args.join(" ")}`).bufferPromise("png"); const size = await gm(image.path).sizePromise();
const output2 = await gm(output).out(image.path).gravity("Center").trim().out("+repage").extent("%[fx:v.w]", "%[fx:u.h + ( v.w/10 )]").out("-delete", "1--1").streamPromise(); const output = await gm().out("-size", `${size.width}x`).background("white").fill("black").font("./assets/caption.otf", size.width / 10).gravity("Center").out(`caption:${args.join(" ")}`).bufferPromise("png");
const outputFinal = await gm(output2).out("-alpha", "set").background("none").out("(").out(image.path).out("-coalesce").out(")").colorspace("sRGB").out("-set", "page", "%[fx:v.w]x%[fx:u.h+v.h]+%[fx:t?(u.w-v.w)/2:0]+%[fx:t?u.h:0]").out("-coalesce").out("null:").out("-insert", 1).out("-layers", "composite").bufferPromise(image.type); const size2 = await gm(output).sizePromise();
const output2 = await gm(output).gravity("Center").trim().out("+repage").extent(size.width, size2.height + (size.width / 10)).streamPromise();
const outputFinal = await gm(output2).out("-alpha", "set").background("none").out("(").out(image.path).out("-coalesce").out(")").colorspace("sRGB").out("-set", "page", "%[fx:u.w]x%[fx:u.h+v.h]+%[fx:t?(u.w-v.w)/2:0]+%[fx:t?u.h:0]").out("-coalesce").out("null:").out("-insert", 1).out("-layers", "composite").bufferPromise(image.type);
await processMessage.delete(); await processMessage.delete();
//return upload(message, outputFinal, `caption.${image.type}`); //return upload(message, outputFinal, `caption.${image.type}`);
return message.channel.createMessage("", { return message.channel.createMessage("", {

View file

@ -2,7 +2,19 @@ const client = require("../utils/client.js");
exports.run = async (message, args) => { exports.run = async (message, args) => {
const getUser = message.mentions.length >= 1 ? message.mentions[0] : (args.length !== 0 ? client.users.get(args[0]) : message.author); const getUser = message.mentions.length >= 1 ? message.mentions[0] : (args.length !== 0 ? client.users.get(args[0]) : message.author);
const user = getUser !== undefined ? getUser : message.author; let user;
if (getUser) {
user = getUser;
} else if (args.join(" ") !== "") {
const userRegex = new RegExp(args.join("|"), "i");
const member = client.users.find(element => {
return userRegex.test(element.username);
});
user = member ? member : message.author;
} else {
user = message.author;
}
//const user = getUser !== undefined ? getUser : (message.author);
const member = message.channel.guild.members.get(user.id); const member = message.channel.guild.members.get(user.id);
const infoEmbed = { const infoEmbed = {
"embed": { "embed": {