From 485432ce48bc137fdb6b7fcf944a81532cbc103c Mon Sep 17 00:00:00 2001 From: fzzinchemical Date: Thu, 10 Apr 2025 18:07:07 +0200 Subject: [PATCH] refactor: improve embed handling in yandereMessageHandler --- src/plugins/yandere/messages.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/plugins/yandere/messages.ts b/src/plugins/yandere/messages.ts index dbd35d2..b47e149 100644 --- a/src/plugins/yandere/messages.ts +++ b/src/plugins/yandere/messages.ts @@ -1,16 +1,16 @@ -import { Bot, Embed, Message } from "npm:discordeno@18.0.1"; +import { Bot, Message, transformEmbed } from "npm:discordeno@18.0.1"; import { defaultString } from "@root/defaultString.ts"; import { logMessage } from "@root/logging.ts"; import { getPosts } from "@root/plugins/yandere/api/api.ts"; -import { debug } from "node:console"; export async function yandereMessageHandler(bot: Bot, message: Message) { const command = message.content.split(" ").slice(1).join(" "); const args = command.match(/(\[\.+\])/g) if (command === "drop") { - const embed = await getPosts("[limit: 1]") + const embed = (await getPosts("[limit: 1]"))[0] + if (embed === undefined) throw Error("undefined embed") bot.helpers.sendMessage(message.channelId, { - embeds: [embed as Embed] + embeds: [transformEmbed(bot, embed)] }) } else if (command.startsWith("drop [") && command.endsWith("]")) { logMessage(message); @@ -18,7 +18,7 @@ export async function yandereMessageHandler(bot: Bot, message: Message) { const generatedEmbeds = await getPosts(args[0]); for (const embed of generatedEmbeds) { bot.helpers.sendMessage(message.channelId, { - embeds: [embed as Embed], + embeds: [transformEmbed(bot, embed)], }); } }