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;
|
let vinboard_webhook;
|
||||||
async function processReaction(msg, user, reaction) {
|
let vin_channel;
|
||||||
if (msg.guildID != FOXWELLS_GUILD_ID) return;
|
async function processReaction(_msg, user, reaction) {
|
||||||
if (msg.channel.id != VINBOARD_CHANNEL_ID) return;
|
if (_msg.guildID != FOXWELLS_GUILD_ID) return;
|
||||||
|
if (_msg.channel.id != VINBOARD_CHANNEL_ID) return;
|
||||||
if (user.bot) return;
|
if (user.bot) return;
|
||||||
if (reaction.name != "\u2b50") 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) {
|
if (!vinboard_webhook) {
|
||||||
const webhooks = await msg.channel.getWebhooks();
|
const webhooks = await vin_channel.getWebhooks();
|
||||||
vinboard_webhook = webhooks.find(
|
vinboard_webhook = webhooks.find(
|
||||||
(webhook) => webhook.id == VINBOARD_WEBHOOK_ID
|
(webhook) => webhook.id == VINBOARD_WEBHOOK_ID
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue