I have an issue with my discord bot which will be a board game bot (I hope). So, I try to assign to users their player number with roles like the first player will have the role 'Player 1' etc... But I always have the same issue:
let role = message.guild.roles.find("480091776468647936");
^
TypeError: Cannot read property 'roles' of undefined at Client. (C:\Users\alant\Desktop\Informatique - Développement\Shadow Bot\shadow_bot.js:54:32)
at emitOne (events.js:121:20)
at Client.emit (events.js:211:7)
at MessageCreateHandler.handle (C:\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
at WebSocketPacketManager.handle (C:\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:103:65)
at WebSocketConnection.onPacket (C:\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:330:35)
at WebSocketConnection.onMessage (C:\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:293:17)
at WebSocket.onMessage (C:\node_modules\ws\lib\EventTarget.js:99:16)
at emitOne (events.js:116:13)
at WebSocket.emit (events.js:211:7)
I already tried so search on Google by myself, but I'm making this bot as a hobby and don't have (yet) a deep knowledge on JavaScript so I expect some help. (Sorry if my English is bad, I'm not from an English speaking country)
bot.on('message', function(message) {
var message = message.content;
if (message === "joueur 1") {
membre = message.author;
let role = message.guild.role.find("480091776468647936");
membre.addRole(role);
message.channel.send("Vous etas doreavant le joueur 1 ! ")
}
})