foxwells.vinboard: ensure we have a good message object
This commit is contained in:
parent
cb032899b8
commit
f53222e0ea
1 changed files with 20 additions and 4 deletions
|
@ -248,14 +248,30 @@ async function createBoardMessage(msg, count) {
|
|||
}
|
||||
|
||||
let vinboard_webhook;
|
||||
async function processReaction(msg, user, reaction) {
|
||||
if (msg.guildID != FOXWELLS_GUILD_ID) return;
|
||||
if (msg.channel.id != VINBOARD_CHANNEL_ID) return;
|
||||
let vin_channel;
|
||||
async function processReaction(_msg, user, reaction) {
|
||||
if (_msg.guildID != FOXWELLS_GUILD_ID) return;
|
||||
if (_msg.channel.id != VINBOARD_CHANNEL_ID) return;
|
||||
if (user.bot) return;
|
||||
if (reaction.name != "\u2b50") return;
|
||||
|
||||
if (!vin_channel) {
|
||||
vin_channel = hf.bot.guilds
|
||||
.get(FOXWELLS_GUILD_ID)
|
||||
.channels.get(VINBOARD_CHANNEL_ID);
|
||||
}
|
||||
|
||||
if (!vin_channel) {
|
||||
logger.error("vinboard", "Failed to get channel.");
|
||||
return;
|
||||
}
|
||||
|
||||
const msg =
|
||||
vin_channel.messages.get(_msg.id) ??
|
||||
(await vin_channel.getMessage(_msg.id));
|
||||
|
||||
if (!vinboard_webhook) {
|
||||
const webhooks = await msg.channel.getWebhooks();
|
||||
const webhooks = await vin_channel.getWebhooks();
|
||||
vinboard_webhook = webhooks.find(
|
||||
(webhook) => webhook.id == VINBOARD_WEBHOOK_ID
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue