Start implementing webhooks

This commit is contained in:
Puyodead1
2023-12-10 17:02:27 -05:00
parent 0a6f6a095d
commit 99d9bf563f
11 changed files with 5029 additions and 401 deletions
+30 -5
View File
@@ -16,12 +16,37 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { Router, Response, Request } from "express";
import { route } from "@spacebar/api";
import { Webhook } from "@spacebar/util";
import { Request, Response, Router } from "express";
const router = Router();
//TODO: implement webhooks
router.get("/", route({}), async (req: Request, res: Response) => {
res.json([]);
});
router.get(
"/",
route({
description:
"Returns a list of guild webhook objects. Requires the MANAGE_WEBHOOKS permission.",
permission: "MANAGE_WEBHOOKS",
responses: {
200: {
body: "APIWebhookArray",
},
},
}),
async (req: Request, res: Response) => {
const { guild_id } = req.params;
const webhooks = await Webhook.find({
where: { guild_id },
relations: [
"user",
"guild",
"source_guild",
"application" /*"source_channel"*/,
],
});
return res.json(webhooks);
},
);
export default router;