Skip to main content

Quick References

Common integration patterns for Wasabi Chat (wasabi_chat).


Messages​

Send a message to a player (server)​

exports.wasabi_chat:sendMessage(source, { name = 'Pacific Bank', color = '#4caf50' }, 'Your loan was approved.')

Send a message to a job (server)​

exports.wasabi_chat:sendToJob('police', { name = 'Dispatch', color = '#3b82f6' }, '10-90 at Fleeca Bank', { onDuty = true })

Send a message to nearby players (server)​

exports.wasabi_chat:sendNearby(source, 15, { name = 'Store Clerk' }, 'We close in 5 minutes.')

Check why a message was not sent (server)​

local ok, reason = exports.wasabi_chat:sendMessage(source, { name = 'Pacific Bank' }, 'Your loan was approved.')
if not ok then
print('Message not sent: ' .. reason)
end
if exports.wasabi_chat:hasWristLink(source) then
exports.wasabi_chat:sendWristNotification(source, { title = 'Dispatch', text = 'New call assigned' })
end

exports.wasabi_chat:sendSystemDM(source, { name = 'Maze Bank' }, 'Your loan payment of $500 is due tomorrow.')

Moderation​

exports.wasabi_chat:mutePlayer(source, 10, 'Spamming OOC')
local muted, secondsLeft, reason = exports.wasabi_chat:isMuted(source)
exports.wasabi_chat:unmutePlayer(source)
exports.wasabi_chat:setSlowMode('ooc', 10)
local text, matched = exports.wasabi_chat:filterText(input)

Hide the chat​

While your own UI is open (client)​

exports.wasabi_chat:setChatHidden(true) -- your UI opens
exports.wasabi_chat:setChatHidden(false) -- your UI closes

Stock chat scripts​

Scripts written for the stock chat keep working without changes:

exports.chat:addMessage(-1, { color = { 255, 200, 0 }, args = { 'Server', 'Restart in 10 minutes.' } })
TriggerClientEvent('chat:addMessage', source, { args = { 'Server', 'Welcome!' } })

Banners​

Banners appear above job announcements and custom messages. The shipped banners are in ui/build/assets/: banner-police.png, banner-ems.png, banner-mechanic.png, banner-business.png, and banner-staff.png.

To add your own:

  1. Make a PNG at 3:1 (the shipped banners are 960x320). A template is in _BANNER_TEMPLATE/.
  2. Save it in ui/build/assets/. If you build the UI from source, also put it in ui/public/assets/.
  3. Use its file name in announcements.jobs.<job>.banner or in an export's banner option.

File names may only use A-Z a-z 0-9 _ -, up to 60 characters, plus .png.

Discord​

Chat log​

Set discordLogs.enabled = true and put the webhook in server.cfg so it stays out of your config files. The convar wins over discordLogs.webhook.

set wasabi_chat_webhook "https://discord.com/api/webhooks/..."
warning

Wrist Link DMs are private. They are logged only if discordLogs.directMessages and messageLog.logDirectMessages are both true. Tell your players if you turn this on.

Emojis and stickers​

Emojis and stickers come from your own Discord server, through a bot that is a member of it. The bot token stays on the server.

set wasabi_chat_discord_guild_id "123456789012345678"
set wasabi_chat_discord_bot_token "your-bot-token"
set wasabi_chat_discord_cache_seconds 300 # optional, 30-3600

Commands​

Players​

  • /wsbchat_open (key T): open the chat.
  • /wristlink: open Wrist Link (no key by default). In item mode this command is not registered; players use the item.
  • /me, /do, /roll [NdM] (default 1d6), /try: overhead bubbles.
  • /jobannounce <status> <text>: job announcement card (open, closed, hiring, event, general).
  • /clear: clear your own chat feed.

Staff​

  • /announce <text>, /clearall.
  • /mute <id> [minutes] [reason], /unmute <id or identifier>, /mutes.
  • /slowmode <local|ooc|staff|groups|dm|all> <seconds>.
  • /wristlinkresetpw <player id | account name> (item mode only).
  • /say <text>: console or ace command.say only.

The mute and slow mode commands are allowed for the console, staffGroups, or the ace command.<name> (for example add_ace group.mod command.mute allow). To let a group skip slow mode (and the word filter, when bypassStaff = true), add add_ace group.mod wasabichat.bypass allow.

Integration hooks​

Use Listeners for editable callbacks and Events for chat activity. Do not call undocumented internal network events as an integration API.