diff --git a/src/routes/api/guilds/[guild]/index.js b/src/routes/api/guilds/[guild]/index.js index eb854d5..e3fe35c 100644 --- a/src/routes/api/guilds/[guild]/index.js +++ b/src/routes/api/guilds/[guild]/index.js @@ -5,7 +5,6 @@ module.exports.get = fastify => ({ handler: async (req, res) => { const { client } = req.routeOptions.config; const guild = client.guilds.cache.get(req.params.guild); - if (!guild) return res.status(404).send(new Error('Not Found')); res.send({ id: guild.id, logo: iconURL(guild), diff --git a/src/routes/api/guilds/[guild]/tickets/@me.js b/src/routes/api/guilds/[guild]/tickets/@me.js new file mode 100644 index 0000000..d80e078 --- /dev/null +++ b/src/routes/api/guilds/[guild]/tickets/@me.js @@ -0,0 +1,18 @@ +module.exports.get = fastify => ({ + handler: async (req, res) => { + const { client } = req.routeOptions.config; + /** @type {import("@prisma/client").PrismaClient} */ + const prisma = client.prisma; + const guild = client.guilds.cache.get(req.params.guild); + res.send( + await prisma.ticket.findMany({ + where: { + createdById: req.user.id, + guildId: guild.id, + }, + }), + ); + }, + onRequest: [fastify.authenticate, fastify.isMember], +}); +