title: discord.js Cannot read property 'execute' of undefined
body: <p>I get this error:</p>
  <pre><code>botcommandsmoney.get('auction').run(bot, message, args, err, auctionhouse)
                                             ^
  
  TypeError: Cannot read property 'run' of undefined
  </code></pre>
  <p>My code in index.js (start file) is this:</p>
  <pre class="lang-js prettyprint-override"><code>//#region Consts
  
  const Discord = require('discord.js')
  const bot = new Discord.Client()
  const fs = require('fs')
  const userdata = require('./userdata.json')
  const botcommands = new Discord.Collection()
  const auctionhouse = new Object()
  
  //#endregion
  
  //#region Command Files
  
  const commandFiles = fs.readdirSync('./cmds/').filter(file =&gt; file.endsWith('.js'))
  for(const file of commandFiles){
      const command = require(`./cmds/${file}`)
  
      botcommands.set(command.name, command)
  }
  
  const botcommandsfun = new Discord.Collection()
  const commandFilesFun = fs.readdirSync('./cmds/fun/').filter(file =&gt; file.endsWith('.js'))
  for(const file of commandFilesFun){
      const command = require(`./cmds/fun/${file}`)
  
      botcommandsfun.set(command.name, command)
  }
  
  const botcommandsinfo = new Discord.Collection()
  const commandFilesInfo = fs.readdirSync('./cmds/info/').filter(file =&gt; file.endsWith('.js'))
  for(const file of commandFilesInfo){
      const command = require(`./cmds/info/${file}`)
  
      botcommandsinfo.set(command.name, command)
  }
  
  const botcommandsitems = new Discord.Collection()
  const commandFilesItems = fs.readdirSync('./cmds/items/').filter(file =&gt; file.endsWith('.js'))
  for(const file of commandFilesItems){
      const command = require(`./cmds/items/${file}`)
  
      botcommandsitems.set(command.name, command)
  }
  
  const botcommandsmisc = new Discord.Collection()
  const commandFilesMisc = fs.readdirSync('./cmds/misc/').filter(file =&gt; file.endsWith('.js'))
  for(const file of commandFilesMisc){
      const command = require(`./cmds/misc/${file}`)
  
      botcommandsmisc.set(command.name, command)
  }
  
  const botcommandsmod = new Discord.Collection()
  const commandFilesmod = fs.readdirSync('./cmds/mod/').filter(file =&gt; file.endsWith('.js'))
  for(const file of commandFilesmod){
      const command = require(`./cmds/mod/${file}`)
  
      botcommandsmod.set(command.name, command)
  }
  
  const botcommandsmoney = new Discord.Collection()
  const commandFilesmoney = fs.readdirSync('./cmds/money/').filter(file =&gt; file.endsWith('.js'))
  for(const file of commandFilesmoney){
      const command = require(`./cmds/money/${file}`)
  
      botcommandsmoney.set(command.name, command)
  }
  
  //#endregion
  
  bot.login('my token, i\'m not gonna tell you it')
  
  bot.on('ready', () =&gt; {
      bot.user.setActivity('*help', { type: &quot;WATCHING&quot; })
  })
  
  bot.on('message', message =&gt; {
  
  
      //#region Setting up data
          if(!userdata[message.author.id]) {
              userdata[message.author.id] = {
                  name: message.author.username,
                  referer: null,
                  joinguild: {
                      guildid: message.guild.id,
                      guildname: message.guild.name
                  },
                  userconfig: {
                      commands: {
                          amount: 0,
                          category: {
                              fun: 0,
                              info: 0,
                              moderation: 0,
                              misc: 0,
                              money: 0,
                              item: 0,
                              premium: 0
                          }
                      },
                      messages: 1,
                      coupons: 0,
                      passive: false
                  },
                  profile: {
                      rob: {
                          robs: 0,
                          successrobs: 0,
                          failedrobs: 0,
                          heists: 0
                      },
                      pay: {
                          payed: 0,
                          recieved: 0
                      },
                      account: {
                          status: &quot;A waffle bot user!&quot;,
                          skin: &quot;default&quot;,
                          food: &quot;waffles&quot;,
                          wishlist: [],
                          funfact: &quot;A cool waffle bot user!&quot;,
                          pfp: message.author.avatarURL()
                      }
                  }
              }
              fs.writeFile(&quot;./userdata.json&quot;, JSON.stringify(userdata), err =&gt; {
                  if (err) console.log(err);
                });
          }
          var item1id = Math.floor((Math.random() * 3) + 1);
          var item2id = Math.floor((Math.random() * 10) + 1);
          while(item2id == item1id){
              var item2id = Math.floor((Math.random() * 10) + 1);
          }
          var item3id = Math.floor((Math.random() * 10) + 1);
          while(item3id == item2id || item3id == item1id){
              var item3id = Math.floor((Math.random() * 10) + 1);
          }
          if(!auctionhouse){
              auctionhouse = {
                  item1: {
                      name: &quot;Spot One&quot;,
                      seller: null,
                      startingprice: 0,
                      currentprice: 0,
                      winningbidder: null,
                      id: item1id
                  },
                  item2: {
                      name: &quot;Spot Two&quot;,
                      seller: null,
                      startingprice: 0,
                      currentprice: 0,
                      winningbidder: null,
                      id: item2id
                  },
                  item3: {
                      name: &quot;Spot Three&quot;,
                      seller: null,
                      startingprice: 0,
                      currentprice: 0,
                      winningbidder: null,
                      id: item3id
                  }
              }
          }
  
      //#endregion
      
      //#region Setting Up RichEmbeds
          function err(error){
              embed = new Discord.MessageEmbed()
              .setTitle('&lt;a:no:676180589895876611&gt; ' + error)
              .setColor(&quot;RED&quot;)
              message.channel.send(embed)
          }
          function success(msg){
              embed = new Discord.MessageEmbed()
              .setTitle('&lt;a:yes:676180565434695747&gt; ' + msg)
              .setColor(&quot;GREEN&quot;)
              message.channel.send(embed)
          }
      //#endregion
      
      const args = message.content.substring(&quot;*&quot;).split(&quot; &quot;);
      switch(args[0]){
          case `*help`:
              botcommandsinfo.get('help').execute(message, args)
              break;
          case '*snipe':
              botcommandsinfo.get('snipe').execute(bot, message, args, err)
              break;
          case '*auctionhouse':
              botcommandsmoney.get('auction').execute(bot, message, args, err, auctionhouse)
              break;
      }
  })
  bot.snipes = new Map()
  
  //#region Firing Events
      bot.on('messageDelete', function(message, channel) {
          bot.snipes.set(message.channel.id, {
              content: message.content,
              author: message.author,
              image: message.attachments.first() ? message.attachments.first().proxyURL : null
          })
      })
  
  //#endregion
  </code></pre>
  <p>All of my other commands work, (snipe and help) but the *auctionhouse does not.</p>
  <p>My code for the *auctionhouse command:</p>
  <pre class="lang-js prettyprint-override"><code>module.exports = {
      name: 'help',
      description: &quot;Help command!&quot;,
      execute(bot, message, args, err, auctionhouse){
      const Discord = require('discord.js')
      const embed = new Discord.MessageEmbed()
      .setTitle('Auction House')
      .setDescription('To bid on an item, run `*bid &lt;id&gt; &lt;amount&gt;`.')
      .addField(`${auctionhouse.item1.name} - $${auctionhouse.item1.currentprice} - ID: \`${auctionhouse.item1.id}\``)
      .addField(`${auctionhouse.item2.name} - $${auctionhouse.item2.currentprice} - ID: \`${auctionhouse.item2.id}\``)
      .addField(`${auctionhouse.item3.name} - $${auctionhouse.item3.currentprice} - ID: \`${auctionhouse.item3.id}\``)
      .setColor(&quot;RANDOM&quot;)
      message.channel.send(embed)
      }
  }
  
  
  </code></pre>
  <p>This is the directory listing: <a href="https://i.stack.imgur.com/bVvGo.png" rel="nofollow noreferrer">stack overflow won't let me add images yet :( so this is an imgur link</a></p>
  <p>Details:</p>
  <p>Runtime: Node.JS v12
  Discord.JS Version: 12.0.0
  OS: Windows 10 Home 64 Bit
  Ram: 8GB, 2GB dedicated
  My Discord: Aawesome#6969</p>