Search code examples
luaworld-of-warcraft

When can i use SendChatMessage after logon?


After logon, i would like to send a chat message to the Guild channel. I'm currently listening for events: PLAYER_ENTERING_WORLD GUILD_ROSTER_UPDATE

Once those have fired (in order), i'd like to send a chat message. However, it never sends. Code:

print("Should_send")
SendChatMessage(msgToSend, "GUILD");

It's also worth noting that if i then trigger this manually, it works. I do see the "Should_send" print statement appearing in the default chat window each time - as expected. I've also checked that "msgToSend" contains content - and is less than 255 characters.

So, when can i call SendChatMessage?


Solution

  • Ok, in order to be able to send a chat message to guild, you need to wait for the event "CLUB_STREAM_SUBSCRIBED" to fire.

    This is due to the Guild channel becoming a "community" channel of sorts - previously, it seems this wasn't required.

    So, adding an event listener:

    frame:RegisterEvent("CLUB_STREAM_SUBSCRIBED");
    

    Resolves the issue.