Robert Lutece Posted June 24, 2023 Report Posted June 24, 2023 The code below uses the information provided by the chatRoomGroupMemberStateChange event to send a message through a chat group channel welcoming a user to the group. async function groupListener() { await client.chat.setSessionActiveGroups(["XXXXXXXX"]); console.log("Group set as active."); client.chat.on("chatRoomGroupMemberStateChange", async (details) => { if (details.change === 1) { const personas = await client.getPersonas([details.member.steamid]); const accountid = details.member.steamid.accountid; const steamID64 = details.member.steamid.getSteamID64(); const playerName = personas.personas[steamID64].player_name; await new Promise((resolve) => setTimeout(resolve, 2000)); await groupComment(0, accountid, playerName, "Welcome to the group!"); } }); } ✔️ If the bot is online and a user joins, the message is sent. If the user then leaves the chat and rejoins it, the message is sent too. ❌ However, if a joined user exits the chat while the bot is offline and then rejoins while the bot is online, there is an error: Error: Request timed out at Promises.timeoutPromise (USERPATH\steambot\node_modules\@doctormckay\stdlib\components\promises.js:12:12) at Promises.timeoutCallbackPromise (USERPATH\steambot\node_modules\@doctormckay\stdlib\components\promises.js:87:25) at SteamUser.getPersonas (USERPATH\steambot\node_modules\steam-user\components\friends.js:323:26) at SteamChatRoomClient.<anonymous> (USERPATH\steambot\Trashbot\trashBot.js:555:41) at SteamChatRoomClient.emit (node:events:512:28) at SteamUser.<anonymous> (USERPATH\steambot\node_modules\steam-user\components\chatroom.js:1186:12) at USERPATH\steambot\node_modules\steam-user\components\classes\HandlerManager.js:35:12 at Array.forEach (<anonymous>) at HandlerManager.emit (USERPATH\steambot\node_modules\steam-user\components\classes\HandlerManager.js:34:12) at SteamUser._handleMessage (USERPATH\steambot\node_modules\steam-user\components\03-messages.js:641:25) at SteamUser._handleNetMessage (USERPATH\steambot\node_modules\steam-user\components\03-messages.js:562:8) at SteamUser._processMulti (USERPATH\steambot\node_modules\steam-user\components\03-messages.js:693:9) Further leaving and rejoining throw no errors. Why is this the case and how can I fix this anomalous behaviour? Quote
Dr. McKay Posted June 25, 2023 Report Posted June 25, 2023 Sounds like Steam isn't replying to the getPersonas call. You might possibly need to add a short delay to give Steam time to realize that you share a chat room with the user you're requesting data for. Robert Lutece 1 Quote
Robert Lutece Posted June 25, 2023 Author Report Posted June 25, 2023 3 hours ago, Dr. McKay said: Sounds like Steam isn't replying to the getPersonas call. You might possibly need to add a short delay to give Steam time to realize that you share a chat room with the user you're requesting data for. It is working a little better now, but it still feels a bit clunky. I guess it is fine as it is. Thank you. 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.