mirror of
https://github.com/roleypoly/roleypoly-v1.git
synced 2025-06-15 18:09:09 +00:00
MVP: finish give/remove roles practical example
This commit is contained in:
parent
3c545bdeaa
commit
d1f556b0f0
6 changed files with 82 additions and 29 deletions
|
@ -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 }
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue