-3

I am making this handler but I cant figure out how to access a value from property accessors inside of an array, here's my code:

  • Code:
const slashDir = path.resolve(__dirname, '../Commands/Slash Command')

  readdirSync(slashDir).forEach(dir => {
    let cmdSlash = readdirSync(`${slashDir}/${dir}/`).filter(file => file.endsWith('.js'))
    for (let file of cmdSlash) {
      let slashPull = require(`${slashDir}/${dir}/${file}`)
      if (slashPull.name) {
        slash.push(slashPull);
        client.slash.set(slashPull.name, slashPull)

        console.log(slash) // THIS IS THE PART WHERE I LOGGED IT

        client.application.commands.create({
          name: slash.name,
          description: slash.name
        })

      } 
    }
  })
  • What I've logged
[
  {
    name: 'info',
    description: 'check bot info',
    run: [AsyncFunction: run]
  }
]
[
  {
    name: 'info',
    description: 'check bot info',
    run: [AsyncFunction: run]
  },
  {
    name: 'test',
    description: 'chekling ping of bot',
    run: [AsyncFunction: run]
  }
]
  • How I defined my slash where i pushed the slashPull.name into it
let slash = [];
Shineurysm
  • 55
  • 6

0 Answers0