Silver
Silver
Explore posts from servers
SIASapphire - Imagine a framework
Created by Silver on 11/23/2024 in #sapphire-support
Updating paginated message pages while the handler is running
I'm trying to make a paginated message that can be updated after its creation. My command currently: 1. Responds with the paginated message with data from the database 2. Fetches new data from an API in the background 3. Updates the pages of the paginated message with this new data I'm currently using the following code to handle the "background task" logic:
paginatedMessage.setPages([]);

for (const recordsChunk of chunk(records, 10)) {
// Add pages with information from the API to the paginated message
}

// Attempt to retain the page number of the paginated message with stale data
const pageIndex = Math.max(Math.min(paginatedMessage.index, paginatedMessage.pages.length - 1), 0);

const page = await paginatedMessage.resolvePage(paginatedMessage.response, user, pageIndex);

await safelyReplyToInteraction({
messageOrInteraction: paginatedMessage.response,
interactionEditReplyContent: page,
interactionReplyContent: { content: "This error should not be able to happen...", ephemeral: true },
componentUpdateContent: page,
messageMethod: "edit",
messageMethodContent: page,
});
paginatedMessage.setPages([]);

for (const recordsChunk of chunk(records, 10)) {
// Add pages with information from the API to the paginated message
}

// Attempt to retain the page number of the paginated message with stale data
const pageIndex = Math.max(Math.min(paginatedMessage.index, paginatedMessage.pages.length - 1), 0);

const page = await paginatedMessage.resolvePage(paginatedMessage.response, user, pageIndex);

await safelyReplyToInteraction({
messageOrInteraction: paginatedMessage.response,
interactionEditReplyContent: page,
interactionReplyContent: { content: "This error should not be able to happen...", ephemeral: true },
componentUpdateContent: page,
messageMethod: "edit",
messageMethodContent: page,
});
This works but after the update happens the components of the paginated message don't respond anymore and result in This interaction failed. Is there a different way to go about this? Because I essentially just need to reload/refresh the current page.
3 replies
DIAdiscord.js - Imagine an app
Created by Silver on 3/13/2024 in #djs-questions
Are forum posts supported for channel select menu default_values?
No description
10 replies
SIASapphire - Imagine a framework
Created by Silver on 8/21/2023 in #sapphire-support
Error: Module did not self-register
I'm getting this error when I run my tests for some reason, how can I solve this?
Error when loading '/path/to/project/dist/commands/developer/eval.js': Error: Module did not self-register: '/path/to/project/node_modules/.pnpm/@[email protected]/node_modules/@sapphire/type/prebuild/type-node-v108-darwin-arm64-unknown-unknown/type.node'.
at Object.Module._extensions..node (node:internal/modules/cjs/loader:1340:18)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Function.Module._load (node:internal/modules/cjs/loader:960:12)
at Module.require (node:internal/modules/cjs/loader:1143:19)
at require (node:internal/modules/cjs/helpers:121:18)
at Object.<anonymous> (/path/to/project/node_modules/.pnpm/@[email protected]/node_modules/@sapphire/type/src/index.ts:12:55)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Function.Module._load (node:internal/modules/cjs/loader:960:12) {
code: 'ERR_DLOPEN_FAILED'
}
Error when loading '/path/to/project/dist/commands/developer/eval.js': Error: Module did not self-register: '/path/to/project/node_modules/.pnpm/@[email protected]/node_modules/@sapphire/type/prebuild/type-node-v108-darwin-arm64-unknown-unknown/type.node'.
at Object.Module._extensions..node (node:internal/modules/cjs/loader:1340:18)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Function.Module._load (node:internal/modules/cjs/loader:960:12)
at Module.require (node:internal/modules/cjs/loader:1143:19)
at require (node:internal/modules/cjs/helpers:121:18)
at Object.<anonymous> (/path/to/project/node_modules/.pnpm/@[email protected]/node_modules/@sapphire/type/src/index.ts:12:55)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Function.Module._load (node:internal/modules/cjs/loader:960:12) {
code: 'ERR_DLOPEN_FAILED'
}
8 replies
SIASapphire - Imagine a framework
Created by Silver on 6/26/2023 in #sapphire-support
How can I bypass required user permissions?
I want developers to be able to bypass them I can probably override the parseConstructorPreConditionsRequiredUserPermissions method so it adds an extended/custom precondition but that's my last resort since it feels hacky
9 replies
SIASapphire - Imagine a framework
Created by Silver on 6/24/2023 in #sapphire-support
I'm not receiving any Context Menu Command interactions
6 replies