Files
Hotodog-Discord-Bot/src/plugins/yandere/messages.ts
2025-04-10 16:35:58 +02:00

25 lines
956 B
TypeScript

import { Bot, Embed, Message } 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]")
bot.helpers.sendMessage(message.channelId, {
embeds: [embed as Embed]
})
} else if (command.startsWith("drop [") && command.endsWith("]")) {
logMessage(message);
if (args === null) throw Error("args is null")
const generatedEmbeds = await getPosts(args[0]);
for (const embed of generatedEmbeds) {
bot.helpers.sendMessage(message.channelId, {
embeds: [embed as Embed],
});
}
}
}