const client = require("../index"); const wolfcount = require('../models/wolfcount'); // When a message is sent, check if the message includes the letters of wolf const wolfChars = ['w', 'o', 'l', 'f']; client.on("messageCreate", async (message) => { if (message.author.bot) return; if (message.content.includes(">>")) return; // convert the message to lowercase const lowerMsg = message.content.toLowerCase(); // console.log(lowerMsg); // check if the message has the letters if (wolfChars.every(char=>lowerMsg.includes(char))) { message.react("🐺").catch(err=>console.log(err)); newcount = basecount + 1; // client.user.setPresence({ // // activities: [{ name: `${newcount} message(s) detected`, type: ActivityType.Watching }], // activities: [{ name: `${newcount} message(s) detected` }], // status: 'dnd', // }); basecount = newcount; console.log(''); console.log('Live wolf count:', newcount); // update the wolf count wolfcount.findByIdAndUpdate("6447da87681fd1bc486a4923", {count: newcount}).then(() => { console.log('Count updated!'); }).catch((error) => { console.error(error); }); } });