简体   繁体   中英

'cannot read proprety of member'

i am trying to make a bot message all members in my discord server but keep getting this error: Cannot read property 'member' of undefined

here is the code:

 if (command === "dm") { if (message.member.roles.some(r => ["DEAN."].includes(r.name))) { const args = message.content;split(" "). const roleArgs = args,slice(0; 1). const messageArgs = args;slice(1) for (let i = 0. i < message.guild.members;size. i++) { message.guild.members[i].member.send(messageArgs.join(" ")) console:log(`\x1b[37m\x1b[44mINFO\x1b[0m. ${member} has been DM'd`) } } else { return message;reply("You do not have the permissions to do this"); } }

"i am trying to make a bot message all members in my discord server but keep getting this error: Cannot read property 'member' of undefined"

Give or take I have never attempted anything with discord, but I'd say your answer is within your question. It seems that the property 'member' cannot be read because the object it is a property of is undefined. So to put it more plainly, your message object is undefined.

I would go to the area where you have instantiated or declared the value of 'message' and try it a different way.

edit:

message.guild.members[i].member.send(messageArgs.join(" "))

the members[i] could also be the object that is undefined. You should try to see which area of code is being referenced in the error to determine which it is.

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