mirror of
https://github.com/roleypoly/roleypoly-v1.git
synced 2025-06-15 01:49:10 +00:00
sync: full redux retrofit done
This commit is contained in:
parent
cfc623b228
commit
f5220aa6dc
14 changed files with 206 additions and 122 deletions
|
@ -2,7 +2,9 @@ module.exports = (R, $) => {
|
|||
R.get('/api/servers', async (ctx) => {
|
||||
const { userId } = ctx.session
|
||||
const srv = $.discord.getRelevantServers(userId)
|
||||
ctx.body = $.discord.presentableServers(srv, userId)
|
||||
const presentable = $.discord.presentableServers(srv, userId)
|
||||
|
||||
ctx.body = presentable
|
||||
})
|
||||
|
||||
R.get('/api/server/:id', async (ctx) => {
|
||||
|
@ -18,8 +20,8 @@ module.exports = (R, $) => {
|
|||
}
|
||||
|
||||
const gm = srv.members.get(userId)
|
||||
const roles = $.discord.presentableRoles(id, gm)
|
||||
const server = $.discord.presentableRoles(id, gm)
|
||||
|
||||
ctx.body = roles
|
||||
ctx.body = server
|
||||
})
|
||||
}
|
||||
|
|
|
@ -41,22 +41,26 @@ class DiscordService extends Service {
|
|||
ownerID: server.ownerID,
|
||||
icon: server.icon
|
||||
},
|
||||
roles: this.presentableRoles(server.id, gm),
|
||||
message: 'moe moe kyuuuuuuuuun~',
|
||||
perms: this.getPermissions(gm)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
presentableRoles (serverId, gm) {
|
||||
return this.client.guilds.get(serverId).roles.filter(r => r.id !== serverId).map((role) => {
|
||||
return {
|
||||
color: role.hexColor,
|
||||
position: role.position,
|
||||
calculatedPosition: role.calculatedPosition,
|
||||
id: role.id,
|
||||
name: role.name,
|
||||
selected: gm.roles.has(role.id)
|
||||
}
|
||||
})
|
||||
return this.client.guilds
|
||||
.get(serverId)
|
||||
.roles
|
||||
.filter(r => r.id !== serverId)
|
||||
.map((role) => ({
|
||||
color: role.hexColor,
|
||||
position: role.position,
|
||||
calculatedPosition: role.calculatedPosition,
|
||||
id: role.id,
|
||||
name: role.name,
|
||||
selected: gm.roles.has(role.id)
|
||||
}))
|
||||
}
|
||||
|
||||
getPermissions (gm) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue