added imagex to send images along messages
All checks were successful
Build OCI Images / build (push) Successful in 2m57s

This commit is contained in:
Rose 2024-09-11 13:19:35 -04:00
parent 0e14cca2eb
commit dc12389cf3
No known key found for this signature in database
10 changed files with 1330 additions and 357 deletions

View file

@ -1,6 +1,7 @@
import "dotenv/config";
import { database } from "@datamine/database";
import { extract } from "@datamine/imagex";
import { REST } from "@discordjs/rest";
import { serve } from "@hono/node-server";
import {
@ -34,6 +35,8 @@ const dispatch = app
),
async (c) => {
const body = await c.req.valid("json");
// biome-ignore lint/style/noNonNullAssertion: it will always have a description and I am sure about this :3
const images = extract(body.description!);
const servers = await database.query.servers.findMany();
for (const server of servers) {
try {
@ -51,6 +54,19 @@ const dispatch = app
} satisfies RESTPostAPIChannelMessageJSONBody,
},
);
if (images.length > 0) {
await rest.post(
Routes.channelMessages(`${BigInt(server.channel)}`),
{
body: {
content: images.join("\n"),
allowed_mentions: {
parse: [AllowedMentionsTypes.Role],
},
} satisfies RESTPostAPIChannelMessageJSONBody,
},
);
}
} catch (error) {
console.error(error);
}