This commit is contained in:
Katalina / stardust 2018-01-06 17:40:52 -06:00
parent 7dd7c170b4
commit 86a222fb98
20 changed files with 291 additions and 46 deletions

View file

@ -49,10 +49,31 @@ module.exports = (R, $) => {
})
R.get('/api/auth/redirect', ctx => {
ctx.body = { url: $.discord.getAuthUrl() }
const url = $.discord.getAuthUrl()
if (ctx.query.url === '✔️') {
ctx.body = { url }
return
}
ctx.redirect(url)
})
R.post('/api/auth/logout', ctx => {
ctx.session = null
})
R.get('/api/oauth/bot', ctx => {
const url = $.discord.getBotJoinUrl()
if (ctx.query.url === '✔️') {
ctx.body = { url }
return
}
ctx.redirect(url)
})
R.get('/api/oauth/bot/callback', ctx => {
console.log(ctx.request)
})
}

View file

@ -67,9 +67,13 @@ module.exports = (R, $) => {
gm = await gm.addRoles(added.filter(pred))
}
if (removed.length > 0) {
gm = await gm.removeRoles(removed.filter(pred))
}
setTimeout(() => {
if (removed.length > 0) {
gm.removeRoles(removed.filter(pred))
}
}, 1000)
// console.log('role patch', { added, removed, allowedRoles, addedFiltered: added.filterNot(pred), removedFiltered: removed.filterNot(pred) })
ctx.body = { ok: true }
})