#Simple Buttons for Bot Discord

3 messages · Page 1 of 1 (latest)

celest kettle
#

Hello :

I want button tell "@ everyone message" when clicked it.

Just button for call all @ with auto message.


i create button when message deleted because on my discord slash command dont work, i found message delete for create my button.


Button . style primary > clicked on it > style secondary + disabled + timer countdown 5:00 minutes under button > timer finish > Button . style primary + timer disappear


Its possible all members are same timer but its individual ?


My code :

const mySecret = process.env[`TOKEN`]
const Discord = require("discord.js");
const { Client, GatewayIntentBits } = require('discord.js')
const { ActionRowBuilder, ButtonBuilder, ButtonStyle, Events } = require('discord.js');
const client = new Client({
  intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMessages,
    // ...
  ]
})

client.on("ready", () => {
  console.log(`Logged in as ${client.user.tag}!`)
})

client.on("message", msg => {
  if (msg.content === "ping") {
    msg.reply("pong");
    console.log(`Message reçu: ${msg.content}`);
  }
})

let button = null;
let button2 = null;
let row = null;

client.on('messageDelete', async message => {
  row = new ActionRowBuilder()
    .addComponents(
      button = new ButtonBuilder()
        .setCustomId('bouton1')
        .setLabel('Alert everyone')
        .setStyle('Primary')
    );

  const channel = message.channel;
  const alertMessage = await channel.send({ content: 'Send an alert to @ everyone to come and play :D', components: [row] });
}); 

//-------------------

client.on(Events.InteractionCreate, interaction => {
  if (interaction.isButton() && interaction.customId === 'bouton1') {
    button2 = interaction.component;
    console.log(button2);
    button2.setStyle('Secondary'); //ERROR HERE
  }
});

//-------------------


client.login(process.env.TOKEN);
#

order of actions :

| Button . style primary > clicked on it > style secondary + disabled + timer countdown 5:00 minutes under button > timer finish > Button . style primary + timer disappear |

reef bone
#

Hahaha, you absolutely destroyed the mod log laugh