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

export const giveawayCommandData = applyCommandDescription(
  new SlashCommandBuilder()
    .setName('giveaway')
    .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild)
    .addSubcommand((s) =>
      applyCommandDescription(s.setName('start'), 'giveaway.start.description')
        .addStringOption((o) =>
          applyOptionDescription(o.setName('duration').setRequired(true), 'giveaway.start.options.duration')
        )
        .addIntegerOption((o) =>
          applyOptionDescription(
            o.setName('winners').setRequired(true).setMinValue(1).setMaxValue(25),
            'giveaway.start.options.winners'
          )
        )
        .addStringOption((o) =>
          applyOptionDescription(o.setName('prize').setRequired(true), 'giveaway.start.options.prize')
        )
        .addRoleOption((o) =>
          applyOptionDescription(o.setName('role'), 'giveaway.start.options.role')
        )
        .addIntegerOption((o) =>
          applyOptionDescription(
            o.setName('level').setMinValue(0).setMaxValue(500),
            'giveaway.start.options.level'
          )
        )
        .addIntegerOption((o) =>
          applyOptionDescription(
            o.setName('member_days').setMinValue(0).setMaxValue(3650),
            'giveaway.start.options.member_days'
          )
        )
    )
    .addSubcommand((s) =>
      applyCommandDescription(s.setName('end'), 'giveaway.end.description').addStringOption((o) =>
        applyOptionDescription(o.setName('id').setRequired(true), 'giveaway.common.options.id')
      )
    )
    .addSubcommand((s) =>
      applyCommandDescription(s.setName('reroll'), 'giveaway.reroll.description').addStringOption(
        (o) => applyOptionDescription(o.setName('id').setRequired(true), 'giveaway.common.options.id')
      )
    )
    .addSubcommand((s) =>
      applyCommandDescription(s.setName('list'), 'giveaway.list.description')
    )
    .addSubcommand((s) =>
      applyCommandDescription(s.setName('delete'), 'giveaway.delete.description').addStringOption(
        (o) => applyOptionDescription(o.setName('id').setRequired(true), 'giveaway.common.options.id')
      )
    )
    .addSubcommand((s) =>
      applyCommandDescription(s.setName('pause'), 'giveaway.pause.description').addStringOption(
        (o) => applyOptionDescription(o.setName('id').setRequired(true), 'giveaway.common.options.id')
      )
    ),
  'giveaway.description'
);
