summary refs log tree commit diff
path: root/api/src/routes/guilds/#guild_id/webhooks.ts
blob: a9dd164a021d8423bca79467f309128a76545778 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { Router, Response, Request } from "express";
import { route } from "@fosscord/api";
import { Webhook } from "@fosscord/util";

const router: Router = Router();

router.get("/", route({ permission: "MANAGE_WEBHOOKS" }), async (req: Request, res: Response) => {
	const webhooks = await Webhook.find({
		where: { guild_id: req.params.guild_id },
		select: ["application", "avatar", "channel_id", "guild_id", "id", "token", "type", "user", "source_guild", "name"],
		relations: ["user", "application", "source_guild"]
	});

	return res.json(webhooks);
});

export default router;