#Issue with ClientApplication always being null

1 messages · Page 1 of 1 (latest)

fading niche

Hello, I'm trying to register application commands by doing client.application?.commands.create(). The problem is that my client.application is always null and nothing happens when I attempt to create commands this way.

const initializeCommands = async (): Promise<void> => {
  for(const folder of commandFolders) {
    const commandFolder: string[] = fs.readdirSync(commandsPath + `/${folder}`)
    const commandFiles: string[] = commandFolder.filter(file => file.endsWith('.ts'))

    for(const file of commandFiles) {
      const filePath: string = path.join(commandsPath, `/${folder}/${file}`)
      const command: Command = (await import(filePath)).command
  
      if(!command) return log.warn(`Invaild command at: ${filePath}`, WarnLevel.Medium)
  
      if(globalPush) await client.application?.commands.create(command.data)
      else await client.application?.commands.create(command.data, process.env.DEV_GUILD as string)
      
      log.command(command)
    }
  }
}