Fix backfill script

This commit is contained in:
Cadence Ember
2026-02-11 12:21:41 +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)
+72 -69
View File
@@ -15,75 +15,77 @@ 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() {
name: "Matrix info", discord.snow.interaction.bulkOverwriteApplicationCommands(id, [{
contexts: [DiscordTypes.InteractionContextType.Guild], name: "Matrix info",
type: DiscordTypes.ApplicationCommandType.Message, contexts: [DiscordTypes.InteractionContextType.Guild],
}, { type: DiscordTypes.ApplicationCommandType.Message,
name: "Permissions", }, {
contexts: [DiscordTypes.InteractionContextType.Guild], name: "Permissions",
type: DiscordTypes.ApplicationCommandType.Message, contexts: [DiscordTypes.InteractionContextType.Guild],
default_member_permissions: String(DiscordTypes.PermissionFlagsBits.KickMembers | DiscordTypes.PermissionFlagsBits.ManageRoles) type: DiscordTypes.ApplicationCommandType.Message,
}, { default_member_permissions: String(DiscordTypes.PermissionFlagsBits.KickMembers | DiscordTypes.PermissionFlagsBits.ManageRoles)
name: "Responses", }, {
contexts: [DiscordTypes.InteractionContextType.Guild], name: "Responses",
type: DiscordTypes.ApplicationCommandType.Message contexts: [DiscordTypes.InteractionContextType.Guild],
}, { type: DiscordTypes.ApplicationCommandType.Message
name: "invite", }, {
contexts: [DiscordTypes.InteractionContextType.Guild], name: "invite",
type: DiscordTypes.ApplicationCommandType.ChatInput, contexts: [DiscordTypes.InteractionContextType.Guild],
description: "Invite a Matrix user to this Discord server", type: DiscordTypes.ApplicationCommandType.ChatInput,
default_member_permissions: String(DiscordTypes.PermissionFlagsBits.CreateInstantInvite), description: "Invite a Matrix user to this Discord server",
options: [ default_member_permissions: String(DiscordTypes.PermissionFlagsBits.CreateInstantInvite),
{ options: [
type: DiscordTypes.ApplicationCommandOptionType.String, {
description: "The Matrix user to invite, e.g. @username:example.org", type: DiscordTypes.ApplicationCommandOptionType.String,
name: "user" description: "The Matrix user to invite, e.g. @username:example.org",
} name: "user"
], }
}, { ],
name: "ping", }, {
contexts: [DiscordTypes.InteractionContextType.Guild], name: "ping",
type: DiscordTypes.ApplicationCommandType.ChatInput, contexts: [DiscordTypes.InteractionContextType.Guild],
description: "Ping a Matrix user.", type: DiscordTypes.ApplicationCommandType.ChatInput,
options: [ description: "Ping a Matrix user.",
{ options: [
type: DiscordTypes.ApplicationCommandOptionType.String, {
description: "Display name or ID of the Matrix user", type: DiscordTypes.ApplicationCommandOptionType.String,
name: "user", description: "Display name or ID of the Matrix user",
autocomplete: true, name: "user",
required: true autocomplete: true,
} required: true
] }
}, { ]
name: "privacy", }, {
contexts: [DiscordTypes.InteractionContextType.Guild], name: "privacy",
type: DiscordTypes.ApplicationCommandType.ChatInput, contexts: [DiscordTypes.InteractionContextType.Guild],
description: "Change whether Matrix users can join through direct invites, links, or the public directory.", type: DiscordTypes.ApplicationCommandType.ChatInput,
default_member_permissions: String(DiscordTypes.PermissionFlagsBits.ManageGuild), description: "Change whether Matrix users can join through direct invites, links, or the public directory.",
options: [ default_member_permissions: String(DiscordTypes.PermissionFlagsBits.ManageGuild),
{ options: [
type: DiscordTypes.ApplicationCommandOptionType.String, {
description: "Check or set the new privacy level", type: DiscordTypes.ApplicationCommandOptionType.String,
name: "level", description: "Check or set the new privacy level",
choices: [{ name: "level",
name: "❓️ Check the current privacy level and get more information.", choices: [{
value: "info" name: "❓️ Check the current privacy level and get more information.",
}, { value: "info"
name: "🤝 Only allow joining with a direct in-app invite from another user. No shareable invite links.", }, {
value: "invite" name: "🤝 Only allow joining with a direct in-app invite from another user. No shareable invite links.",
}, { value: "invite"
name: "🔗 Matrix links can be created and shared like Discord's invite links. In-app invites still work.", }, {
value: "link", name: "🔗 Matrix links can be created and shared like Discord's invite links. In-app invites still work.",
}, { value: "link",
name: "🌏️ Publicly visible in the Matrix directory, like Server Discovery. Invites and links still work.", }, {
value: "directory" name: "🌏️ Publicly visible in the Matrix directory, like Server Discovery. Invites and links still work.",
}] value: "directory"
} }]
] }
}]).catch(e => { ]
console.error(e) }]).catch(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