foxwells.vinboard: fix webhook calls

This commit is contained in:
Cynthia Foxwell 2023-01-21 22:40:02 -07:00
parent 956e95b780
commit ea0cc9d4b4

View file

@ -239,12 +239,11 @@ async function createBoardMessage(msg, count, fetchAttachment = true) {
} }
return { return {
avatarURL: msg.member?.avatarURL ?? msg.author.avatarURL, avatar_url: msg.member?.avatarURL ?? msg.author.avatarURL,
username: msg.member?.displayName ?? msg.author.username, username: msg.member?.displayName ?? msg.author.username,
threadID: VINBOARD_THREAD_ID, thread_id: 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,
}; };
} }
@ -324,9 +323,9 @@ async function processReaction(_msg, reaction, user) {
); );
const props = { const props = {
avatarURL: _boardMessage.author.avatarURL("png", 256), avatar_url: _boardMessage.author.avatarURL,
username: _boardMessage.author.username, username: _boardMessage.author.username,
threadID: VINBOARD_THREAD_ID, thread_id: VINBOARD_THREAD_ID,
embeds: _boardMessage.embeds, embeds: _boardMessage.embeds,
wait: true, wait: true,
}; };
@ -335,25 +334,25 @@ async function processReaction(_msg, reaction, user) {
); );
props.embeds[0].title = `${trueCount} \u2b50`; props.embeds[0].title = `${trueCount} \u2b50`;
props.embeds[0].color = pastelize(msg.author.username); props.embeds[0].color = pastelize(msg.author.username);
await vinboard_webhook.editMessage(_boardMessage.id, props); await hf.bot.editWebhookMessage(vinboard_webhook.id, vinboard_webhook.token, _boardMessage.id, props);
await setBoardEntry(msg.id, trueCount, _boardMessage.id); 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}"`);
const boardMessage = await vinboard_webhook.execute( const boardMessage = await hf.bot.executeWebhook(vinboard_webhook.id, vinboard_webhook.token,
await createBoardMessage(msg, trueCount) await createBoardMessage(msg, trueCount)
); );
await setBoardEntry(msg.id, trueCount, boardMessage.id); 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}"`);
const boardMessage = await vinboard_webhook.execute( const boardMessage = await hf.bot.executeWebhook(vinboard_webhook.id, vinboard_webhook.token,
await createBoardMessage(msg, trueCount) await createBoardMessage(msg, trueCount)
); );
await setBoardEntry(msg.id, trueCount, boardMessage.id); 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}"`);
const boardMessage = await vinboard_webhook.execute( const boardMessage = await hf.bot.executeWebhook(vinboard_webhook.id, vinboard_webhook.token,
await createBoardMessage(msg, trueCount) await createBoardMessage(msg, trueCount)
); );
await setBoardEntry(msg.id, trueCount, boardMessage.id); await setBoardEntry(msg.id, trueCount, boardMessage.id);