> For the complete documentation index, see [llms.txt](https://docs.rainmad.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rainmad.com/resources/scenes-draw-everywhere/events-and-exports.md).

# Events & Exports

## Server event hooks

Two public hooks fire on the server. Handlers written for older versions keep working unchanged; the names and payloads are the same.

**`rm_scenes:server:onSceneCreated`** fires when a scene is saved, and when one is copied.

```lua
AddEventHandler('rm_scenes:server:onSceneCreated', function(data)
    -- data.creatorId         number  server id of the creator
    -- data.creatorIdentifier string  identifier of the creator
    -- data.creatorName       string  name of the creator
    -- data.coords            vector3 scene position
end)
```

**`rm_scenes:server:onSceneDeleted`** fires when a scene is deleted from the list, bulk-deleted by an admin, or absorbed by a merge.

```lua
AddEventHandler('rm_scenes:server:onSceneDeleted', function(data)
    -- data.deleterId         number  server id of who removed it
    -- data.creatorIdentifier string  identifier of the scene's creator
    -- data.creatorName       string  name of the scene's creator
    -- data.coords            vector3 scene position
end)
```

{% hint style="info" %}
Scenes removed by the automatic cleanups (expiry, `deleteUnseenAfter`) are pruned directly in the database at resource start and do not fire the hook.
{% endhint %}

## Server exports

Both commands can be disabled (`cfg.commands.create/list = false`) and replaced with these, wired to an item, a menu or a job script:

```lua
exports.rm_scenes:openSceneCreation(source --[[number]])
exports.rm_scenes:openSceneList(source --[[number]])
```

`openSceneCreation` runs the same authorization and scene-limit checks as the command.

## Discord logging

Scene creations and copies route through `rm_scenes/server/discord_log.lua`, an open file you can rewrite entirely. Logging is **off by default**: set `enabled = true` and your webhook URL in the file's config to turn it on, and shape the embed however you like.

The default logger attaches the scene's drawing to every creation embed, so moderators see what was drawn without joining, and lists the creator, coordinates and the picked duration. Drop the `image` field from the entry in `discord_log.lua` if you'd rather keep the logs text-only.
