nyx

The first CODM discrod bot -- cath.exe Template
git clone https://codeberg.org/night0721/nyx
Log | Files | Refs | LICENSE

loadout.js (2327B)


      1 const { EmbedBuilder } = require("discord.js"); //@night0721 You need to make this
      2 const items = require("../../util/Data/loadout.json");
      3 module.exports = {
      4   name: "loadout",
      5   description: "Generate A Random Loadout",
      6   category: "CODM",
      7   run: async (client, interaction) => {
      8     const secondary =
      9       items.secondary[Math.floor(Math.random() * items.secondary.length)];
     10     const red = items.perk_1[Math.floor(Math.random() * items.perk_1.length)];
     11     const green = items.perk_2[Math.floor(Math.random() * items.perk_2.length)];
     12     const blue = items.perk_3[Math.floor(Math.random() * items.perk_3.length)];
     13     const operator =
     14       items.operator_skill[
     15         Math.floor(Math.random() * items.operator_skill.length)
     16       ];
     17     const slots = shuffle(items.scorestreak);
     18     const slot_1 = slots.next().value,
     19       slot_2 = slots.next().value,
     20       slot_3 = slots.next().value;
     21     const result = new EmbedBuilder()
     22       .setColor(client.color)
     23       .setFooter({
     24         text: `Made by ${client.author}`,
     25         iconURL: client.user.displayAvatarURL({ dynamic: true }),
     26       })
     27       .setURL(client.web)
     28       .setTitle(`🎲 A Randomly Generated Loadout 🎲`)
     29       .setDescription(
     30         `This loadout is a randomly generated, Also try, \`\`\`/class\`\`\` to get a randomally generated primary weapon gunsmith build`
     31       )
     32       .addFields(
     33         {
     34           name: "Secondary Weapon",
     35           value: secondary,
     36           inline: true,
     37         },
     38         {
     39           name: "Operator Skill",
     40           value: operator,
     41           inline: true,
     42         },
     43         {
     44           name: "Scorestreak",
     45           value: `${slot_1}\n${slot_2}\n${slot_3}`,
     46           inline: true,
     47         },
     48         {
     49           name: "Red Perk",
     50           value: red,
     51           inline: true,
     52         },
     53         {
     54           name: "Green Perk",
     55           value: green,
     56           inline: true,
     57         },
     58         {
     59           name: "Blue Perk",
     60           value: blue,
     61           inline: true,
     62         }
     63       )
     64       .setTimestamp();
     65     interaction.followUp({ embeds: [result] });
     66 
     67     function* shuffle(array) {
     68       let i = array.length;
     69       while (i--) {
     70         yield array.splice(Math.floor(Math.random() * (i + 1)), 1)[0];
     71       }
     72     }
     73   },
     74 };