misc.generate: pretty embeds

This commit is contained in:
Cynthia Foxwell 2022-07-04 19:36:06 -06:00
parent b15bcfbdf3
commit 8f016f7361

View file

@ -419,16 +419,27 @@ generate.callback = async function (msg, line) {
}
const data = await request.json();
const images = data.images.map((img) => Buffer.from(img, "base64"));
const images = data.images
.map((img) => Buffer.from(img, "base64"))
.map((img, index) => ({file: img, name: `${index}.jpg`}));
const title = `Responses for "${safeString(line)}"`;
const out = {
embeds: [],
file: images,
};
for (const index in images) {
const img = images[index];
await msg.channel.createMessage(
`Response ${Number(index) + 1} for \`${safeString(line)}\`:`,
{file: img, name: `${index}.jpg`}
);
out.embeds.push({
title,
url: "https://www.craiyon.com",
image: {
url: `attachment://${index}.jpg`,
},
});
}
return null;
return out;
};
hf.registerCommand(generate);