error: A compatible class export was not found.

My code
import {
InteractionHandler,
InteractionHandlerTypes,
} from "@sapphire/framework";
import type { ButtonInteraction } from "discord.js";
import { client } from "../index.js";
export class ButtonHandler extends InteractionHandler {
public constructor(
ctx: InteractionHandler.LoaderContext,
options: InteractionHandler.Options
) {
super(ctx, {
...options,
interactionHandlerType: InteractionHandlerTypes.Button,
});
}

public override async parse(interaction: ButtonInteraction) {
const buttonId = interaction.customId;
const [toDo, guildId, panelId, ticketModelId] = buttonId.split("-");
await interaction.deferReply({ ephemeral: true });
const guildData = await client.tickets.getGuild(guildId);
if (!guildData) {
{
interaction.editReply({
content: i18next.t("commands:error.unknown", {
warnEmoji: client.makeEmoji(EMOJI.WARNING),
}),
});
return this.none();
}
}
switch (toDo) {
case "ticketCreate": {
const ticketModel = guildData.ticketModels.find(
(ticketModel) =>
ticketModel.ticketModelId === parseInt(ticketModelId) &&
ticketModel.panelId === parseInt(panelId)
);
return this.some({ guildData, ticketModel });
}
default: {
return this.none();
}
}
}
public async run(
interaction: ButtonInteraction,
data: {
guildData: Prisma.GuildGetPayload<{
include: {
panels: true;
ticketModels: true;
tickets: true;
};
}>;
ticketModel: TicketModel;
}
) {
//redacted to save space
}
}
import {
InteractionHandler,
InteractionHandlerTypes,
} from "@sapphire/framework";
import type { ButtonInteraction } from "discord.js";
import { client } from "../index.js";
export class ButtonHandler extends InteractionHandler {
public constructor(
ctx: InteractionHandler.LoaderContext,
options: InteractionHandler.Options
) {
super(ctx, {
...options,
interactionHandlerType: InteractionHandlerTypes.Button,
});
}

public override async parse(interaction: ButtonInteraction) {
const buttonId = interaction.customId;
const [toDo, guildId, panelId, ticketModelId] = buttonId.split("-");
await interaction.deferReply({ ephemeral: true });
const guildData = await client.tickets.getGuild(guildId);
if (!guildData) {
{
interaction.editReply({
content: i18next.t("commands:error.unknown", {
warnEmoji: client.makeEmoji(EMOJI.WARNING),
}),
});
return this.none();
}
}
switch (toDo) {
case "ticketCreate": {
const ticketModel = guildData.ticketModels.find(
(ticketModel) =>
ticketModel.ticketModelId === parseInt(ticketModelId) &&
ticketModel.panelId === parseInt(panelId)
);
return this.some({ guildData, ticketModel });
}
default: {
return this.none();
}
}
}
public async run(
interaction: ButtonInteraction,
data: {
guildData: Prisma.GuildGetPayload<{
include: {
panels: true;
ticketModels: true;
tickets: true;
};
}>;
ticketModel: TicketModel;
}
) {
//redacted to save space
}
}
Solution:
My bad they were interaction-handlers and I had them in the folder meant fo listener's
Jump to solution
4 Replies
Tenjaou
TenjaouOP6mo ago
Error
Error when loading 'D:\old-drive\Source-Codes\Bots\TicketZ-bot\src\listeners\buttonHandler.ts': 9 | LoaderErrorType2["UnknownStore"] = "UNKNOWN_STORE";
10 | return LoaderErrorType2;
11 | })(LoaderErrorType || {});
12 | var _LoaderError = class _LoaderError extends Error {
13 | constructor(type, message) {
14 | super(message);
^
error: A compatible class export was not found. [D:\old-drive\Source-Codes\Bots\TicketZ-bot\src\listeners\buttonHandler.ts]
path: "D:\old-drive\Source-Codes\Bots\TicketZ-bot\src\listeners\buttonHandler.ts"
at new _LoaderError (D:\old-drive\Source-Codes\Bots\TicketZ-bot\node_modules\@sapphire\pieces\dist\esm\lib\errors\LoaderError.mjs:14:5)
at new _MissingExportsError (D:\old-drive\Source-Codes\Bots\TicketZ-bot\node_modules\@sapphire\pieces\dist\esm\lib\errors\MissingExportsError.mjs:6:5)
at D:\old-drive\Source-Codes\Bots\TicketZ-bot\node_modules\@sapphire\pieces\dist\esm\lib\strategies\LoaderStrategy.mjs:63:13
Error when loading 'D:\old-drive\Source-Codes\Bots\TicketZ-bot\src\listeners\buttonHandler.ts': 9 | LoaderErrorType2["UnknownStore"] = "UNKNOWN_STORE";
10 | return LoaderErrorType2;
11 | })(LoaderErrorType || {});
12 | var _LoaderError = class _LoaderError extends Error {
13 | constructor(type, message) {
14 | super(message);
^
error: A compatible class export was not found. [D:\old-drive\Source-Codes\Bots\TicketZ-bot\src\listeners\buttonHandler.ts]
path: "D:\old-drive\Source-Codes\Bots\TicketZ-bot\src\listeners\buttonHandler.ts"
at new _LoaderError (D:\old-drive\Source-Codes\Bots\TicketZ-bot\node_modules\@sapphire\pieces\dist\esm\lib\errors\LoaderError.mjs:14:5)
at new _MissingExportsError (D:\old-drive\Source-Codes\Bots\TicketZ-bot\node_modules\@sapphire\pieces\dist\esm\lib\errors\MissingExportsError.mjs:6:5)
at D:\old-drive\Source-Codes\Bots\TicketZ-bot\node_modules\@sapphire\pieces\dist\esm\lib\strategies\LoaderStrategy.mjs:63:13
Spinel
Spinel6mo ago
1. Which version of @sapphire/framework are you using? 2. What's your file/folder structure? 3. Did you use the CLI to generate your bot? 4. What's your main (CJS) or module (ESM) property in package.json 5. Are you using TypeScript? And if so, how are you compiling and running your code? That is to say, what are your build and startup scripts? - Did you remove your output folder and rebuild then try again? 6. Is your problem related to message commands? Did you add loadMessageCommandListeners to your SapphireClient options Remember that if you are new to @sapphire/framework it is important that you read the user guide.
Tenjaou
TenjaouOP6mo ago
1. 5.2.1 2.
src
├───commands
├───enums
├───interfaces
├───languages
│ └───en-US
├───listeners
└───structures
src
├───commands
├───enums
├───interfaces
├───languages
│ └───en-US
├───listeners
└───structures
3. No 4. "module": "src/index.ts" 5. Am using Bun 6. N/A
Solution
Tenjaou
Tenjaou6mo ago
My bad they were interaction-handlers and I had them in the folder meant fo listener's
Want results from more Discord servers?
Add your server