🚑️ add error catching so that it doesnt not explode and restart
🐛 make it actually ping registered roles
This commit is contained in:
parent
0151b10ad2
commit
4e61307743
1 changed files with 24 additions and 4 deletions
|
|
@ -3,7 +3,12 @@ import "dotenv/config";
|
||||||
import { database } from "@datamine/database";
|
import { database } from "@datamine/database";
|
||||||
import { REST } from "@discordjs/rest";
|
import { REST } from "@discordjs/rest";
|
||||||
import { serve } from "@hono/node-server";
|
import { serve } from "@hono/node-server";
|
||||||
import { Routes, type APIEmbed } from "discord-api-types/v10";
|
import {
|
||||||
|
AllowedMentionsTypes,
|
||||||
|
Routes,
|
||||||
|
type APIEmbed,
|
||||||
|
type RESTPostAPIChannelMessageJSONBody,
|
||||||
|
} from "discord-api-types/v10";
|
||||||
import { Hono } from "hono";
|
import { Hono } from "hono";
|
||||||
import { validator } from "hono/validator";
|
import { validator } from "hono/validator";
|
||||||
|
|
||||||
|
|
@ -31,9 +36,24 @@ const dispatch = app
|
||||||
const body = await c.req.valid("json");
|
const body = await c.req.valid("json");
|
||||||
const servers = await database.query.servers.findMany();
|
const servers = await database.query.servers.findMany();
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
rest.post(Routes.channelMessages(`${BigInt(server.channel)}`), {
|
try {
|
||||||
body: { embeds: [body] },
|
await rest.post(
|
||||||
});
|
Routes.channelMessages(`${BigInt(server.channel)}`),
|
||||||
|
{
|
||||||
|
body: {
|
||||||
|
content: server.role
|
||||||
|
? `<@&${BigInt(server.role)}>`
|
||||||
|
: "",
|
||||||
|
embeds: [body],
|
||||||
|
allowed_mentions: {
|
||||||
|
parse: [AllowedMentionsTypes.Role],
|
||||||
|
},
|
||||||
|
} satisfies RESTPostAPIChannelMessageJSONBody,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return c.text(`Fanning out to ${servers.length} servers.`);
|
return c.text(`Fanning out to ${servers.length} servers.`);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue