import type { ApplicationCommandStructure, Client } from '@projectdysnomia/dysnomia';

export async function registerCommands(client: Client, commands: ApplicationCommandStructure[]) {
  if (!client) throw new Error('Client not initialized');
  if (!(await client.getCommands()).length || process.env.RESET_COMMANDS === 'true' || process.env.NODE_ENV === 'development') {
    console.debug('Registering commands...');
    const response = await client.bulkEditCommands(commands);
    console.debug(`Registered ${response.length} commands.`);
  }
  return commands;
}
