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

export const selfrolesCommandData = applyCommandDescription(
  new SlashCommandBuilder()
    .setName('selfroles')
    .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild)
    .addSubcommandGroup((group) =>
      applyCommandDescription(group.setName('panel'), 'selfroles.panel.description')
        .addSubcommand((sub) =>
          applyCommandDescription(sub.setName('create'), 'selfroles.panel.create.description')
            .addStringOption((o) =>
              applyOptionDescription(o.setName('title').setRequired(true), 'selfroles.panel.create.options.title')
            )
            .addStringOption((o) =>
              applyOptionDescription(o.setName('mode').setRequired(true), 'selfroles.panel.create.options.mode')
                .addChoices(
                  localizedChoice('selfroles.choice.mode.buttons', 'BUTTONS'),
                  localizedChoice('selfroles.choice.mode.dropdown', 'DROPDOWN'),
                  localizedChoice('selfroles.choice.mode.reactions', 'REACTIONS')
                )
            )
            .addStringOption((o) =>
              applyOptionDescription(
                o.setName('behavior').setRequired(true),
                'selfroles.panel.create.options.behavior'
              )
                .addChoices(
                  localizedChoice('selfroles.choice.behavior.normal', 'NORMAL'),
                  localizedChoice('selfroles.choice.behavior.unique', 'UNIQUE'),
                  localizedChoice('selfroles.choice.behavior.verify', 'VERIFY'),
                  localizedChoice('selfroles.choice.behavior.temporary', 'TEMPORARY')
                )
            )
            .addStringOption((o) =>
              applyOptionDescription(o.setName('roles').setRequired(true), 'selfroles.panel.create.options.roles')
            )
            .addChannelOption((o) =>
              applyOptionDescription(o.setName('channel').setRequired(true), 'selfroles.panel.create.options.channel')
                .addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement)
            )
            .addStringOption((o) =>
              applyOptionDescription(o.setName('description'), 'selfroles.panel.create.options.description')
            )
            .addStringOption((o) =>
              applyOptionDescription(o.setName('duration'), 'selfroles.panel.create.options.duration')
            )
        )
        .addSubcommand((sub) =>
          applyCommandDescription(sub.setName('edit'), 'selfroles.panel.edit.description')
            .addStringOption((o) =>
              applyOptionDescription(o.setName('panel_id').setRequired(true), 'selfroles.panel.common.options.panel_id')
            )
            .addStringOption((o) =>
              applyOptionDescription(o.setName('title'), 'selfroles.panel.create.options.title')
            )
            .addStringOption((o) =>
              applyOptionDescription(o.setName('description'), 'selfroles.panel.create.options.description')
            )
            .addStringOption((o) =>
              applyOptionDescription(o.setName('mode'), 'selfroles.panel.create.options.mode')
                .addChoices(
                  localizedChoice('selfroles.choice.mode.buttons', 'BUTTONS'),
                  localizedChoice('selfroles.choice.mode.dropdown', 'DROPDOWN'),
                  localizedChoice('selfroles.choice.mode.reactions', 'REACTIONS')
                )
            )
            .addStringOption((o) =>
              applyOptionDescription(o.setName('behavior'), 'selfroles.panel.create.options.behavior')
                .addChoices(
                  localizedChoice('selfroles.choice.behavior.normal', 'NORMAL'),
                  localizedChoice('selfroles.choice.behavior.unique', 'UNIQUE'),
                  localizedChoice('selfroles.choice.behavior.verify', 'VERIFY'),
                  localizedChoice('selfroles.choice.behavior.temporary', 'TEMPORARY')
                )
            )
            .addStringOption((o) =>
              applyOptionDescription(o.setName('roles'), 'selfroles.panel.create.options.roles')
            )
            .addStringOption((o) =>
              applyOptionDescription(o.setName('duration'), 'selfroles.panel.create.options.duration')
            )
        )
        .addSubcommand((sub) =>
          applyCommandDescription(sub.setName('delete'), 'selfroles.panel.delete.description').addStringOption(
            (o) =>
              applyOptionDescription(o.setName('panel_id').setRequired(true), 'selfroles.panel.common.options.panel_id')
          )
        )
    ),
  'selfroles.description'
);
