API C_ChatInfo.SendAddonMessage

From Wowpedia
Jump to: navigation, search

Sends a message to the hidden addon channel.

success = C_ChatInfo.SendAddonMessage("prefix", "message" [, "chatType", "target"])

Arguments

prefix 
string - Message prefix, can be used as your addon identifier; at most 15 characters.
message 
string - Text to send, at most 250 characters.
chatType 
string (optional) - AddOn channel to send to. Valid types are "PARTY", "RAID", "GUILD", "BATTLEGROUND", "WHISPER", and "CHANNEL". Defaults to "PARTY".
target 
string (optional) - Used only for "WHISPER" and "CHANNEL" communications - the player to whisper to for "WHISPER" or the channel id (e.g 6) to broadcast to for "CHANNEL".

Returns

success 
boolean - Whether the message was successfully sent.

Details

  • Calling this function results in the event CHAT_MSG_ADDON being invoked on:
    • <target>'s client if <type> is "WHISPER" or
    • all clients in the <type> chat channel, otherwise
  • Messages sent to "RAID" while in a party will get delivered to "PARTY" (note that in an arena, messages to "RAID" will cause the error "You are not in a raid group.")
  • Messages sent to <type> when you are not in the specified community will not be delivered.
  • Except NULL (ASCII 0) all characters (decimal ID 1-255) are allowed (in opposition to SendChatMessage where many characters are disallowed).
  • Messages sent as "WHISPER" to players from another server will silently fail unless the target is from a realm connected to the player's realm (same auction house, same major city channels). When sending messages to a player from a connected realm, the target has to be formed as "PlayerName-RealmName".
  • The message will not be affected by the player's level of drunkenness.
  • For addons that send user generated content, consider using C_ChatInfo.SendAddonMessageLogged (added in Patch 8.0.1), as the messages will then be logged and visible for game masters in case of reports for content that violates the terms of service.
  • The prefix should be registered using API C ChatInfo.RegisterAddonMessagePrefix if you want to later receive those messages.

Patch changes

  • Battle for Azeroth Patch 8.0.1 (2018-07-17): Moved into the C_ChatInfo table.
  • Warlords of Draenor Patch 6.0.2 (2014-10-14): "CHANNEL" is now a supported "type" to send addon messages over a custom chat channel. The "target" argument is the name of the custom chat channel to use. The message will be sent to every player who joined this custom chat channel and have registered the addon prefix.
  • Cataclysm Patch 4.1.0 (2011-04-26): Addons should now register which prefixes they want to receive addon messages for using C_ChatInfo.RegisterAddonMessagePrefix.
  • The Burning Crusade Patch 2.1.0 (2007-05-22): The "WHISPER" mode was added, as servers will begin to rate throttle regular whispers to alleviate spam problems.
  • WoW Icon update.png Patch 1.12.0 (2006-08-22): Added.

See also