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 registration.yaml
ooye.db* ooye.db*
events.db* events.db*
backfill.db*
# Automatically generated # Automatically generated
node_modules 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") const discord = new DiscordClient(reg.ooye.discord_token, "half")
passthrough.discord = discord passthrough.discord = discord
const {as} = require("../src/matrix/appservice")
passthrough.as = as
const orm = sync.require("../src/db/orm") const orm = sync.require("../src/db/orm")
passthrough.from = orm.from passthrough.from = orm.from
passthrough.select = orm.select passthrough.select = orm.select
@@ -69,7 +72,7 @@ async function event(event) {
backfill: true, backfill: true,
...message ...message
} }
await eventDispatcher.onMessageCreate(discord, simulatedGatewayDispatchData) await eventDispatcher.MESSAGE_CREATE(discord, simulatedGatewayDispatchData)
preparedInsert.run(channelID, message.id) preparedInsert.run(channelID, message.id)
} }
last = messages.at(-1)?.id last = messages.at(-1)?.id
+1
View File
@@ -47,6 +47,7 @@ const utils = {
if (listen === "full") { if (listen === "full") {
try { try {
interactions.registerInteractions()
await eventDispatcher.checkMissedExpressions(message.d) await eventDispatcher.checkMissedExpressions(message.d)
await eventDispatcher.checkMissedPins(client, message.d) await eventDispatcher.checkMissedPins(client, message.d)
await eventDispatcher.checkMissedMessages(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 // 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", name: "Matrix info",
contexts: [DiscordTypes.InteractionContextType.Guild], contexts: [DiscordTypes.InteractionContextType.Guild],
type: DiscordTypes.ApplicationCommandType.Message, type: DiscordTypes.ApplicationCommandType.Message,
}, { }, {
name: "Permissions", name: "Permissions",
contexts: [DiscordTypes.InteractionContextType.Guild], contexts: [DiscordTypes.InteractionContextType.Guild],
type: DiscordTypes.ApplicationCommandType.Message, type: DiscordTypes.ApplicationCommandType.Message,
default_member_permissions: String(DiscordTypes.PermissionFlagsBits.KickMembers | DiscordTypes.PermissionFlagsBits.ManageRoles) default_member_permissions: String(DiscordTypes.PermissionFlagsBits.KickMembers | DiscordTypes.PermissionFlagsBits.ManageRoles)
}, { }, {
name: "Responses", name: "Responses",
contexts: [DiscordTypes.InteractionContextType.Guild], contexts: [DiscordTypes.InteractionContextType.Guild],
type: DiscordTypes.ApplicationCommandType.Message type: DiscordTypes.ApplicationCommandType.Message
}, { }, {
name: "invite", name: "invite",
contexts: [DiscordTypes.InteractionContextType.Guild], contexts: [DiscordTypes.InteractionContextType.Guild],
type: DiscordTypes.ApplicationCommandType.ChatInput, type: DiscordTypes.ApplicationCommandType.ChatInput,
@@ -41,7 +42,7 @@ discord.snow.interaction.bulkOverwriteApplicationCommands(id, [{
name: "user" name: "user"
} }
], ],
}, { }, {
name: "ping", name: "ping",
contexts: [DiscordTypes.InteractionContextType.Guild], contexts: [DiscordTypes.InteractionContextType.Guild],
type: DiscordTypes.ApplicationCommandType.ChatInput, type: DiscordTypes.ApplicationCommandType.ChatInput,
@@ -55,7 +56,7 @@ discord.snow.interaction.bulkOverwriteApplicationCommands(id, [{
required: true required: true
} }
] ]
}, { }, {
name: "privacy", name: "privacy",
contexts: [DiscordTypes.InteractionContextType.Guild], contexts: [DiscordTypes.InteractionContextType.Guild],
type: DiscordTypes.ApplicationCommandType.ChatInput, type: DiscordTypes.ApplicationCommandType.ChatInput,
@@ -81,9 +82,10 @@ discord.snow.interaction.bulkOverwriteApplicationCommands(id, [{
}] }]
} }
] ]
}]).catch(e => { }]).catch(e => {
console.error(e) console.error(e)
}) })
}
/** @param {DiscordTypes.APIInteraction} interaction */ /** @param {DiscordTypes.APIInteraction} interaction */
async function dispatchInteraction(interaction) { async function dispatchInteraction(interaction) {
@@ -147,3 +149,4 @@ async function dispatchInteraction(interaction) {
} }
module.exports.dispatchInteraction = dispatchInteraction module.exports.dispatchInteraction = dispatchInteraction
module.exports.registerInteractions = registerInteractions