client.on('messageReactionAdd', async (reaction, user) => { console.log(0) try { console.log(1) if (user.bot) return; console.log(2) if (reaction.emoji.name === `🎫`) { console.log(3) const existingTicketConfig = await pool.query(`SELECT * FROM ticketconfig WHERE messageId = ${reaction.message.id}`) console.log(4) if (!existingTicketConfig) { console.log(5) reaction.message.channel.send(`This server is not setup in the ticket config database yet. Please contact the server owner and ask them to set it`); console.log(6) } else { console.log(7) const reactionMessage = existingTicketConfig[0][0].messageId console.log(8) if (!reaction.message.id === reactionMessage) { console.log(9) return; } else { console.log(10) const findTicket = await pool.query(`SELECT * FROM tickets WHERE authorId = ${user.id} AND resolved = 0`); console.log(11) if (!findTicket) { console.log(12) reaction.message.channel.send(`You ticket is being created.`) } else { console.log(13) reaction.message.channel.send(`You already have a ticket. Please resolve that one before creating another.`) console.log(14) } console.log(15) } console.log(16) } console.log(17) } else { console.log(18) reaction.message.channel.send(`Hi`) console.log(19) } console.log(20) } catch (e) { console.log(e) } });