Duck
Duck
SIASapphire - Imagine a framework
Created by Duck on 12/16/2023 in #discordjs-support
Encountered error while handling an interaction handler run method for interaction-handler
For whatever reason if I send a reply immediately in the parse function of sapphire's interaction handler before it's sent to mine, it stops the error. :BRUH:
9 replies
SIASapphire - Imagine a framework
Created by Duck on 12/16/2023 in #discordjs-support
Encountered error while handling an interaction handler run method for interaction-handler
Weirdly enough I know how to stop the error, my interaction handler that runs preconditions on the interaction is the reason it's erroring. It doesn't error on my other interactions only in this specific scenario. I don't know why it's causing an unknown interaction error, if anyone knows anything about this error or wants to help please hmu
9 replies
SIASapphire - Imagine a framework
Created by Duck on 12/16/2023 in #discordjs-support
Encountered error while handling an interaction handler run method for interaction-handler
I tried a more basic approach by having the button handle a specific interaction.
export class BasicButton extends InteractionHandler {
public group: Group | undefined;

public constructor(ctx: LoaderContext, options: InteractionHandlerOptions) {
super(ctx, {
...options,
id: "group_basic",
name: "BasicButton",
interactionHandlerType: InteractionHandlerTypes.Button,
});
}

public override async validate(interaction: ButtonInteraction) {
// Check the group exists
const group = await getGroup(interaction.client, interaction, "basic");
if (!group) return this.none();

// Store the group
this.group = group;
return this.some();
}

public run(interaction: ButtonInteraction) {
// If the group is undefined then we should not run
if (!this.group) return;

// We can now run the command
return interaction.reply("test");
// return replyWithCommands(interaction, this.group.name);
}
}
export class BasicButton extends InteractionHandler {
public group: Group | undefined;

public constructor(ctx: LoaderContext, options: InteractionHandlerOptions) {
super(ctx, {
...options,
id: "group_basic",
name: "BasicButton",
interactionHandlerType: InteractionHandlerTypes.Button,
});
}

public override async validate(interaction: ButtonInteraction) {
// Check the group exists
const group = await getGroup(interaction.client, interaction, "basic");
if (!group) return this.none();

// Store the group
this.group = group;
return this.some();
}

public run(interaction: ButtonInteraction) {
// If the group is undefined then we should not run
if (!this.group) return;

// We can now run the command
return interaction.reply("test");
// return replyWithCommands(interaction, this.group.name);
}
}
No luck, same error. For those unaware, I have a wrapper on interaction handler that allows me to run preconditions through interactions.
9 replies
SIASapphire - Imagine a framework
Created by Duck on 12/16/2023 in #discordjs-support
Encountered error while handling an interaction handler run method for interaction-handler
Still having this issue and haven't figured out why just yet
9 replies
SIASapphire - Imagine a framework
Created by Duck on 12/16/2023 in #discordjs-support
Encountered error while handling an interaction handler run method for interaction-handler
And it is almost a direct copy of this which does work DuckRefreshButton.ts the button
public async run(interaction: ButtonInteraction) {
replyToInteraction(interaction);
}
public async run(interaction: ButtonInteraction) {
replyToInteraction(interaction);
}
replyToInteration.ts for the duck command
export async function replyToInteraction(
interaction: ChatInputCommandInteraction | MessageComponentInteraction
) {
await autoDeferReply(interaction);

// Buttons
const refreshButton = new ButtonBuilder() //
.setCustomId(duckRefreshButtonID)
.setLabel("New Duck")
.setStyle(ButtonStyle.Primary);

// Action builder
const row = new ActionRowBuilder<ButtonBuilder>() //
.addComponents(refreshButton);

// Embed builder
const embed = new EmbedBuilder() //
.setColor(0x2095ab)
.setAuthor({
name: interaction.user.username,
iconURL: interaction.user.displayAvatarURL(),
})
.setDescription("Oh look it's a Duck :DuckLove:");

// Retrieve the image
const duck = await fetchDuck(interaction, embed);
if (typeof duck === "string") {
embed.setImage(duck);
return sendDeferredResponse(interaction, {
embeds: [embed],
components: [row],
});
}
}
export async function replyToInteraction(
interaction: ChatInputCommandInteraction | MessageComponentInteraction
) {
await autoDeferReply(interaction);

// Buttons
const refreshButton = new ButtonBuilder() //
.setCustomId(duckRefreshButtonID)
.setLabel("New Duck")
.setStyle(ButtonStyle.Primary);

// Action builder
const row = new ActionRowBuilder<ButtonBuilder>() //
.addComponents(refreshButton);

// Embed builder
const embed = new EmbedBuilder() //
.setColor(0x2095ab)
.setAuthor({
name: interaction.user.username,
iconURL: interaction.user.displayAvatarURL(),
})
.setDescription("Oh look it's a Duck :DuckLove:");

// Retrieve the image
const duck = await fetchDuck(interaction, embed);
if (typeof duck === "string") {
embed.setImage(duck);
return sendDeferredResponse(interaction, {
embeds: [embed],
components: [row],
});
}
}
9 replies
SIASapphire - Imagine a framework
Created by Duck on 12/16/2023 in #discordjs-support
Encountered error while handling an interaction handler run method for interaction-handler
"discord.js": "^14.14.1",
2023-12-16 12:23:43 - ERROR - Encountered error while handling an interaction handler run method for interaction-handler "GroupButton" at path "C:\Users\askme\Desktop\testing-forbidden\dist\interaction-handlers\help\GroupButton.js" DiscordAPIError[10062]: Unknown interaction
2023-12-16 12:23:43 - ERROR - at handleErrors (C:\Users\askme\Desktop\testing-forbidden\node_modules\@discordjs\rest\dist\index.js:722:13)
2023-12-16 12:23:43 - ERROR - at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2023-12-16 12:23:43 - ERROR - at async BurstHandler.runRequest (C:\Users\askme\Desktop\testing-forbidden\node_modules\@discordjs\rest\dist\index.js:826:23)
2023-12-16 12:23:43 - ERROR - at async _REST.request (C:\Users\askme\Desktop\testing-forbidden\node_modules\@discordjs\rest\dist\index.js:1266:22)
2023-12-16 12:23:43 - ERROR - at async ButtonInteraction.reply (C:\Users\askme\Desktop\testing-forbidden\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:111:5)
2023-12-16 12:23:43 - ERROR - at async Object.fromAsync (C:\Users\askme\Desktop\testing-forbidden\node_modules\@sapphire\result\dist\index.js:613:22)
2023-12-16 12:23:43 - ERROR - at async Promise.allSettled (index 0)
2023-12-16 12:23:43 - ERROR - at async _InteractionHandlerStore.run (C:\Users\askme\Desktop\testing-forbidden\node_modules\@sapphire\framework\dist\lib\structures\InteractionHandlerStore.js:48:21)
2023-12-16 12:23:43 - ERROR - at async _CoreListener.run (C:\Users\askme\Desktop\testing-forbidden\node_modules\@sapphire\framework\dist\listeners\CoreInteractionCreate.js:21:7)
2023-12-16 12:23:43 - ERROR - at async Object.fromAsync (C:\Users\askme\Desktop\testing-forbidden\node_modules\@sapphire\result\dist\index.js:613:22) {
2023-12-16 12:23:43 - ERROR - requestBody: [Object],
2023-12-16 12:23:43 - ERROR - rawError: [Object],
2023-12-16 12:23:43 - ERROR - code: 10062,
2023-12-16 12:23:43 - ERROR - status: 404,
2023-12-16 12:23:43 - ERROR - method: 'POST',
2023-12-16 12:23:43 - ERROR - url: 'https://discord.com/api/v10/interactions/1185406840272588810/aW50ZXJhY3Rpb246MTE4NTQwNjg0MDI3MjU4ODgxMDpNSWNFaFZUc1l4YlNRd3dCa1g2UVRtRDZGWGNFV3d5d25nZFl5QXVyUU5yQnFnZ21CQ2N3bk8xWDlncTBQU1FORnl1eEtPcHJzaFM2bUVWQk1MNXZmNEU5eFVMeW9ScmJBZnBESWdGTGhRbmJHNnhZTVBUc3JnNW8zbmp0WVFiRA/callback'
2023-12-16 12:23:43 - ERROR - }
2023-12-16 12:23:43 - ERROR - Encountered error while handling an interaction handler run method for interaction-handler "GroupButton" at path "C:\Users\askme\Desktop\testing-forbidden\dist\interaction-handlers\help\GroupButton.js" DiscordAPIError[10062]: Unknown interaction
2023-12-16 12:23:43 - ERROR - at handleErrors (C:\Users\askme\Desktop\testing-forbidden\node_modules\@discordjs\rest\dist\index.js:722:13)
2023-12-16 12:23:43 - ERROR - at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2023-12-16 12:23:43 - ERROR - at async BurstHandler.runRequest (C:\Users\askme\Desktop\testing-forbidden\node_modules\@discordjs\rest\dist\index.js:826:23)
2023-12-16 12:23:43 - ERROR - at async _REST.request (C:\Users\askme\Desktop\testing-forbidden\node_modules\@discordjs\rest\dist\index.js:1266:22)
2023-12-16 12:23:43 - ERROR - at async ButtonInteraction.reply (C:\Users\askme\Desktop\testing-forbidden\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:111:5)
2023-12-16 12:23:43 - ERROR - at async Object.fromAsync (C:\Users\askme\Desktop\testing-forbidden\node_modules\@sapphire\result\dist\index.js:613:22)
2023-12-16 12:23:43 - ERROR - at async Promise.allSettled (index 0)
2023-12-16 12:23:43 - ERROR - at async _InteractionHandlerStore.run (C:\Users\askme\Desktop\testing-forbidden\node_modules\@sapphire\framework\dist\lib\structures\InteractionHandlerStore.js:48:21)
2023-12-16 12:23:43 - ERROR - at async _CoreListener.run (C:\Users\askme\Desktop\testing-forbidden\node_modules\@sapphire\framework\dist\listeners\CoreInteractionCreate.js:21:7)
2023-12-16 12:23:43 - ERROR - at async Object.fromAsync (C:\Users\askme\Desktop\testing-forbidden\node_modules\@sapphire\result\dist\index.js:613:22) {
2023-12-16 12:23:43 - ERROR - requestBody: [Object],
2023-12-16 12:23:43 - ERROR - rawError: [Object],
2023-12-16 12:23:43 - ERROR - code: 10062,
2023-12-16 12:23:43 - ERROR - status: 404,
2023-12-16 12:23:43 - ERROR - method: 'POST',
2023-12-16 12:23:43 - ERROR - url: 'https://discord.com/api/v10/interactions/1185406840272588810/aW50ZXJhY3Rpb246MTE4NTQwNjg0MDI3MjU4ODgxMDpNSWNFaFZUc1l4YlNRd3dCa1g2UVRtRDZGWGNFV3d5d25nZFl5QXVyUU5yQnFnZ21CQ2N3bk8xWDlncTBQU1FORnl1eEtPcHJzaFM2bUVWQk1MNXZmNEU5eFVMeW9ScmJBZnBESWdGTGhRbmJHNnhZTVBUc3JnNW8zbmp0WVFiRA/callback'
2023-12-16 12:23:43 - ERROR - }
9 replies
SIASapphire - Imagine a framework
Created by RedStar on 4/26/2023 in #sapphire-support
PaginatedMessage extended with editing the select menu options does not work as expected
Without actually executing it's hard to say precisely what it's doing but if you try comparing GenOptions and SubPage it might be more consistent
18 replies
SIASapphire - Imagine a framework
Created by RedStar on 4/26/2023 in #sapphire-support
PaginatedMessage extended with editing the select menu options does not work as expected
Here
if (
this.selectStringOptions.at(-1)!.index === 9 &&
this.genaratedOptions.length > 10
)
this.selectStringOptions.push({
label: `Continue to next page of ${SubPage + 2}/${GenOptions}`,
value: `+${this.displaySubPage}/${
chunk(this.genaratedOptions, 10).length
}`,
});
if (
this.selectStringOptions.at(-1)!.index === 9 &&
this.genaratedOptions.length > 10
)
this.selectStringOptions.push({
label: `Continue to next page of ${SubPage + 2}/${GenOptions}`,
value: `+${this.displaySubPage}/${
chunk(this.genaratedOptions, 10).length
}`,
});
Try replacing this.genaratedOptions.length > 10 with GenOptions > SubPage + 2
18 replies
SIASapphire - Imagine a framework
Created by RedStar on 4/26/2023 in #sapphire-support
PaginatedMessage extended with editing the select menu options does not work as expected
just the new one will do
18 replies
SIASapphire - Imagine a framework
Created by RedStar on 4/26/2023 in #sapphire-support
PaginatedMessage extended with editing the select menu options does not work as expected
It's hard to say without the rest of the file to give context
18 replies
SIASapphire - Imagine a framework
Created by RedStar on 4/26/2023 in #sapphire-support
PaginatedMessage extended with editing the select menu options does not work as expected
If it's the map causing issues
chunk(this.genaratedOptions, 10)[this.displaySubPage].map
chunk(this.genaratedOptions, 10)[this.displaySubPage].map
Then you are likely trying to access an item that doesn't exist
18 replies
SIASapphire - Imagine a framework
Created by RedStar on 4/26/2023 in #sapphire-support
PaginatedMessage extended with editing the select menu options does not work as expected
send the error
18 replies
SIASapphire - Imagine a framework
Created by Duck on 4/7/2023 in #sapphire-support
TypeError: Cannot read properties of undefined (reading 'write')
Yea you are supposed to import it from framework and not the plugin itself
10 replies
SIASapphire - Imagine a framework
Created by Duck on 4/7/2023 in #sapphire-support
TypeError: Cannot read properties of undefined (reading 'write')
I import the container in this instance, what are you doing specifically?
10 replies
SIASapphire - Imagine a framework
Created by Duck on 4/7/2023 in #sapphire-support
TypeError: Cannot read properties of undefined (reading 'write')
Actually I figured it out,
const result = await model.create(document).catch((error) => {
container.logger.error(error);
});
const result = await model.create(document).catch((error) => {
container.logger.error(error);
});
Doing .catch(container.logger.error) will just absolutely obliterate the logger lmao
10 replies
SIASapphire - Imagine a framework
Created by Duck on 4/7/2023 in #sapphire-support
TypeError: Cannot read properties of undefined (reading 'write')
Though it's annoying no other error appears before the logger so I don't know
10 replies
SIASapphire - Imagine a framework
Created by Duck on 4/7/2023 in #sapphire-support
TypeError: Cannot read properties of undefined (reading 'write')
I am thinking, maybe when it runs the insertDocument method, if it fails it might crash the logger
10 replies