Schmaniel Posted January 24, 2020 Report Posted January 24, 2020 I want to kick every user that is not in one of my groups. therefore I added a sleep inbetween the chatMessage and the removeFriend. Both are working, but not simultaneously. The user is getting kicked without the message being sent. function sleep(milliseconds) { var start = new Date().getTime(); for (var i = 0; i < 1e7; i++) { if ((new Date().getTime() - start) > milliseconds){ break; } } } user.chatMessage(`${row.SteamID64}`, "You are getting kicked, because you are not in one of our groups anymore"); sleep(5000); user.removeFriend(`${row.SteamID64}`); Quote
Dr. McKay Posted January 25, 2020 Report Posted January 25, 2020 By sleeping synchronously, you're preventing the module from actually sending the message over the network. You should almost never sleep synchronously in JavaScript. You're looking for the setTimeout function. vrtgn 1 Quote
Schmaniel Posted January 25, 2020 Author Report Posted January 25, 2020 Tried it with user.chatMessage(`${row.SteamID64}`, "You are getting kicked, because you are not in one of our groups anymore"); setTimeout(() => user.removeFriend(`${row.SteamID64}`), 5000); But I'm still getting kicked before I receive the message Quote
Schmaniel Posted January 26, 2020 Author Report Posted January 26, 2020 So there was a link to a Steamgroup in the chatMessage, that I censored, that caused that the message wasn't send. Quote
PonyExpress Posted March 7, 2020 Report Posted March 7, 2020 (edited) client.chat.sendFriendMessage(sid, "You are deleted. Bye-Bye!", null, (err, response) => { if (err) { // nothing } else { client.removeFriend(sid); } }); I think this should work. Or not? Edited March 7, 2020 by PonyExpress Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.