#buttons in loop

7 messages · Page 1 of 1 (latest)

wheat night
#

hey so i made buttons in a command,i want to make like it keeps sending the same message until a specific no. rolls out.
for eg - if no. isn't zero,it keeps sending the message with buttons but if its zero it stops.

#

i hope i was able to explain well

#

can some help

#

someone*

#
const runs = ["0","1", "2", "3", "4", "6"]
const x = Math.floor((Math.random() * runs.length));
    const delivery = ["Inswing", "Outswing", "Yorker","Full Toss", "Bouncer"]
const randomdelivery = delivery[Math.floor(Math.random() * delivery.length)];

    const row = new MessageActionRow()
      .addComponents(
        new MessageButton()
          .setStyle("PRIMARY")
          .setCustomId("coverdrive")
          .setLabel("Drive"),

        new MessageButton()
          .setStyle("SECONDARY")
          .setCustomId("defend")
          .setLabel("Defend"),

        new MessageButton()
          .setStyle("DANGER")
          .setCustomId("loft")
          .setLabel("Loft"))
    const dsrow = new MessageActionRow()
    .addComponents(
      
    
        new MessageButton()
        .setStyle("SUCCESS")
        .setCustomId("sweep")
        .setLabel("Sweep"),
        new MessageButton()
        .setStyle("SECONDARY")
        .setCustomId("leave")
        .setLabel("Leave"),
       
      );

    const sentMessage = await message.channel.send({ content: ` ${randomdelivery} Delivery Is Coming.`, components: [row,dsrow] });
     

    const filter = (interaction) =>
              interaction.user.id === message.author.id;
            const collector = message.channel.createMessageComponentCollector({
              filter,
              max: 1
            });
    

collector.on("collect", (interaction) => {
  
 
  
if (interaction.customId == "loft") {
  if(x ===0 )  {return  interaction.reply("You Are Out!")
               } else(interaction.reply(`${x} Runs!`))
  
  


}
  


  if (interaction.customId == "coverdrive") return interaction.reply(`${y} runs`)
  if (interaction.customId == "defend") return interaction.reply( `${z} Runs!`)
  if(interaction.customId == "sweep") return interaction.reply(`${x} Runs!`)
  if(interaction.customId == "leave") return interaction.reply(`0 Runs!`)
#

current code of command

wheat night
#

bro its been 1 month and u guys still dont reply