Custom actions

On top of the built-in actions moderations can take, you can craft custom actions to fit your game. These actions can be anything from banning a user from a specific game mode or removing points or currency from an account.

There are two steps to creating a custom action:

  1. Create the action in the Moderation dashboard.
  2. Update a Cloud Code Script with the behavior the action will trigger.

Create a custom action

To create the custom action, navigate to the Moderation actions page in the Unity Cloud Dashboard: Moderation > Moderation actions.

  1. On the Moderation actions page, select Create custom action.
  2. Fill in the required information on the Custom action page.
  3. After adding the information, select Save.

The custom action you created will appear with the listed actions on the Moderation actions page.

Custom action settings

When creating or editing a custom action, you can change multiple conditions of the action:

  • Action name and ID: What the action is called and how it’s referred to in code.
  • Type: Is the action time-based or a one-time action?
  • Classification: Define if the action is positive or negative for the player.
  • Duration: How long will the action apply?

You can also toggle event settings from the editing page or whether the action is enabled or disabled.

You can edit a custom action after it’s been created.

Cloud Code script

To have an action take effect in your game's backend, you must set up a Cloud Code Script to execute any necessary actions For example, if you want a player banned from Competitive mode, you need to establish this action within the script to hit your game’s webhooks which would carry out the ban.

There is a default template script available from Cloud Code. The Moderation actions page directs you to this default template in the Cloud Code dashboard. Update the script with the desired behavior of your custom actions. Define each custom action you create in one script file.

Important: The Cloud Code script must be published before being added.

This script uses events to trigger specific actions through Cloud Code. You need to define a JSON parameter called ‘event’ in the script. You can do this from the Cloud Code product page under the Scripts section. Then select the Details tab of the script you are using and select Add.

A screenshot of the Cloud Code script Details tab

Fill in the parameter fields with:

  • Parameter name: event
  • Type: JSON
  • Required: True

A screenshot of the fields filled for creating a new event paramter

Set the script on the Moderation action page. When Moderators use the customize action the script will trigger.

Learn more about Cloud Code and script templates in the Cloud Code documentation.

Use a custom action

Select the custom action from the list of actions when responding to an incident.