问题
So i have a discord bot, and i have been forking some code and basically experminting. my synax is right however it says TypeError: Cannot read property 'add' of undefined when i try to make my discord.js bot add a role.
client.guilds.get(config.guild).member(message.author).role.add(config.role) // ensure this is a string in the config ("")
.then(console.log(`TOKEN: ${message.author.token} :: Role ${config.role} added to member ${message.author.id}`))
.catch(console.error)
})
Could someone please explain how to fix this as i am still noobish at this.
回答1:
Found out what was wrong, the Role ID Was invalid for some reason, Doing \@role
did the trick.
来源:https://stackoverflow.com/questions/53368797/typeerror-cannot-read-property-add-of-undefined-discord-js