Advertisement
OtKashix

Untitled

Oct 13th, 2020 (edited)
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const fs = require('fs').promises;
  2.         const path = require('path');
  3.         let champs = __dirname+'/../champions/';
  4.  
  5.         const selected = args[0];
  6.         let available = [];
  7.         let descriptions = [];
  8.         if(!selected){
  9.             fs.readdir(path.join(champs))
  10.             .then(champFiles => {
  11.                 x = 0;
  12.                 champFiles.forEach(fill =>{
  13.                     if(!fill.endsWith('.js')) return;
  14.                     let champName = fill.substring(0, fill.indexOf('.js'));
  15.                     let champModule = require(path.join(champs, champName));
  16.                     if(champModule.pick === 'yes'){
  17.                         available[x] = champName;
  18.                         descriptions[x] = champModule.type;
  19.                         x++;
  20.                     }
  21.                 })
  22.                 const embed = new Discord.MessageEmbed()
  23.                 .setDescription('All champions available to pick.')
  24.                 for(let i = 0; i < available.length; i++){
  25.                     embed.addField(available[i], descriptions[i]);
  26.                 }
  27.                 message.channel.send(embed);
  28.             }).catch(e => console.log(e));
  29.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement