forked from cadence/out-of-your-element
Compare commits
No commits in common. "feature/backfill-create-rooms" and "main" have entirely different histories.
feature/ba
...
main
1 changed files with 6 additions and 14 deletions
|
|
@ -38,8 +38,12 @@ passthrough.select = orm.select
|
||||||
|
|
||||||
/** @type {import("../src/d2m/event-dispatcher")}*/
|
/** @type {import("../src/d2m/event-dispatcher")}*/
|
||||||
const eventDispatcher = sync.require("../src/d2m/event-dispatcher")
|
const eventDispatcher = sync.require("../src/d2m/event-dispatcher")
|
||||||
/** @type {import("../src/d2m/actions/create-room")} */
|
|
||||||
const createRoom = sync.require("../src/d2m/actions/create-room")
|
const roomID = passthrough.select("channel_room", "room_id", {channel_id: channelID}).pluck().get()
|
||||||
|
if (!roomID) {
|
||||||
|
console.error("Please choose a channel that's already bridged.")
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
;(async () => {
|
;(async () => {
|
||||||
await discord.cloud.connect()
|
await discord.cloud.connect()
|
||||||
|
|
@ -56,18 +60,6 @@ async function event(event) {
|
||||||
if (!channel) return
|
if (!channel) return
|
||||||
const guild_id = event.d.id
|
const guild_id = event.d.id
|
||||||
|
|
||||||
let roomID = passthrough.select("channel_room", "room_id", {channel_id: channelID}).pluck().get()
|
|
||||||
if (!roomID) {
|
|
||||||
console.log(`Channel #${channel.name} is not bridged yet. Attempting to auto-create...`)
|
|
||||||
try {
|
|
||||||
roomID = await createRoom.syncRoom(channelID)
|
|
||||||
console.log(`Successfully bridged to new room: ${roomID}`)
|
|
||||||
} catch (e) {
|
|
||||||
console.error(`Failed to auto-create room: ${e.message}`)
|
|
||||||
process.exit(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let last = backfill.prepare("SELECT cast(max(message_id) as TEXT) FROM backfill WHERE channel_id = ?").pluck().get(channelID) || "0"
|
let last = backfill.prepare("SELECT cast(max(message_id) as TEXT) FROM backfill WHERE channel_id = ?").pluck().get(channelID) || "0"
|
||||||
console.log(`OK, processing messages for #${channel.name}, continuing from ${last}`)
|
console.log(`OK, processing messages for #${channel.name}, continuing from ${last}`)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue