MVP: finish give/remove roles practical example

This commit is contained in:
Katalina / stardust 2017-12-23 04:31:52 -06:00
parent 3c545bdeaa
commit d1f556b0f0
6 changed files with 82 additions and 29 deletions

View file

@ -24,4 +24,24 @@ module.exports = (R, $) => {
ctx.body = server
})
R.patch('/api/servers/:server/roles', async ctx => {
const { userId } = ctx.session
const { server } = ctx.params
let gm = $.discord.gm(server, userId)
const { added, removed } = ctx.request.body
if (added.length > 0) {
gm = await gm.addRoles(added)
}
if (removed.length > 0) {
gm = await gm.removeRoles(removed)
}
console.log(gm.roles)
ctx.body = { ok: true }
})
}