AI Core

Logs

aiLog and aiLogChannels: send logs through ai-core to the console, Discord, Fivemanage or FiveM Stats, whatever the owner turns on in the panel.

TypeScript
import { aiLog, aiLogChannels } from "@aicore-fivem/lib/server";

Your script never posts to Discord or a log service itself. It sends a log to ai-core on a channel (a name like purchase); the server owner decides in ai-core's admin panel where each channel goes. Webhook urls and API keys stay in the panel, never in your code.

aiLog

Sends one log line through ai-core's log system.

Side: Server · Waits: no

Signature
aiLog(channel: string, message: string, options?: LogOptions): void
Lua
aiLib.aiLog(channel, message, options)

Parameters

Prop

Type

LogOptions

Prop

Type

Returns

void. In TypeScript it does nothing while ai-core is not running; the Lua twin prints [channel] message to the console instead.

Example

import { aiLog } from "@aicore-fivem/lib/server";

aiLog("purchase", `bought ${count}x ${item} for $${price}`, {
  source,
  metadata: { item, count, price },
});

aiLogChannels

Describes your resource's log channels: the dataset name used by Fivemanage and FiveM Stats, and whether a channel is on. Call it once when your script starts.

Side: Server · Waits: no

Signature
aiLogChannels(channels: Record<string, LogChannel>): void

No Lua twin: call ai-core's export exports['ai-core']:LogChannels(channels).

Parameters

Returns

void. Does nothing while ai-core is not running.

Example

import { aiLogChannels } from "@aicore-fivem/lib/server";

aiLogChannels({
  purchase: { dataset: "shops" },
  debug: { active: false },
});

On this page