foxwells.vinboard: .
This commit is contained in:
		
							parent
							
								
									069e0f57b7
								
							
						
					
					
						commit
						84ddbce959
					
				
					 1 changed files with 21 additions and 12 deletions
				
			
		| 
						 | 
				
			
			@ -207,7 +207,7 @@ async function findSuitableImage(msg) {
 | 
			
		|||
  return out;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
async function createBoardMessage(msg, count) {
 | 
			
		||||
async function createBoardMessage(msg, count, fetchAttachment = true) {
 | 
			
		||||
  const embed = {
 | 
			
		||||
    title: `${count} \u2b50`,
 | 
			
		||||
    color: getTopColor(msg, msg.author.id, pastelize(msg.author.id)),
 | 
			
		||||
| 
						 | 
				
			
			@ -221,7 +221,9 @@ async function createBoardMessage(msg, count) {
 | 
			
		|||
    timestamp: msg.timestamp,
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  const image = await findSuitableImage(msg);
 | 
			
		||||
  let image;
 | 
			
		||||
  if (fetchAttachment) {
 | 
			
		||||
    image = await findSuitableImage(msg);
 | 
			
		||||
    if (image.url) {
 | 
			
		||||
      if (image.video) {
 | 
			
		||||
        embed.description += `\n(contains video ${
 | 
			
		||||
| 
						 | 
				
			
			@ -232,6 +234,7 @@ async function createBoardMessage(msg, count) {
 | 
			
		|||
        url: image.url,
 | 
			
		||||
      };
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return {
 | 
			
		||||
    avatarURL:
 | 
			
		||||
| 
						 | 
				
			
			@ -239,7 +242,7 @@ async function createBoardMessage(msg, count) {
 | 
			
		|||
    username: msg.member?.displayName ?? msg.author.username,
 | 
			
		||||
    threadID: VINBOARD_THREAD_ID,
 | 
			
		||||
    embeds: [embed],
 | 
			
		||||
    files: image.file ? [{contents: image.file, name: "thumb.jpg"}] : null,
 | 
			
		||||
    files: image?.file ? [{contents: image.file, name: "thumb.jpg"}] : null,
 | 
			
		||||
    wait: true,
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -319,7 +322,7 @@ async function processReaction(_msg, user, reaction) {
 | 
			
		|||
          } -> ${trueCount})`
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        const props = await createBoardMessage(msg, trueCount);
 | 
			
		||||
        const props = await createBoardMessage(msg, trueCount, false);
 | 
			
		||||
        props.attachments = [..._boardMessage.attachments.values()];
 | 
			
		||||
        await vinboard_webhook.editMessage(_boardMessage.id, props);
 | 
			
		||||
        await setBoardEntry(msg.id, trueCount, _boardMessage.id);
 | 
			
		||||
| 
						 | 
				
			
			@ -330,6 +333,12 @@ async function processReaction(_msg, user, reaction) {
 | 
			
		|||
        );
 | 
			
		||||
        await setBoardEntry(msg.id, trueCount, boardMessage.id);
 | 
			
		||||
      }
 | 
			
		||||
    } else {
 | 
			
		||||
      logger.verbose("vinboard", `Creating entry for "${msg.id}"`);
 | 
			
		||||
      const boardMessage = await vinboard_webhook.execute(
 | 
			
		||||
        await createBoardMessage(msg, trueCount)
 | 
			
		||||
      );
 | 
			
		||||
      await setBoardEntry(msg.id, trueCount, boardMessage.id);
 | 
			
		||||
    }
 | 
			
		||||
  } else {
 | 
			
		||||
    logger.verbose("vinboard", `Creating entry for "${msg.id}"`);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue