简体   繁体   中英

Discord.js - filter who has specific role in object

I have an object. I want to make this object to show only those who have the role I have specified. The object gets the data from the "quick.db" module. for exp my object like this =

var users = [
{ ID: 747374763, data: 45600},
{ ID: 1111....., data: 33333},
.........{ ID: 22222, data: 4444}
]

the object here shows all of the data I specified in the "quick.db" module. I just want to show the data of the people (IDs) who have the role I have specified. how can i do like that? also im get object like this

var users = db.all().filter(x => x.ID.startsWith(`totalMessage`)).sort((a, b) => b.data - a.data)

okay i did with filter()

 let filter = users.filter(function(member) {
return message.guild.member(member.ID).roles.has("role id")
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM