auth-bot

Discord Bot to verify user, allowing server owner to recover server by pulling back members
git clone https://codeberg.org/night0721/auth-bot
Log | Files | Refs | README | LICENSE

interaction.js (1725B)


      1 const client = require("../bot");
      2 const dotenv = require("dotenv");
      3 const { EmbedBuilder } = require("discord.js");
      4 dotenv.config();
      5 client.on("interactionCreate", async interaction => {
      6   if (interaction.isCommand()) {
      7     await interaction
      8       .deferReply({ ephemeral: true })
      9       .catch(e => console.log(e));
     10     const cmd = client.slashCommands.get(interaction.commandName);
     11     if (!cmd) return;
     12     const args = [];
     13     for (const option of interaction.options.data) {
     14       if (option.type === "SUB_COMMAND_GROUP") {
     15         if (option.name) args.push(option.name);
     16         option.options?.forEach(x => {
     17           if (x.type === 1) {
     18             if (x.name) args.push(x.name);
     19             x.options?.forEach(y => {
     20               if (y.value) args.push(y.value);
     21             });
     22           } else if (x.value) {
     23             args.push(x.value);
     24           }
     25           if (x.value) args.push(x.value);
     26         });
     27       }
     28       if (option.type === "SUB_COMMAND") {
     29         if (option.name) args.push(option.name);
     30         option.options?.forEach(x => {
     31           if (x.value) args.push(x.value);
     32         });
     33       } else if (option.value) {
     34         args.push(option.value);
     35       }
     36     }
     37     interaction.member = interaction.guild.members.cache.get(
     38       interaction.user.id
     39     );
     40     cmd.run(client, interaction, args).catch(e => sendE(e, interaction));
     41   }
     42 });
     43 function sendE(e, i) {
     44   console.error(e.stack);
     45   const embed = new EmbedBuilder()
     46     .setTitle("Command Error")
     47     .setDescription(`\`\`\`yaml\n${e.stack}\`\`\``)
     48     .setTimestamp()
     49     .setColor("#ff0000")
     50     .setFooter({ text: client.user.username });
     51   i.channel.send({ embeds: [embed] });
     52 }