#error: A compatible class export was not found.

1 messages · Page 1 of 1 (latest)

vital coral
#

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
  }
}
split ospreyBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

vital coral
#

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
crude cedarBOT
#
  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?
  1. 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.

vital coral
#
  1. 5.2.1
src
├───commands
├───enums
├───interfaces
├───languages
│   └───en-US
├───listeners
└───structures
  1. No
  2. "module": "src/index.ts"
  3. Am using Bun
  4. N/A
#

My bad they were interaction-handlers and I had them in the folder meant fo listener's