fix(discord-bot): query active quest of latest in quete command
All checks were successful
Build and Push Docker Image / build (push) Successful in 31s
All checks were successful
Build and Push Docker Image / build (push) Successful in 31s
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
import { EmbedBuilder } from "discord.js";
|
import { EmbedBuilder } from "discord.js";
|
||||||
import type { Command } from "~/commands";
|
import type { Command } from "~/commands";
|
||||||
import { getLatestQuest } from "~/services/wov";
|
import { getActiveQuest, getLatestQuest } from "~/services/wov";
|
||||||
|
|
||||||
export const queteCommand: Command = async (message) => {
|
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);
|
const color = parseInt(quest.quest.promoImagePrimaryColor.substring(1), 16);
|
||||||
|
|
||||||
await message.reply({
|
await message.reply({
|
||||||
|
|||||||
@@ -28,6 +28,18 @@ export const getLatestQuest = async (): Promise<QuestResult> => {
|
|||||||
return history[0];
|
return history[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getActiveQuest = async (): Promise<QuestResult | null> => {
|
||||||
|
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<QuestResult | null> => {
|
export const checkForNewQuest = async (): Promise<QuestResult | null> => {
|
||||||
const lastQuest = await getLatestQuest();
|
const lastQuest = await getLatestQuest();
|
||||||
const lastId = lastQuest.quest.id;
|
const lastId = lastQuest.quest.id;
|
||||||
|
|||||||
Reference in New Issue
Block a user