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

export const scheduleCommandData = applyCommandDescription(
  new SlashCommandBuilder()
    .setName('schedule')
    .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild)
    .addSubcommand((sub) =>
      applyCommandDescription(sub.setName('create'), 'schedule.create.description')
        .addChannelOption((o) =>
          applyOptionDescription(o.setName('channel').setRequired(true), 'schedule.common.options.channel')
        )
        .addStringOption((o) =>
          applyOptionDescription(o.setName('content').setRequired(true), 'schedule.common.options.content')
        )
        .addStringOption((o) =>
          applyOptionDescription(o.setName('embed_title'), 'schedule.common.options.embed_title')
        )
        .addStringOption((o) =>
          applyOptionDescription(
            o.setName('embed_description'),
            'schedule.common.options.embed_description'
          )
        )
        .addIntegerOption((o) =>
          applyOptionDescription(
            o.setName('embed_color').setMinValue(0).setMaxValue(0xffffff),
            'schedule.common.options.embed_color'
          )
        )
        .addRoleOption((o) =>
          applyOptionDescription(o.setName('role'), 'schedule.common.options.role')
        )
        .addStringOption((o) =>
          applyOptionDescription(o.setName('when'), 'schedule.create.options.when')
        )
        .addStringOption((o) =>
          applyOptionDescription(o.setName('cron'), 'schedule.create.options.cron')
        )
    )
    .addSubcommand((sub) =>
      applyCommandDescription(sub.setName('list'), 'schedule.list.description')
    )
    .addSubcommand((sub) =>
      applyCommandDescription(sub.setName('delete'), 'schedule.delete.description').addStringOption(
        (o) => applyOptionDescription(o.setName('id').setRequired(true), 'schedule.common.options.id')
      )
    ),
  'schedule.description'
);

export const announceCommandData = applyCommandDescription(
  new SlashCommandBuilder()
    .setName('announce')
    .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild)
    .addChannelOption((o) =>
      applyOptionDescription(o.setName('channel').setRequired(true), 'schedule.common.options.channel')
    )
    .addStringOption((o) =>
      applyOptionDescription(o.setName('content').setRequired(true), 'schedule.common.options.content')
    )
    .addStringOption((o) =>
      applyOptionDescription(o.setName('embed_title'), 'schedule.common.options.embed_title')
    )
    .addStringOption((o) =>
      applyOptionDescription(o.setName('embed_description'), 'schedule.common.options.embed_description')
    )
    .addIntegerOption((o) =>
      applyOptionDescription(
        o.setName('embed_color').setMinValue(0).setMaxValue(0xffffff),
        'schedule.common.options.embed_color'
      )
    )
    .addRoleOption((o) =>
      applyOptionDescription(o.setName('role'), 'schedule.common.options.role')
    ),
  'announce.description'
);
