import { ChannelType } from 'discord.js';
import { applyCommandDescription, applyOptionDescription } from '@nexumi/shared';
import { SlashCommandBuilder } from 'discord.js';

export const birthdayCommandData = applyCommandDescription(
  new SlashCommandBuilder()
    .setName('birthday')
    .addSubcommand((s) =>
      applyCommandDescription(s.setName('set'), 'birthdays.set.description')
        .addIntegerOption((o) =>
          applyOptionDescription(o.setName('month').setRequired(true).setMinValue(1).setMaxValue(12), 'birthdays.set.options.month')
        )
        .addIntegerOption((o) =>
          applyOptionDescription(o.setName('day').setRequired(true).setMinValue(1).setMaxValue(31), 'birthdays.set.options.day')
        )
        .addIntegerOption((o) =>
          applyOptionDescription(
            o.setName('year').setMinValue(1900).setMaxValue(new Date().getFullYear()),
            'birthdays.set.options.year'
          )
        )
    )
    .addSubcommand((s) => applyCommandDescription(s.setName('remove'), 'birthdays.remove.description'))
    .addSubcommand((s) => applyCommandDescription(s.setName('next'), 'birthdays.next.description'))
    .addSubcommand((s) => applyCommandDescription(s.setName('list'), 'birthdays.list.description'))
    .addSubcommand((s) =>
      applyCommandDescription(s.setName('setup'), 'birthdays.setup.description')
        .addChannelOption((o) =>
          applyOptionDescription(
            o.setName('channel').addChannelTypes(ChannelType.GuildText).setRequired(true),
            'birthdays.setup.options.channel'
          )
        )
        .addRoleOption((o) =>
          applyOptionDescription(o.setName('role'), 'birthdays.setup.options.role')
        )
        .addStringOption((o) =>
          applyOptionDescription(o.setName('timezone'), 'birthdays.setup.options.timezone')
        )
        .addStringOption((o) =>
          applyOptionDescription(o.setName('message'), 'birthdays.setup.options.message')
        )
    ),
  'birthdays.description'
);
