AlexzanderFlores / WOKCommands

130 stars 60 forks source link

Following along with the Discord.JS V13 Ep. 7 and I am receiving an usual issue #189

Open alexjack32 opened 3 years ago

alexjack32 commented 3 years ago

import { ButtonInteraction, MessageActionRow, MessageButton} from "discord.js"; import { ICommand } from "wokcommands";

export default { category: 'Testing', description: 'Testing',

slash: true, testOnly: true,

callback: async ({ interaction: msgInt, channel }) => { const row = new MessageActionRow() .addComponents( new MessageButton() .setCustomId('ban_yes') .setEmoji('👼🏾') .setLabel('confirm') .setStyle('SUCCESS') )

  .addComponents(
    new MessageButton()
    .setCustomId('ban_no')
    .setLabel('Cancel')
    .setStyle('DANGER')
  )

const linkRow = new MessageActionRow()
.addComponents(
  new MessageButton()
  .setURL('https://google.com')
  .setLabel('Google Search')
  .setStyle('LINK')
)

await msgInt.reply({
    content: 'Are you sure?',
    components: [row, linkRow],
    ephemeral: true,
  })

  const filter =(btnInt: ButtonInteraction) => {
    return msgInt.user.id === btnInt.user.id
  }

  const collector = channel.createMessageCollector({ 

filter, // here it gives and error for the filter max: 1, time: 1000 * 15 }) // here it gives and error for the filter Screenshot 2021-11-15 145442

}, } as ICommand

RaulSanchezzt commented 2 years ago

Hi, I had the same problem and I changed ButtonInteraction to MessageComponentInteraction


const filter = (btnInt: MessageComponentInteraction) => {
        return msgInt.user.id === btnInt.user.id
    }

    const collector = channel.createMessageComponentCollector({
        filter,
        max: 1,
        time: 1000 * 15
    })

    collector.on('collect', (i: MessageComponentInteraction) => {
        i.reply({
            content: 'You clicked a button',
            ephemeral: true
        })
    })```