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?