import { SlashCommandBuilder } from "discord.js";
import type { CommandModule } from "../../discord/types.js";
import { notifyService } from "../../services/notify/notify-service.js";

export const notifyListCommand: CommandModule = {
  data: new SlashCommandBuilder().setName("notify_list").setDescription("활성 알림 규칙 목록"),
  async execute(interaction) {
    if (!interaction.guildId) return;
    const rules = await notifyService.listRules(interaction.guildId);
    if (rules.length === 0) {
      await interaction.reply("활성 알림 규칙이 없습니다.");
      return;
    }
    const msg = rules
      .map((r) => `- ${r.id} | <#${r.channelId}> | \`${r.cronExpr}\` | ${r.message.slice(0, 40)}`)
      .join("\n");
    await interaction.reply(msg);
  },
};
