title: How do I pass module.exports in my index.js / discord.js
body: <p>So I made a &quot;mute&quot; and &quot;warn&quot; command for my discord bot and when I try to run them I get an error. This error is because in all my previous commands I used &quot;.execute(message, args)&quot; in my command code, so when I wanted to get the command from my index.js I just had to pass <code>client.commands.get('name').execute(message, args)</code>. Now, I don't have this in my command, so how do I get it from index.js. I hope you understand what I'm saying.</p>
  <p>Here's index.js:</p>
  <pre><code>const Discord = require('discord.js');
  const { Client, Collection } = require ('discord.js');
  const client = new Discord.Client();
  
  const token = 'TOKEN';
  const PREFIX = '-';
  
  const fs = require('fs');
  client.commands = new Discord.Collection();
  
  const commandFiles = fs.readdirSync('./commands/').filter(file =&gt; file.endsWith('.js'));
  for(const file of commandFiles){
      const command = require(`./commands/${file}`);
   
      client.commands.set(command.name, command);
  }
  
  client.on('ready', () =&gt;{
      console.log('Compass is online');
      client.user.setActivity('GameCore', {type: 'WATCHING'}).catch(console.error);
  })
  
  client.on('message', message=&gt;{
      
      if (!message.content.startsWith(PREFIX)) return;
      else {
          const args = message.content.slice(PREFIX.length).split(/ +/);
          const command = args.shift().toLowerCase();
  
          if(command === 'help') {
              client.commands.get('help').execute(message, args);
          }
          if(command === 'kick') {
              client.commands.get('kick').execute(message, args);
          }
          if(command === 'ban') {
              client.commands.get('ban').execute(message, args);  
          }
          if(command === 'slowmode') {
              client.commands.get('slowmode').execute(message, args);  
          }
          if(command === 'warn') {
              client.commands.get('warn').execute(message, args);  
          }
          if(command === 'mute') {
              client.commands.get('mute').execute(message, args);  
          }
  
  
      }
  })
  
  client.login(token);
  </code></pre>
  <p>mute.js (warn.js is build in a similar format):</p>
  <pre><code>var Discord = require('discord.js');
  var ms = require('ms');
  
  module.export = async(message, args) =&gt; {
      if(!message.member.hasPemission('MANAGE_MESSAGES')) return message.channel.send(':x:***You do not have permissions to run this command!***')
  
      var user = message.mentions.users.first();
      if(!user) return message.channel.send(':x:***Please mention a user!***')
  
      var member;
  
      try {
          member = await message.guild.members.fetch(user);
      
      } catch(err) {
          member = null;
      }
  
      if(!member) return message.channel.send(':x:***Please mention a user!***');
      if(member.hasPermission('MANAGE_MESSAGES')) return message.channel.send(':x:***You cannot mute that person!***')
  
      var rawTime = args[1];
      var time = ms(rawTime)
      if(!time) return message.channel.send('You didn\'t specify a time!')
      
      var reason = args.splice(2).join(' ');
      if(!reason) return message.reply('You need to give a mute reason!');
      
      var channel = message.guild.channels.catch.find(c =&gt; c.name === 'potato');
  
      var log = new Discord.MessageEmbed()
      .setTitle(':white_check_mark:***This user has been muted.***')
      .addField('User:', user, true)
      .addField('By:', message.author, true)
      .addField('Expires:', rawTime)
      .addField('Reason:', reason)
      channel.send(log);
  
      var embed = new Discord.MessageEmbed()
      .setTitle('You have been muted!')
      .addField('Expires:', rawTime, true)
      .addField('Reason:', reason, true);
  
      try {
          user.send(embed);
      } catch(err) {
          console.warn(err);
      }
  
      var role = msg.guild.roles.cache.find(r =&gt; r.name === 'Muted');
  
      member.roles.add(role);
  
      setTimeout(async() =&gt; {
          member.roles.remove(role);
      }, time);
  
      message.channel.send(`**${user}** has been muted by **${message.author}** for **${rawTime}**!`)
  }
  </code></pre>
  <p>And the error I get when I type &quot;-mute&quot; or &quot;-warn&quot;:</p>
  <pre><code>            client.commands.get('mute').execute(message, args);
                                         ^
  
  TypeError: Cannot read property 'execute' of undefined
      at Client.&lt;anonymous&gt; (G:\Alexis\Desktop\Compass\index.js:46:40)
      at Client.emit (events.js:315:20)
      at MessageCreateAction.handle (G:\Alexis\Desktop\Compass\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
      at Object.module.exports [as MESSAGE_CREATE] (G:\Alexis\Desktop\Compass\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
      at WebSocketManager.handlePacket (G:\Alexis\Desktop\Compass\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
      at WebSocketShard.onPacket (G:\Alexis\Desktop\Compass\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
      at WebSocketShard.onMessage (G:\Alexis\Desktop\Compass\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
      at WebSocket.onMessage (G:\Alexis\Desktop\Compass\node_modules\ws\lib\event-target.js:125:16)
      at WebSocket.emit (events.js:315:20)
      at Receiver.receiverOnMessage (G:\Alexis\Desktop\Compass\node_modules\ws\lib\websocket.js:797:20)
  </code></pre>