feat: update this highly outdated app to use latest packages and custom configs (#1)

Reviewed-on: https://codeberg.org/nhcarrigan/tingle-bot/pulls/1
Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com>
Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
This commit is contained in:
2024-09-26 19:46:33 +00:00
committed by Naomi the Technomancer
parent 1339b63378
commit 7c0bd7ad10
74 changed files with 6348 additions and 8905 deletions

View File

@ -1,40 +1,46 @@
import { REST } from "@discordjs/rest";
import { Routes } from "discord-api-types/v9";
import { Client, WebhookClient } from "discord.js";
import { CommandList } from "../../commands/_CommandList";
import { WeatherCache } from "../../interfaces/WeatherCache";
import { scheduleForecasts } from "../../modules/scheduleForecasts";
import { logHandler } from "../../utils/logHandler";
/**
* @copyright nhcarrigan
* @license Naomi's Public License
* @author Naomi Carrigan
*/
import { REST, Routes, type Client, WebhookClient } from "discord.js";
import { commandList } from "../../commands/_commandList.js";
import { scheduleForecasts } from "../../modules/scheduleForecasts.js";
import { logHandler } from "../../utils/logHandler.js";
import type { WeatherCache } from "../../interfaces/weatherCache.js";
/**
* Handler for the READY event from Discord. Logs that the bot is connected,
* then registers the guild slash commands.
*
* @param {Client} BOT The bot's Discord instance.
* @param {WeatherCache} CACHE The cache of weather data.
* @param bot - The bot's Discord instance.
* @param cache - The cache of weather data.
*/
export const onReady = async (BOT: Client, CACHE: WeatherCache) => {
export const onReady = async (
bot: Client,
cache: WeatherCache
): Promise<void> => {
const webhook = new WebhookClient({ url: process.env.DEBUG_HOOK as string });
await webhook.send("Ruu Bot is online!");
logHandler.log("info", "Connected to Discord!");
const rest = new REST({ version: "9" }).setToken(
process.env.DISCORD_TOKEN as string
process.env.DISCORD_TOKEN ?? ""
);
const commandData = CommandList.map((command) => command.data.toJSON());
const commandData = commandList.map((command) => {
return command.data.toJSON();
});
await rest.put(
Routes.applicationGuildCommands(
BOT.user?.id || "oopsie whoopsie",
process.env.HOME_GUILD_ID as string
bot.user?.id ?? "oopsie whoopsie",
process.env.HOME_GUILD_ID ?? ""
),
{ body: commandData }
);
logHandler.log("info", "Registered commands!");
scheduleForecasts(CACHE);
scheduleForecasts(cache);
};