fix unsafe roles being usable, begin work on role/server editor

This commit is contained in:
Katalina / stardust 2017-12-24 03:22:41 -06:00
parent d1f556b0f0
commit bd15a812e5
20 changed files with 343 additions and 92 deletions

View file

@ -15,7 +15,10 @@ class DiscordService extends Service {
this.client = new discord.Client()
this.startBot()
}
ownGm (server) {
return this.gm(server, this.client.user.id)
}
async startBot () {
@ -45,6 +48,11 @@ class DiscordService extends Service {
}
}
safeRole (server, role) {
const r = this.getRoles(server).get(role)
return r.editable && !r.hasPermission('MANAGE_ROLES', false, true)
}
// oauth step 2 flow, grab the auth token via code
async getAuthToken (code) {
const url = 'https://discordapp.com/api/oauth2/token'

View file

@ -42,13 +42,14 @@ class PresentationService extends Service {
async rolesByServer (server) {
return server.roles
.filter(r => r.id !== server.id) // get rid of @everyone
.map(r => ({
id: r.id,
color: r.color,
name: r.name,
position: r.position
}))
.filter(r => r.id !== server.id) // get rid of @everyone
.map(r => ({
id: r.id,
color: r.color,
name: r.name,
position: r.position,
safe: this.discord.safeRole(server.id, r.id)
}))
}
}