问题
pls help
CODE case 'clear': if(!message.member.roles.find(r => r.name === "OWNER"))
OUTPUT
if(!message.member.roles.find(r => r.name === "OWNER"))
TypeError: message.member.roles.find is not a function
回答1:
GuildMember.roles returns an object of type GuildMemberRoleManager. To get the roles from this you want to use GuildMemberRoleManager.cache. This returns an object of type Collection<Snowflake, Role>. Once you have that, you can use Collection.find(fn, [thisArg]). BUT, in your specific case, you'd want to use Collection.some(fn, [thisArg]). The some method checks if a specific item exists based on a function.
Your code would instead look like this:
if(!message.member.roles.cache.some(r => r.name === "OWNER")) {
//your code here
}
来源:https://stackoverflow.com/questions/60623190/discord-js-typeerror-message-member-roles-find-is-not-a-function