Crosspost vrctl events to vrc channel with own reminders
This commit is contained in:
@@ -2,6 +2,7 @@ const { Events } = require('discord.js');
|
||||
const axios = require('axios').default;
|
||||
|
||||
const SWARM_EVENTS_CHANNEL_ID = '1536067515115905155';
|
||||
const VRC_CROSSPOST_CHANNEL_ID = '1438261670916133055';
|
||||
const VRC_TL_EVENT_REGEX = /https:\/\/vrc\.tl\/event\/(\d+)/g;
|
||||
const REMINDER_EMOTE = '🔔';
|
||||
|
||||
@@ -44,16 +45,28 @@ module.exports = {
|
||||
lines.push(`Group: ${event.urls.vrcGroup}`);
|
||||
}
|
||||
|
||||
lines.push(`\nReact with ${REMINDER_EMOTE} to get pinged 1 hour before this starts.`);
|
||||
|
||||
const reply = await message.reply(lines.join('\n'));
|
||||
await reply.react(REMINDER_EMOTE);
|
||||
|
||||
const reminderPrompt = `\nReact with ${REMINDER_EMOTE} to get pinged 1 hour before this starts.`;
|
||||
const db = await message.client.localDB;
|
||||
|
||||
const reply = await message.reply([...lines, reminderPrompt].join('\n'));
|
||||
await reply.react(REMINDER_EMOTE);
|
||||
db.prepare(`
|
||||
INSERT INTO vrctl_event_reminders (vrctl_event_id, message_id, channel_id, event_name, event_start)
|
||||
VALUES (?, ?, ?, ?, ?)
|
||||
`).run(eventId, reply.id, reply.channel.id, event.name, event.start);
|
||||
|
||||
try {
|
||||
const crosspostChannel = await message.client.channels.fetch(VRC_CROSSPOST_CHANNEL_ID);
|
||||
const crosspostLines = [...lines, `Link: https://vrc.tl/event/${eventId}`, reminderPrompt];
|
||||
const crosspost = await crosspostChannel.send(crosspostLines.join('\n'));
|
||||
await crosspost.react(REMINDER_EMOTE);
|
||||
db.prepare(`
|
||||
INSERT INTO vrctl_event_reminders (vrctl_event_id, message_id, channel_id, event_name, event_start)
|
||||
VALUES (?, ?, ?, ?, ?)
|
||||
`).run(eventId, crosspost.id, crosspost.channel.id, event.name, event.start);
|
||||
} catch (crosspostError) {
|
||||
console.error(`Failed to crosspost vrc.tl event ${eventId} to vrc channel:`, crosspostError);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Failed to fetch vrc.tl event ${eventId}:`, error?.response?.data ?? error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user