toowake

answer.js

Apr 29th, 2023
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const { SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits } = require("discord.js");
  2.  
  3. module.exports = {
  4.     data: new SlashCommandBuilder()
  5.     .setName("answer")
  6.     .setDescription("Answer to a message")
  7.     .setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages)
  8.     .addStringOption(option => option
  9.         .setName("message-id")
  10.         .setDescription("the message id")
  11.         .setRequired(true)
  12.     )
  13.     .addStringOption(option => option
  14.         .setName("thema")
  15.         .addChoices(
  16.             {name: "option-1", value: "op1"},
  17.             {name: "option-2", value: "op2"}
  18.         )
  19.         .setDescription("Das Thema")
  20.         .setRequired(true)
  21.     ),
  22.  
  23.     async execute (interaction, client) {
  24.         const msgid = interaction.options.getString("message-id");
  25.         const thema = interaction.options.getString("thema");
  26.  
  27.         const embed1 = new EmbedBuilder()
  28.         .setTitle("Option 1")
  29.         .addFields(
  30.             {name: "Moderator", value: `<@${interaction.user.id}>`, inline: true},
  31.         )
  32.         .setDescription("Test")
  33.         .setColor("Random")
  34.  
  35.         const embed2 = new EmbedBuilder()
  36.         .setTitle("Option 2")
  37.         .addFields(
  38.             {name: "Moderator", value: `<@${interaction.user.id}>`, inline: true},
  39.         )
  40.         .setDescription("Test")
  41.         .setColor("Random")
  42.  
  43.         await interaction.reply({
  44.             content: `Answered to https://ptb.discord.com/channels/${interaction.guild.id}/${interaction.channel.id}/${msgid}`,
  45.             ephemeral: true
  46.         })
  47.  
  48.         if (thema === "op1") {
  49.             client.channels.cache.get(interaction.channel.id).messages.fetch(msgid).then(message => message.reply({embeds: [embed1]}))
  50.         }
  51.  
  52.         if (thema === "op2") {
  53.             client.channels.cache.get(interaction.channel.id).messages.fetch(msgid).then(message => message.reply({embeds: [embed1]}))
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment