Sends a chat message


See also Chat functions.

Signature:

SendChatMessage("text" [, "chatType" [, languageIndex [, "channel"]]])

Arguments:

  • text - Message to be sent (up to 255 characters) (string)

  • chatType - Channel on which to send the message (defaults to SAY if omitted) (string)

    • CHANNEL - Message to a server or custom chat channel (sent with /1, /2, etc in the default UI); requires channel number for channel argument
    • DND - Enables Away-From-Keyboard status for the player, with text as the custom message seen by others attempting to whisper the player
    • EMOTE - Custom text emotes visible to nearby players (sent with /e in the default UI)
    • GUILD - Messages to guild members (sent with /g in the default UI)
    • INSTANCE_CHAT - Messages to a LFG/LFR instance group (sent with /i in the default UI)
    • OFFICER - Messages to guild officers (sent with /o in the default UI)
    • PARTY - Messages to party members (sent with /p in the default UI)
    • RAID - Messages to raid members (sent with /ra in the default UI)
    • RAID_WARNING - Warning to raid members (sent with /rw in the default UI)
    • SAY - Speech to nearby players (sent with /s in the default UI)
    • WHISPER - Message to a specific character (sent with /w in the default UI); requires name of the character for channel argument
    • YELL - Yell to not-so-nearby players (sent with /y in the default UI)

  • languageIndex - Language in which to send the message; defaults to Common (for Alliance players) or Orcish (for Horde players) if omitted. Language indices can be retrieved from GetLanguageByIndex(). (number)

  • channel - If chatType is WHISPER, name of the target character; if chatType is CHANNEL, number identifying the target channel; ignored otherwise (string)

Examples:

-- Send a chat message to the character the player is currently mousing over
-- This should be run as a macro (via keybind) so your mouse can be hovering
-- over a unit in the 3-D world, or a unit frame

local name = UnitName("mouseover")
SendChatMessage("Hey " .. name .. " I'm mousing over you!!!", "WHISPER", nil, name)

-- This can be run as a macro by putting it all on one line, and adding run
-- in front of it, like so:
--
-- /run local name = UnitName("mouseover"); SendChatMessage("Hey " .. name .. " I'm mousing over you!!!", "WHISPER", nil, name)
This function must query the remote server, and any results will not be immediately available to the game client. Please see the function's documentation for more information about how to retrieve any results.