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

export const verifyCommandData = applyCommandDescription(
  new SlashCommandBuilder()
    .setName('verify')
    .addSubcommand((s) =>
      applyCommandDescription(s.setName('setup'), 'verify.setup.description')
        .addChannelOption((o) =>
          applyOptionDescription(
            o.setName('channel').addChannelTypes(ChannelType.GuildText).setRequired(true),
            'verify.setup.options.channel'
          )
        )
        .addRoleOption((o) =>
          applyOptionDescription(o.setName('verified_role').setRequired(true), 'verify.setup.options.verified_role')
        )
        .addRoleOption((o) =>
          applyOptionDescription(o.setName('unverified_role'), 'verify.setup.options.unverified_role')
        )
        .addStringOption((o) =>
          applyOptionDescription(o.setName('mode'), 'verify.setup.options.mode')
            .addChoices(
              { name: 'Button', value: 'BUTTON' },
              { name: 'Captcha', value: 'CAPTCHA' }
            )
        )
        .addStringOption((o) =>
          applyOptionDescription(
            o.setName('captcha_provider'),
            'verify.setup.options.captcha_provider'
          ).addChoices(
            { name: 'Math', value: 'MATH' },
            { name: 'reCAPTCHA v2', value: 'RECAPTCHA_V2' },
            { name: 'reCAPTCHA v3', value: 'RECAPTCHA_V3' },
            { name: 'hCaptcha', value: 'HCAPTCHA' },
            { name: 'Turnstile', value: 'TURNSTILE' }
          )
        )
        .addIntegerOption((o) =>
          applyOptionDescription(o.setName('min_account_age_days'), 'verify.setup.options.min_account_age_days')
            .setMinValue(0)
            .setMaxValue(365)
        )
        .addStringOption((o) =>
          applyOptionDescription(o.setName('fail_action'), 'verify.setup.options.fail_action')
            .addChoices(
              { name: 'Kick', value: 'KICK' },
              { name: 'Ban', value: 'BAN' },
              { name: 'None', value: 'NONE' }
            )
        )
        .addBooleanOption((o) =>
          applyOptionDescription(o.setName('alt_detection'), 'verify.setup.options.alt_detection')
        )
    )
    .addSubcommand((s) =>
      applyCommandDescription(s.setName('panel'), 'verify.panel.description')
        .addChannelOption((o) =>
          applyOptionDescription(
            o.setName('channel').addChannelTypes(ChannelType.GuildText),
            'verify.panel.options.channel'
          )
        )
    ),
  'verify.description'
);
