type 2 collector for my typescript discord js project

i have tryed to make 2 collector (first in selectMenuBuilder, and second as a ButtonBuilder)
my code :

 const selectCollector = reply.createMessageComponentCollector({
                filter: collectorFilter,
                time: 60000,
                componentType: ComponentType.StringSelect,
                max: 1
            });
            selectCollector.on('collect', async (i) => {
                const value = i.values[0];
                if (value === "AllStats") {
                    const embed = new EmbedBuilder()
                        .setTitle("AllStats")
                        .setDescription("Voulez vous activé le module allStats ?")
                        .setColor("#FF0000")
                    const acceptButton = new ButtonBuilder()
                        .setCustomId("acceptAllStats")
                        .setLabel("Oui")
                        .setStyle(ButtonStyle.Success)
                    const refuseButton = new ButtonBuilder()
                        .setCustomId("refuseAllStats")
                        .setLabel("Non")
                        .setStyle(ButtonStyle.Danger)
                    const row = new ActionRowBuilder<ButtonBuilder>()
                        .addComponents(acceptButton, refuseButton);
                    const allStatsButton = await command.editReply({ embeds: , components: [row] });
                    const buttonCollector = allStatsButton.createMessageComponentCollector({
                        filter: collectorFilter,
                        time: 60000,
                        componentType: ComponentType.Button
                    });
                    buttonCollector.on('collect', async (i) => {
                        const customId = i.customId;
                        const discordId = command.guildId;
                        if (discordId === null) {
                            return await command.editReply({ content: "Une erreur est survenue" });
                        }
                        let db = await prisma.botConfig.findUnique({ where: { discordId: discordId } })
                        if (db === null) {
                            db = await prisma.botConfig.create({ data: { discordId: discordId, allStats: false } })
                        }
                        if (customId === "acceptAllStats") {
                            await prisma.botConfig.update({ where: { discordId: discordId }, data: { allStats: true } })
                            await command.editReply({ content: "Vous avez accepté l'activation du module allStats", components: [], embeds: [] })
                        } else if (customId === "refuseAllStats") {
                            await prisma.botConfig.update({ where: { discordId: discordId }, data: { allStats: false } })
                            await command.editReply({ content: "Vous avez refusé l'activation du module allStats", components: [], embeds: [] })
                        }
                    })
                }

i have this error with i make the npm run build :

src/addons/minecraftAddon/interactions/commands/mAddonConfig.ts:68:21 - error TS2769: No overload matches this call.
  Overload 1 of 3, '(event: "end", listener: (collected: Collection<string, ButtonInteraction<CacheType>>, reason: string) => Awaitable<void>): InteractionCollector<...>', gave the following error.
    Argument of type '"collect"' is not assignable to parameter of type '"end"'.
  Overload 2 of 3, '(event: "ignore" | "dispose" | "collect", listener: (interaction: ButtonInteraction<CacheType>) => Awaitable<void>): InteractionCollector<ButtonInteraction<CacheType>>', gave the following error.
    Argument of type '(i: ButtonInteraction<CacheType>) => Promise<Message<boolean> | undefined>' is not assignable to parameter of type '(interaction: ButtonInteraction<CacheType>) => Awaitable<void>'.
      Type 'Promise<Message<boolean> | undefined>' is not assignable to type 'Awaitable<void>'.
        Type 'Promise<Message<boolean> | undefined>' is not assignable to type 'PromiseLike<void>'.
          Types of property 'then' are incompatible.
            Type '<TResult1 = Message<boolean> | undefined, TResult2 = never>(onfulfilled?: ((value: Message<boolean> | undefined) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<...>) | ... 1 more ... | undefined) => Promise<...>' is not assignable to type '<TResult1 = void, TResult2 = never>(onfulfilled?: ((value: void) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<...>) | null | undefined) => PromiseLike<...>'.
              Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible.
                Types of parameters 'value' and 'value' are incompatible.
                  Type 'Message<boolean> | undefined' is not assignable to type 'void'.
                    Type 'Message<boolean>' is not assignable to type 'void'.
  Overload 3 of 3, '(event: string, listener: (...args: any[]) => Awaitable<void>): InteractionCollector<ButtonInteraction<CacheType>>', gave the following error.
    Argument of type '(i: ButtonInteraction<CacheType>) => Promise<Message<boolean> | undefined>' is not assignable to parameter of type '(...args: any[]) => Awaitable<void>'.
      Type 'Promise<Message<boolean> | undefined>' is not assignable to type 'Awaitable<void>'.

 68                     buttonCollector.on('collect', async (i) => {
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 69                         const customId = i.customId;
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
 84                         }
    ~~~~~~~~~~~~~~~~~~~~~~~~~
 85                     })
    ~~~~~~~~~~~~~~~~~~~~~~



Found 1 error.

its possible to help me ? I tried to put typing in the code but nothing works. I don’t understand why this does this to me. I potentially saw a code that talked about using the collector(“end”) but without success in my tests

Leave a Comment