toowake

random.js

Aug 7th, 2023
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. const {SlashCommandBuilder, EmbedBuilder, Embed} = require("discord.js");
  2.  
  3. module.exports = {
  4. data: new SlashCommandBuilder()
  5. .setName("random")
  6. .setDescription("Gives you a random answer from the given options")
  7. .addStringOption(option => option
  8. .setName("option-1")
  9. .setDescription("the first option")
  10. .setRequired(true)
  11. )
  12. .addStringOption(option => option
  13. .setName("option-2")
  14. .setDescription("The second option")
  15. .setRequired(true)
  16. ),
  17.  
  18. async execute (interaction) {
  19.  
  20. const op1 = interaction.options.getString("option-1");
  21. const op2 = interaction.options.getString("option-2");
  22. const choices = [`${op1}`, `${op2}`];
  23.  
  24. const answer = Math.floor(Math.random() * choices.length);
  25.  
  26. const embed = new EmbedBuilder()
  27. .setTitle("Here is the answer!")
  28. .addFields({ name: `User: `, value: `<@${interaction.user.id}>`, inline: true})
  29. .addFields({ name: `Answer: `, value: `${choices[answer]}`, inline: true})
  30. .addFields({ name: "Option 1: ", value: `${op1}`, inline: false})
  31. .addFields({ name: "Option 2: ", value: `${op2}`})
  32. .setColor("Random")
  33. .setTimestamp()
  34.  
  35. return interaction.reply({ embeds: [embed] });
  36.  
  37. }
  38. }
Add Comment
Please, Sign In to add comment