Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const {
- SlashCommandBuilder,
- ActionRowBuilder,
- ButtonBuilder,
- ButtonStyle,
- } = require("discord.js");
- module.exports = {
- data: new SlashCommandBuilder().setName("jax").setDescription("jax command"),
- async execute(interaction) {
- const JaxTable = [
- "<:jax:1162642006472937473> ",
- "<:JaxConfused:1164269815599472741> ",
- "<:JaxHappy:1164269856401670145> ",
- "<:JaxIuhh:1164269983686213732> ",
- "<:JaxPissed:1164269746301177947> ",
- "<:JaxTBH:1165532633128783914> ",
- "<:JaxUhhh:1164269901016477801>",
- "<:scaredJax:1164346158441828402>",
- ];
- const jaxbutton = new ActionRowBuilder().addComponents(
- new ButtonBuilder()
- .setCustomId(`jax`)
- .setLabel("Jax")
- .setStyle(ButtonStyle.Primary),
- new ButtonBuilder()
- .setCustomId(`nomorejax`)
- .setLabel("No more Jax")
- .setStyle(ButtonStyle.Danger)
- );
- interaction.reply({
- content: "Click this button to get a random Jax emoji",
- components: [jaxbutton],
- });
- const collector = interaction.channel.createMessageComponentCollector();
- collector.on("collect", async (button) => {
- if (button.customId === "jax") {
- const randomIndex = Math.floor(Math.random() * JaxTable.length);
- const selectedEmoji = JaxTable[randomIndex];
- if (interaction.user.id === button.user.id) {
- await button.reply({
- content: selectedEmoji,
- });
- } else {
- await button.reply({
- content: "That's not your button!",
- ephemeral: true,
- });
- }
- } else if (button.customId === "nomorejax") {
- if (
- interaction.user.id === button.user.id ||
- interaction.member.roles.cache.has("1162638848791162930")
- ) {
- // Disable both buttons
- jaxbutton.components[0].setDisabled(true);
- jaxbutton.components[1].setDisabled(true);
- // Edit the original message to reflect the disabled buttons
- interaction.editReply({
- content: "Both buttons have been disabled",
- components: [jaxbutton],
- });
- } else {
- await button.reply({
- content: "That's not your button!",
- ephemeral: true,
- });
- }
- }
- });
- // After 30 seconds, disable the button
- setTimeout(() => {
- jaxbutton.components[0].setDisabled(true);
- jaxbutton.components[1].setDisabled(true);
- interaction.editReply({
- content: "Both buttons have been disabled",
- components: [jaxbutton],
- });
- }, 30000);
- },
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement