bot.on('raw', async (raw) => {
if(raw.t === "MESSAGE_REACTION_ADD"){
if(raw.d.message_id === "770476453146001428")
{
var role = message.guild.roles.cache.find(role => role.id === "757820583508574340");
var user = message.guild.members.cache.get(raw.d.user_id);
user.roles.add(role)
}
}
});
Ошибка
(node:12944) UnhandledPromiseRejectionWarning: ReferenceError: message is not defined
at Client. (C:\Users\Kirill\Desktop\12\main.js:140:15)
at Client.emit (events.js:315:20)
at WebSocketShard.onMessage (C:\Users\Kirill\Desktop\12\node_modules\discord.js\src\client\websocket\WebSocketShard.js:295:27)
at WebSocket.onMessage (C:\Users\Kirill\Desktop\12\node_modules\ws\lib\event-target.js:125:16)
at WebSocket.emit (events.js:315:20)
at Receiver.receiverOnMessage (C:\Users\Kirill\Desktop\12\node_modules\ws\lib\websocket.js:797:20)
at Receiver.emit (events.js:315:20)
at Receiver.dataMessage (C:\Users\Kirill\Desktop\12\node_modules\ws\lib\receiver.js:437:14)
at Receiver.getData (C:\Users\Kirill\Desktop\12\node_modules\ws\lib\receiver.js:367:17)
at Receiver.startLoop (C:\Users\Kirill\Desktop\12\node_modules\ws\lib\receiver.js:143:22)
(node:12944) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_reje...). (rejection id: 1)
(node:12944) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Александр, коротко я пытаюсь сделать так если нажать на реакцию то выдасца роль но я не знаю как это сделать в документаций по discord.js я не очень разбираюсь
let usera = message.content.split(" ").slice(1)[0];
let nomber = message.content.split(" ").slice(2)[0].split("")[0];
let time = message.content.split(" ").slice(2)[0].split("")[1];
let reason = message.content.split(" ").slice(3)[0];
console.log(time);
let timer = 0;
let role = message.guild.roles.cache.get("1181214927566946344")
let user = message.guild.members.cache.get(usera);
user.roles.add(role)
делаю команду на мут ошибку выдаёт:
user.roles.add(role)
^
TypeError: Cannot read properties of undefined (reading 'roles')