user3012708
user3012708

Reputation: 946

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?

Upvotes: 2

Views: 387

Answers (2)

user3012708
user3012708

Reputation: 946

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.

Upvotes: 2

Beeeaaar
Beeeaaar

Reputation: 1035

You will likely need to set a flag for the event, then print later on another event.

You can send chat messages any time after you see the welcome message or after the welcome message was posted. Which is pretty soon after you able to receive events from your frames.


Here is what I would do to complete a similar mission:

Just put your send code in a macro to test it first. Don't worry about timing the message until you see it work in a macro.

You can make your own print to send generic messages to the chat window which should always work similar to:

function MyPrint( msg, r, g, b, frame, id)
    (frame or DEFAULT_CHAT_FRAME):AddMessage(msg, r or 1, g or 1, b or 0, id or 0)
end

-- put these in your event handlers
MyPrint("event PLAYER_ENTERING_WORLD")

MyPrint("event GUILD_ROSTER_UPDATE")

And use that for debugging instead.

You need to divide and conquer the problem, because there are so many things that could be wrong causing your issue, no one here can really have a definitive answer.

I know for sure that if you try to write to chat before the welcome message with print it at least used to not work. I remember spooling messages in the past until a certain event had fired then printing them.

Upvotes: 0

Related Questions