Sends a chat-like message receivable by other addons. Allows for client-to-client addon communication.

Unlike with SendChatMessage, messages sent via SendAddonMessage:

  • do not appear in receiving players' chat windows (unless an addon explicitly prints them)
  • are not subject to strict server-side spam filtering/throttling (sending too many messages at once can still disconnect the user)
  • are not modified if the sending character is drunk

Messages are received via the CHAT_MSG_ADDON event. The client utilizes the prefix string to filter messages; only those prefixes which have been registered will be received. Prefixes can be registered using RegisterAddonMessagePrefix.

There is currently no support for sending addon messages to Real ID or BattleTag friends.


See also Addon-related functions.

Signature:

SendAddonMessage("prefix", "message" [, "type" [, "target"]])

Arguments:

  • prefix - An arbitrary label for the message. Allows receiving addons to filter incoming messages: for example, if an addon uses the same prefix for all messages it sends, an addon interested in only those messages can check for that prefix before handling the message content. The prefix may contain any character except the null character ('\0'), which prematurely terminates the string, and the number of characters may not exceed 16. (string)

  • message - A message to send. The server will truncate message if it exceeds 255 characters. The number of characters in prefix does not affect the number of characters available for the message. (string)

  • type - Scope in which to broadcast the message: (string)

    • BATTLEGROUND - To all allied players in the current battleground instance
    • CHANNEL - To a custom addon message channel running in parallel to an existing custom chat channel
    • GUILD - To all members of the player's guild
    • OFFICER - To all guild officers
    • PARTY - To all members of the player's party (used by default if no type is given)
    • RAID - To all members of the player's raid group (automatically reverts to sending to party if the player is not in a raid group)
    • WHISPER - To a specific player

  • target - If type is 'WHISPER', the name of the target player. If 'CHANNEL', the target chat channel's id number (the first value returned by GetChannelName(channelName)). In cross-realm battlegrounds, the format 'Name-Realm' can be used to target a player from another realm; e.g. 'Thott-Cenarius', but this does not work for cross-realm raids or parties. (string)

Examples:

-- Hypothetical communication using addon messages
local MSG_PREFIX = "MY_MOD"
SendAddonMessage(MSG_PREFIX, "Resync", "GUILD")
SendAddonMessage(MSG_PREFIX, "VersionCheck", "WHISPER", "username")