process.on("message", (data) => {
console.log("message recieved");
switch (data.key) {
case 1: //create a message for groups
const createGMsg = async () => {
try {
task1 = true;
console.log("sendthe message");
await clientMain.sendMessage(Admin, "Envie mensaje Grupal porfavor");
message = await waitForResponse(clientMain, Admin);
await GmsgModel.addGMsg(message, data.id);
for some reason, client.sendmessage crashes
the client is already ready but it still crashes, the Admin phone number is correct, it uses the @c.us and everything
(solved by encapsuling the sendmessage code on the event client.on(ready). And the process.on needed to be async