Add PATCH guild settings route

This commit is contained in:
Isaac 2022-05-07 18:46:19 +01:00
parent cb4013337f
commit 66b46cf3e2

View File

@ -5,6 +5,22 @@ module.exports.get = fastify => ({
const settings = await client.prisma.guild.findUnique({ where: { id: req.params.guild } }) ??
await client.prisma.guild.create({ data: { id: req.params.guild } });
res.send(settings);
},
onRequest: [fastify.authenticate, fastify.isAdmin],
});
module.exports.patch = fastify => ({
handler: async (req, res) => {
/** @type {import('../../../../../client')} */
const client = res.context.config.client;
const settings = await client.prisma.guild.update({
data: req.body,
where: { id: req.params.guild },
});
res.send(settings);
},
onRequest: [fastify.authenticate, fastify.isAdmin],