Add authentication

This commit is contained in:
Isaac
2022-05-06 21:17:53 +01:00
parent 425e7ab151
commit a1823a750e
8 changed files with 105 additions and 5 deletions

View File

@@ -0,0 +1,7 @@
module.exports.get = fastify => ({
handler: (req, res) => {
const { client } = res.context.config;
return client.guilds.cache.get(req.params.guild);
},
onRequest: [fastify.authenticate],
});

View File

@@ -0,0 +1,9 @@
module.exports.get = fastify => ({
handler: async (req, res) => {
const { client } = res.context.config;
const user = await client.users.fetch(req.user.payload.id);
console.log(req.user.payload.username, user?.tag);
res.send(client.guilds.cache);
},
onRequest: [fastify.authenticate],
});