[英]Discord.js - filter who has specific role in object
I have an object.我有一个 object。 I want to make this object to show only those who have the role I have specified.
我想让这个 object 只显示那些我指定的角色。 The object gets the data from the "quick.db" module.
object 从“quick.db”模块获取数据。 for exp my object like this =
对于 exp 我的 object 像这样 =
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.此处的 object 显示了我在“quick.db”模块中指定的所有数据。 I just want to show the data of the people (IDs) who have the role I have specified.
我只想显示具有我指定角色的人员 (ID) 的数据。 how can i do like that?
我怎么能那样做? also im get object like this
我也像这样得到 object
var users = db.all().filter(x => x.ID.startsWith(`totalMessage`)).sort((a, b) => b.data - a.data)
okay i did with filter()
好吧,我用
filter()
let filter = users.filter(function(member) {
return message.guild.member(member.ID).roles.has("role id")
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.