Advertisement
OtKashix

Untitled

Oct 30th, 2020
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module.exports = {
  2.     name: 'commands',
  3.     alias: ['commands'],
  4.     type: 'user',
  5.     description: 'Shows all the commands related to the bot.',
  6.     run: (client, message, args) => { // Parametros que utiliza
  7.         const Discord = require('discord.js');
  8.         const fs = require('fs').promises;
  9.         const fss = require('fs');
  10.         const path = require('path');
  11.  
  12.         let nombres = [];
  13.         let descripciones = [];
  14.         let contador = 0;
  15.  
  16.         fs.readdir(path.join(__dirname)) // Explicado en main.js
  17.         .then(filess => {
  18.             x=0;
  19.             filess.forEach(fil =>{
  20.                 if(!fil.endsWith('.js')) return;
  21.                 let commandName = fil.substring(0, fil.indexOf('.js'));
  22.                 let commandModule = require(path.join(__dirname, commandName));
  23.                 //console.log(commandName, commandModule.description);
  24.                 if(commandModule.type === null || commandModule.type === undefined || commandModule.type === ''){
  25.                     contador++;
  26.                 } else if(commandModule.type === 'admin' && message.member.hasPermission('BAN_MEMBERS')){
  27.                     nombres[x] = commandName;
  28.                     descripciones[x] = commandModule.description;
  29.                     x++
  30.                 } else if(commandModule.type === 'admin' && !message.member.hasPermission('BAN_MEMBERS')){
  31.                     contador++;
  32.                 }else if(commandModule.type === 'user'){
  33.                     nombres[x] = commandName;
  34.                     descripciones[x] = commandModule.description;
  35.                     x++
  36.                 }
  37.                 //if(commandModule.type === 'admin') return;
  38.                 /*nombres[x] = commandName;
  39.                 descripciones[x] = commandModule.description;*/
  40.                 //console.log(x, nombres[x], descripciones[x]);
  41.                 //x++;
  42.             })
  43.             const embed = new Discord.MessageEmbed()
  44.             .setDescription('All commands available.')
  45.             for(let i = 0; i < nombres.length; i++){
  46.                 embed.addField(nombres[i], descripciones[i]);
  47.             }
  48.             message.channel.send(embed);
  49.         })
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement