Advertisement
PrinceOfCookies

Untitled

Oct 27th, 2023
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. const {
  2. SlashCommandBuilder,
  3. ActionRowBuilder,
  4. ButtonBuilder,
  5. ButtonStyle,
  6. } = require("discord.js");
  7.  
  8. module.exports = {
  9. data: new SlashCommandBuilder().setName("jax").setDescription("jax command"),
  10. async execute(interaction) {
  11. const JaxTable = [
  12. "<:jax:1162642006472937473> ",
  13. "<:JaxConfused:1164269815599472741> ",
  14. "<:JaxHappy:1164269856401670145> ",
  15. "<:JaxIuhh:1164269983686213732> ",
  16. "<:JaxPissed:1164269746301177947> ",
  17. "<:JaxTBH:1165532633128783914> ",
  18. "<:JaxUhhh:1164269901016477801>",
  19. "<:scaredJax:1164346158441828402>",
  20. ];
  21.  
  22. const jaxbutton = new ActionRowBuilder().addComponents(
  23. new ButtonBuilder()
  24. .setCustomId(`jax`)
  25. .setLabel("Jax")
  26. .setStyle(ButtonStyle.Primary),
  27. new ButtonBuilder()
  28. .setCustomId(`nomorejax`)
  29. .setLabel("No more Jax")
  30. .setStyle(ButtonStyle.Danger)
  31. );
  32.  
  33. interaction.reply({
  34. content: "Click this button to get a random Jax emoji",
  35. components: [jaxbutton],
  36. });
  37.  
  38. const collector = interaction.channel.createMessageComponentCollector();
  39.  
  40. collector.on("collect", async (button) => {
  41. if (button.customId === "jax") {
  42. const randomIndex = Math.floor(Math.random() * JaxTable.length);
  43. const selectedEmoji = JaxTable[randomIndex];
  44.  
  45. if (interaction.user.id === button.user.id) {
  46. await button.reply({
  47. content: selectedEmoji,
  48. });
  49. } else {
  50. await button.reply({
  51. content: "That's not your button!",
  52. ephemeral: true,
  53. });
  54. }
  55. } else if (button.customId === "nomorejax") {
  56. if (
  57. interaction.user.id === button.user.id ||
  58. interaction.member.roles.cache.has("1162638848791162930")
  59. ) {
  60. // Disable both buttons
  61. jaxbutton.components[0].setDisabled(true);
  62. jaxbutton.components[1].setDisabled(true);
  63.  
  64. // Edit the original message to reflect the disabled buttons
  65. interaction.editReply({
  66. content: "Both buttons have been disabled",
  67. components: [jaxbutton],
  68. });
  69. } else {
  70. await button.reply({
  71. content: "That's not your button!",
  72. ephemeral: true,
  73. });
  74. }
  75. }
  76. });
  77.  
  78. // After 30 seconds, disable the button
  79. setTimeout(() => {
  80. jaxbutton.components[0].setDisabled(true);
  81. jaxbutton.components[1].setDisabled(true);
  82. interaction.editReply({
  83. content: "Both buttons have been disabled",
  84. components: [jaxbutton],
  85. });
  86. }, 30000);
  87. },
  88. };
  89.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement