/**
 * @copyright nhcarrigan
 * @license Naomi's Public License
 * @author Naomi Carrigan
 */
import { onInteraction } from "./handlers/onInteraction.js";
import { onReady } from "./handlers/onReady.js";
import type { WeatherCache } from "../interfaces/weatherCache.js";
import type { Client } from "discord.js";

/**
 * Mounts listeners for the Discord gateway events.
 * @param bot - The bot's discord instance.
 * @param cache - The cache of weather data.
 */
export const handleEvents = (bot: Client, cache: WeatherCache): void => {
  bot.on("ready", async() => {
    await onReady(bot, cache);
  });

  bot.on(
    "interactionCreate",
    async(interaction) => {
      await onInteraction(interaction, cache);
    },
  );
};
