(node:17712) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'guild' of undefined
at Client. (C:\Users\kuchm\Desktop\DSTBOT\index.js:224:27)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:17712) 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:17712) [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.
client.on('messageReactionAdd', async (reaction, user,message) => {
if (reaction.partial) {
try {
await reaction.fetch();
} catch (error) {
console.error('Something went wrong when fetching the message: ', error);
return;
}
}
console.log(`${reaction.message.author}'s message "${reaction.message.content}" gained a reaction!`);
console.log(`${reaction.count} user(s) have given the same reaction to this message!`);
var role1 = message.guild.roles.cache.find(role => role.id === "786640140440567849");
guild.addRole(role1);
if(reaction.message.content == 'Поставь реакцию если не бот'){
}
});
messageReactionAdd
принимает лишь два параметра - messageReaction (объект реакции) и user (пользователь, поставивший реакцию на сообщение) - параметра message не существует.reaction.message...
reaction.
перед message
..get()
для получения чего-либо по ID, а.find()
- для поиска по названию/цвету и т.п