misc.generate: pretty embeds
This commit is contained in:
		
							parent
							
								
									b15bcfbdf3
								
							
						
					
					
						commit
						8f016f7361
					
				
					 1 changed files with 18 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -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);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue