Jump to content
Toggle menu
  • 17.3K articles
  • 8.2K files
  • 5 users
  • 280.7K edits
WoW Classic Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

API SendChatMessage

From WoW Classic Wiki

Sends a chat message.

SendChatMessage("msg",[ "chatType",[ "language",[ "channel"]]]);

Parameters

Arguments

(msg, chatType, language, channel)
msg
String, The message to be sent, maximum length of 255 characters.
chatType
String - (Optional) The type of chat message to be sent, "SAY", "PARTY", etc. See the list of chatTypeIds.
If chatType is nil or omitted then "SAY" will be used.
language
String - (Optional) The language used to translate the message.
Languages: "COMMON", "DARNASSIAN", "DWARVISH", "TAURAHE", "ORCISH", "GUTTERSPEAK", "DEMONIC", "DRACONIC", "KALIMAG", "TITAN", "GNOMISH"
If language is nil or omitted the default language will be used: "ORCISH" for the Horde, and "COMMON" for the Alliance, as returned by GetDefaultLanguage("player").
channel
String - The channel or player receiving the message for "CHANNEL"/"WHISPER" communication. If sending to a channel you must use the number (eg. "1"); obtain it using GetChannelName("channelName"). This field is required for the "CHANNEL"/"WHISPER" chat types and ignored for any other chat type.

Returns

nil

Example

SendChatMessage("Hello Bob!", "WHISPER", "Common", "Bob");

Result

To [Bob]: Hello Bob!

Example

local s = "Hello World"
local index = GetChannelName("General") -- It finds General is a channel at index 1
if (index~=nil) then 
  SendChatMessage(s , "CHANNEL", nil, index); 
end

Result

[1. General - Current Zone Name][Bob]: Hello World


Details

Sends a chat message of the specified in 'msg' (ex. "Hey!"), to the system specified in 'system' ("SAY", "WHISPER", "EMOTE", "CHANNEL", "PARTY", "GUILD", "OFFICER", "YELL", "RAID", "RAID_WARNING", "AFK", "DND"), in the language specified in 'language' ("COMMON", "DARNASSIAN", "DWARVISH", "TAURAHE", "ORCISH", "GUTTERSPEAK", "DEMONIC", "DRACONIC", "KALIMAG", "TITAN", "GNOMISH"), to the player or channel specified in 'channel'(ex. "1", "Bob").
Notes
"AFK" and "DND" set your AFK or DND auto-reply. To cancel afk/dnd status, send another message to the same 'channel'.
It should be noted that you must provide a 'language' (be it nil or an actual language name) before the 'channel' when sending to the "WHISPER" or "CHANNEL" system.
To send a whisper to the player's selected target, use UnitName("target") as the Channel.
Patch 1.11 added the "RAID_WARNING" system, only useable by the raid leader and raid assistants. The default UI shows messages send via "RAID_WARNING" in big letters on the center of the screen.
Some channels may have restrictions on who may speak in them. For example, in order to speak in the 'World Defense' channel, you must have a PvP rank of 11 or higher.