Can someone tell me what I did wrong?
/*
bot.on('message', message =>{
if(message.author.bot) return;
const TicketToolEmbed = new Discord.MessageEmbed()
.setTitle("Creat a support Ticket")
.setDescription("React to this message to open a support ticket with the Server Administrators")
.setColor("#B900FF")
.setTimestamp()
.setFooter("Ticket Bot System")
message.channel.send(TicketToolEmbed)
.then(message => message.react('✅'))
.catch(err => console.log(err));
}); */
bot.on('raw', async payload => {
let eventname = payload.t;
if (eventname === 'MESSAGE_REACTION_ADD') {
let msgId = payload.d.message_id;
if (msgId === '712016328189411348') {
let channelId = payload.d.channelId;
let channel = Client.channels.get(channelId);
if (channel) {
if (channel.message.has(msgId))
return;
else {
try {
let msg = await channel.fetchMessage(msgId);
let reaction = msg.reaction.get('✅');
let user = Client.user.get(payload.d.user_id);
Client.emit('messageReactionAss', reaction, user);
}
catch (ex) {
console.log(ex);
return;
}
}
}
}
}
});
bot.on('messageReactionAdd', (reaction, user) => {
if(reaction.emoji.name === '✅') {
console.log("Creating ticket...");
}
else {
console.log("Wrong emoji");
}
});
Console:
(node:11924) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'get' of undefined
at Client.<anonymous> (C:\Users\sande\Desktop\discbot\index.js:65:43)
at Client.emit (events.js:310:20)
at WebSocketShard.onMessage (C:\Users\sande\Desktop\discbot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:287:27)
at WebSocket.onMessage (C:\Users\sande\Desktop\discbot\node_modules\ws\lib\event-target.js:125:16)
at WebSocket.emit (events.js:310:20)
at Receiver.receiverOnMessage (C:\Users\sande\Desktop\discbot\node_modules\ws\lib\websocket.js:800:20)
at Receiver.emit (events.js:310:20)
at Receiver.dataMessage (C:\Users\sande\Desktop\discbot\node_modules\ws\lib\receiver.js:436:14)
at Receiver.getData (C:\Users\sande\Desktop\discbot\node_modules\ws\lib\receiver.js:366:17)
at Receiver.startLoop (C:\Users\sande\Desktop\discbot\node_modules\ws\lib\receiver.js:142:22)
(node:11924) 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_rejections_mode). (rejection id: 1)
(node:11924) [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.