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

export const tagCommandData = applyCommandDescription(
  new SlashCommandBuilder()
    .setName('tag')
    .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild)
    .addSubcommand((sub) =>
      applyCommandDescription(sub.setName('create'), 'tag.create.description')
        .addStringOption((o) =>
          applyOptionDescription(o.setName('name').setRequired(true), 'tag.common.options.name')
        )
        .addStringOption((o) =>
          applyOptionDescription(o.setName('response_type').setRequired(true), 'tag.create.options.response_type')
            .addChoices(
              localizedChoice('tag.choice.response_type.text', 'TEXT'),
              localizedChoice('tag.choice.response_type.embed', 'EMBED')
            )
        )
        .addStringOption((o) =>
          applyOptionDescription(o.setName('content'), 'tag.create.options.content')
        )
        .addStringOption((o) =>
          applyOptionDescription(o.setName('embed_title'), 'tag.create.options.embed_title')
        )
        .addStringOption((o) =>
          applyOptionDescription(o.setName('embed_description'), 'tag.create.options.embed_description')
        )
        .addIntegerOption((o) =>
          applyOptionDescription(
            o.setName('embed_color').setMinValue(0).setMaxValue(0xffffff),
            'tag.create.options.embed_color'
          )
        )
        .addStringOption((o) =>
          applyOptionDescription(o.setName('trigger_word'), 'tag.create.options.trigger_word')
        )
        .addStringOption((o) =>
          applyOptionDescription(o.setName('allowed_roles'), 'tag.create.options.allowed_roles')
        )
        .addStringOption((o) =>
          applyOptionDescription(o.setName('allowed_channels'), 'tag.create.options.allowed_channels')
        )
    )
    .addSubcommand((sub) =>
      applyCommandDescription(sub.setName('edit'), 'tag.edit.description')
        .addStringOption((o) =>
          applyOptionDescription(o.setName('name').setRequired(true), 'tag.common.options.name')
        )
        .addStringOption((o) =>
          applyOptionDescription(o.setName('new_name'), 'tag.edit.options.new_name')
        )
        .addStringOption((o) =>
          applyOptionDescription(o.setName('response_type'), 'tag.create.options.response_type')
            .addChoices(
              localizedChoice('tag.choice.response_type.text', 'TEXT'),
              localizedChoice('tag.choice.response_type.embed', 'EMBED')
            )
        )
        .addStringOption((o) =>
          applyOptionDescription(o.setName('content'), 'tag.create.options.content')
        )
        .addStringOption((o) =>
          applyOptionDescription(o.setName('embed_title'), 'tag.create.options.embed_title')
        )
        .addStringOption((o) =>
          applyOptionDescription(o.setName('embed_description'), 'tag.create.options.embed_description')
        )
        .addIntegerOption((o) =>
          applyOptionDescription(
            o.setName('embed_color').setMinValue(0).setMaxValue(0xffffff),
            'tag.create.options.embed_color'
          )
        )
        .addStringOption((o) =>
          applyOptionDescription(o.setName('trigger_word'), 'tag.create.options.trigger_word')
        )
        .addStringOption((o) =>
          applyOptionDescription(o.setName('allowed_roles'), 'tag.create.options.allowed_roles')
        )
        .addStringOption((o) =>
          applyOptionDescription(o.setName('allowed_channels'), 'tag.create.options.allowed_channels')
        )
    )
    .addSubcommand((sub) =>
      applyCommandDescription(sub.setName('delete'), 'tag.delete.description').addStringOption((o) =>
        applyOptionDescription(o.setName('name').setRequired(true), 'tag.common.options.name')
      )
    )
    .addSubcommand((sub) =>
      applyCommandDescription(sub.setName('list'), 'tag.list.description')
    )
    .addSubcommand((sub) =>
      applyCommandDescription(sub.setName('info'), 'tag.info.description').addStringOption((o) =>
        applyOptionDescription(o.setName('name').setRequired(true), 'tag.common.options.name')
      )
    )
    .addSubcommand((sub) =>
      applyCommandDescription(sub.setName('run'), 'tag.run.description')
        .addStringOption((o) =>
          applyOptionDescription(o.setName('name').setRequired(true), 'tag.common.options.name')
        )
        .addStringOption((o) =>
          applyOptionDescription(o.setName('args'), 'tag.run.options.args')
        )
    ),
  'tag.description'
);
