Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module.exports = {
- name: 'commands',
- alias: ['commands'],
- type: 'user',
- description: 'Shows all the commands related to the bot.',
- run: (client, message, args) => { // Parametros que utiliza
- const Discord = require('discord.js');
- const fs = require('fs').promises;
- const fss = require('fs');
- const path = require('path');
- let nombres = [];
- let descripciones = [];
- let contador = 0;
- fs.readdir(path.join(__dirname)) // Explicado en main.js
- .then(filess => {
- x=0;
- filess.forEach(fil =>{
- if(!fil.endsWith('.js')) return;
- let commandName = fil.substring(0, fil.indexOf('.js'));
- let commandModule = require(path.join(__dirname, commandName));
- //console.log(commandName, commandModule.description);
- if(commandModule.type === null || commandModule.type === undefined || commandModule.type === ''){
- contador++;
- } else if(commandModule.type === 'admin' && message.member.hasPermission('BAN_MEMBERS')){
- nombres[x] = commandName;
- descripciones[x] = commandModule.description;
- x++
- } else if(commandModule.type === 'admin' && !message.member.hasPermission('BAN_MEMBERS')){
- contador++;
- }else if(commandModule.type === 'user'){
- nombres[x] = commandName;
- descripciones[x] = commandModule.description;
- x++
- }
- //if(commandModule.type === 'admin') return;
- /*nombres[x] = commandName;
- descripciones[x] = commandModule.description;*/
- //console.log(x, nombres[x], descripciones[x]);
- //x++;
- })
- const embed = new Discord.MessageEmbed()
- .setDescription('All commands available.')
- for(let i = 0; i < nombres.length; i++){
- embed.addField(nombres[i], descripciones[i]);
- }
- message.channel.send(embed);
- })
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement