Fix backfill script

This commit is contained in:
Cadence Ember
2026-02-11 12:21:54 +13:00
parent 6df931f848
commit 7ebe8aa042
4 changed files with 78 additions and 70 deletions
+1
View File
@@ -3,6 +3,7 @@ config.js
registration.yaml
ooye.db*
events.db*
backfill.db*
# Automatically generated
node_modules
+4 -1
View File
@@ -29,6 +29,9 @@ const DiscordClient = require("../src/d2m/discord-client")
const discord = new DiscordClient(reg.ooye.discord_token, "half")
passthrough.discord = discord
const {as} = require("../src/matrix/appservice")
passthrough.as = as
const orm = sync.require("../src/db/orm")
passthrough.from = orm.from
passthrough.select = orm.select
@@ -69,7 +72,7 @@ async function event(event) {
backfill: true,
...message
}
await eventDispatcher.onMessageCreate(discord, simulatedGatewayDispatchData)
await eventDispatcher.MESSAGE_CREATE(discord, simulatedGatewayDispatchData)
preparedInsert.run(channelID, message.id)
}
last = messages.at(-1)?.id
+1
View File
@@ -47,6 +47,7 @@ const utils = {
if (listen === "full") {
try {
interactions.registerInteractions()
await eventDispatcher.checkMissedExpressions(message.d)
await eventDispatcher.checkMissedPins(client, message.d)
await eventDispatcher.checkMissedMessages(client, message.d)
+11 -8
View File
@@ -15,20 +15,21 @@ const ping = sync.require("./interactions/ping.js")
// User must have EVERY permission in default_member_permissions to be able to use the command
discord.snow.interaction.bulkOverwriteApplicationCommands(id, [{
function registerInteractions() {
discord.snow.interaction.bulkOverwriteApplicationCommands(id, [{
name: "Matrix info",
contexts: [DiscordTypes.InteractionContextType.Guild],
type: DiscordTypes.ApplicationCommandType.Message,
}, {
}, {
name: "Permissions",
contexts: [DiscordTypes.InteractionContextType.Guild],
type: DiscordTypes.ApplicationCommandType.Message,
default_member_permissions: String(DiscordTypes.PermissionFlagsBits.KickMembers | DiscordTypes.PermissionFlagsBits.ManageRoles)
}, {
}, {
name: "Responses",
contexts: [DiscordTypes.InteractionContextType.Guild],
type: DiscordTypes.ApplicationCommandType.Message
}, {
}, {
name: "invite",
contexts: [DiscordTypes.InteractionContextType.Guild],
type: DiscordTypes.ApplicationCommandType.ChatInput,
@@ -41,7 +42,7 @@ discord.snow.interaction.bulkOverwriteApplicationCommands(id, [{
name: "user"
}
],
}, {
}, {
name: "ping",
contexts: [DiscordTypes.InteractionContextType.Guild],
type: DiscordTypes.ApplicationCommandType.ChatInput,
@@ -55,7 +56,7 @@ discord.snow.interaction.bulkOverwriteApplicationCommands(id, [{
required: true
}
]
}, {
}, {
name: "privacy",
contexts: [DiscordTypes.InteractionContextType.Guild],
type: DiscordTypes.ApplicationCommandType.ChatInput,
@@ -81,9 +82,10 @@ discord.snow.interaction.bulkOverwriteApplicationCommands(id, [{
}]
}
]
}]).catch(e => {
}]).catch(e => {
console.error(e)
})
})
}
/** @param {DiscordTypes.APIInteraction} interaction */
async function dispatchInteraction(interaction) {
@@ -147,3 +149,4 @@ async function dispatchInteraction(interaction) {
}
module.exports.dispatchInteraction = dispatchInteraction
module.exports.registerInteractions = registerInteractions