✨ added imagex to send images along messages
All checks were successful
Build OCI Images / build (push) Successful in 2m57s
All checks were successful
Build OCI Images / build (push) Successful in 2m57s
This commit is contained in:
parent
0e14cca2eb
commit
dc12389cf3
10 changed files with 1330 additions and 357 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue