Files
lbf-bot/apps/discord-bot/src/commands/quete.ts

31 lines
1.1 KiB
TypeScript

import { EmbedBuilder } from "discord.js";
import { getActiveQuest, getLatestQuest } from "~/wov";
import { replyError } from "~/discord";
import type { Command } from "./index";
import { noMention } from "~/discord";
export const queteCommand: Command = {
help: "Affiche la quête en cours ou la dernière quête",
handler: async (message) => {
const quest = (await getActiveQuest()) ?? (await getLatestQuest());
if (!quest) {
await replyError(message, "Impossible de récupérer la quête.");
return;
}
const color = parseInt(quest.quest.promoImagePrimaryColor.substring(1), 16);
const emoji = quest.quest.purchasableWithGems ? "💎" : "🪙";
await message.channel.send({
options: noMention,
embeds: [
new EmbedBuilder()
.setDescription(`### Quête actuelle ${emoji}${emoji}${emoji}`)
.setImage(quest.quest.promoImageUrl)
.setColor(color)
],
});
await message.delete();
},
};