diff --git a/apps/discord-bot/src/commands/quete.ts b/apps/discord-bot/src/commands/quete.ts index 50d9e71..19c5000 100644 --- a/apps/discord-bot/src/commands/quete.ts +++ b/apps/discord-bot/src/commands/quete.ts @@ -1,9 +1,9 @@ import { EmbedBuilder } from "discord.js"; import type { Command } from "~/commands"; -import { getLatestQuest } from "~/services/wov"; +import { getActiveQuest, getLatestQuest } from "~/services/wov"; export const queteCommand: Command = async (message) => { - const quest = await getLatestQuest(); + const quest = (await getActiveQuest()) ?? (await getLatestQuest()); const color = parseInt(quest.quest.promoImagePrimaryColor.substring(1), 16); await message.reply({ diff --git a/apps/discord-bot/src/services/wov.ts b/apps/discord-bot/src/services/wov.ts index a3c16bb..b0dfeb7 100644 --- a/apps/discord-bot/src/services/wov.ts +++ b/apps/discord-bot/src/services/wov.ts @@ -28,6 +28,18 @@ export const getLatestQuest = async (): Promise => { return history[0]; }; +export const getActiveQuest = async (): Promise => { + const response = await fetch( + `https://api.wolvesville.com/clans/${env.WOV_CLAN_ID}/quests/active`, + { + method: "GET", + headers: { Authorization: `Bot ${env.WOV_API_KEY}` }, + }, + ); + if (response.status === 404) return null; + return (await response.json()) as QuestResult; +}; + export const checkForNewQuest = async (): Promise => { const lastQuest = await getLatestQuest(); const lastId = lastQuest.quest.id;