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;
 | 
					  return out;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
async function createBoardMessage(msg, count) {
 | 
					async function createBoardMessage(msg, count, fetchAttachment = true) {
 | 
				
			||||||
  const embed = {
 | 
					  const embed = {
 | 
				
			||||||
    title: `${count} \u2b50`,
 | 
					    title: `${count} \u2b50`,
 | 
				
			||||||
    color: getTopColor(msg, msg.author.id, pastelize(msg.author.id)),
 | 
					    color: getTopColor(msg, msg.author.id, pastelize(msg.author.id)),
 | 
				
			||||||
| 
						 | 
					@ -221,16 +221,19 @@ async function createBoardMessage(msg, count) {
 | 
				
			||||||
    timestamp: msg.timestamp,
 | 
					    timestamp: msg.timestamp,
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const image = await findSuitableImage(msg);
 | 
					  let image;
 | 
				
			||||||
  if (image.url) {
 | 
					  if (fetchAttachment) {
 | 
				
			||||||
    if (image.video) {
 | 
					    image = await findSuitableImage(msg);
 | 
				
			||||||
      embed.description += `\n(contains video ${
 | 
					    if (image.url) {
 | 
				
			||||||
        image.attachment ? "attachment" : "embed"
 | 
					      if (image.video) {
 | 
				
			||||||
      })`;
 | 
					        embed.description += `\n(contains video ${
 | 
				
			||||||
 | 
					          image.attachment ? "attachment" : "embed"
 | 
				
			||||||
 | 
					        })`;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      embed.image = {
 | 
				
			||||||
 | 
					        url: image.url,
 | 
				
			||||||
 | 
					      };
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    embed.image = {
 | 
					 | 
				
			||||||
      url: image.url,
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return {
 | 
					  return {
 | 
				
			||||||
| 
						 | 
					@ -239,7 +242,7 @@ async function createBoardMessage(msg, count) {
 | 
				
			||||||
    username: msg.member?.displayName ?? msg.author.username,
 | 
					    username: msg.member?.displayName ?? msg.author.username,
 | 
				
			||||||
    threadID: VINBOARD_THREAD_ID,
 | 
					    threadID: VINBOARD_THREAD_ID,
 | 
				
			||||||
    embeds: [embed],
 | 
					    embeds: [embed],
 | 
				
			||||||
    files: image.file ? [{contents: image.file, name: "thumb.jpg"}] : null,
 | 
					    files: image?.file ? [{contents: image.file, name: "thumb.jpg"}] : null,
 | 
				
			||||||
    wait: true,
 | 
					    wait: true,
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -319,7 +322,7 @@ async function processReaction(_msg, user, reaction) {
 | 
				
			||||||
          } -> ${trueCount})`
 | 
					          } -> ${trueCount})`
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const props = await createBoardMessage(msg, trueCount);
 | 
					        const props = await createBoardMessage(msg, trueCount, false);
 | 
				
			||||||
        props.attachments = [..._boardMessage.attachments.values()];
 | 
					        props.attachments = [..._boardMessage.attachments.values()];
 | 
				
			||||||
        await vinboard_webhook.editMessage(_boardMessage.id, props);
 | 
					        await vinboard_webhook.editMessage(_boardMessage.id, props);
 | 
				
			||||||
        await setBoardEntry(msg.id, trueCount, _boardMessage.id);
 | 
					        await setBoardEntry(msg.id, trueCount, _boardMessage.id);
 | 
				
			||||||
| 
						 | 
					@ -330,6 +333,12 @@ async function processReaction(_msg, user, reaction) {
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
        await setBoardEntry(msg.id, trueCount, boardMessage.id);
 | 
					        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 {
 | 
					  } else {
 | 
				
			||||||
    logger.verbose("vinboard", `Creating entry for "${msg.id}"`);
 | 
					    logger.verbose("vinboard", `Creating entry for "${msg.id}"`);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue