Skip to main content

TakeManualActionOnPlayerAsync

Manually applies a moderation action on a player. Use GetProductActionsAsync() to retrieve available actions first. This method is only available to dev players.

Method Signature

public async Task<ManualActionResponse> TakeManualActionOnPlayerAsync(
string playerUserId,
string productActionId,
int durationInMinutes,
string playerUsername,
int numberOfStrikes = 1,
string description = null)

Parameters

ParameterTypeRequiredDescription
playerUserIdstringYesThe unique ID of the target player
productActionIdstringYesThe ID of the product action to apply - get this from GetProductActionsAsync()
durationInMinutesintYesHow long the action should last in minutes
playerUsernamestringYesThe target player's display name
numberOfStrikesintNoNumber of strikes to add (defaults to 1)
descriptionstringNoA note explaining why the action was taken

Returns

Returns a ManualActionResponse object containing the created action log, or null if the request failed or the caller is not a dev player.

Usage Example

// First, get available actions
var actionsResponse = await PlaySafeManager.Instance.GetProductActionsAsync();

if (actionsResponse != null && actionsResponse.Ok && actionsResponse.Data != null)
{
// Pick an action (e.g. the first one, or let the moderator choose)
var selectedAction = actionsResponse.Data[0];

// Apply the action to a player
var result = await PlaySafeManager.Instance.TakeManualActionOnPlayerAsync(
playerUserId: targetPlayerId,
productActionId: selectedAction.Id,
durationInMinutes: 60,
playerUsername: targetUsername,
description: "Inappropriate behavior during match"
);

if (result != null && result.Ok)
{
Debug.Log($"Action applied. Action log ID: {result.Data?.Id}");
Debug.Log($"Action: {result.Data?.ActionFriendlyName}");
Debug.Log($"Ends at: {result.Data?.EndDate}");
}
}

Response Type

ManualActionResponse

public class ManualActionResponse
{
public bool Ok { get; set; }
public ActionLog Data { get; set; }
public string Message { get; set; }
}

ActionLog

public class ActionLog
{
public string Id { get; set; }
public string ActionFriendlyName { get; set; }
public bool TriggersStrike { get; set; }
public string ActionValue { get; set; }
public string ViolationType { get; set; }
public string Trigger { get; set; }
public string Description { get; set; }
public string Transcript { get; set; }
public bool IsActive { get; set; }
public int DurationInMinutes { get; set; }
public int DelayInSeconds { get; set; }
public DateTime EndDate { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
}

Properties

PropertyTypeDescription
OkboolIndicates whether the request was successful
DataActionLogThe created action log entry
Data.IdstringThe unique ID of the action log
Data.ActionFriendlyNamestringThe display name of the action applied
Data.ActionValuestringThe machine-readable action value
Data.IsActiveboolWhether the action is currently active
Data.DurationInMinutesintHow long the action lasts
Data.EndDateDateTimeWhen the action expires
MessagestringResponse message from the server

Error Handling

The method returns null if:

  • The current player is not a dev player
  • Network request fails
  • Response parsing fails

Always check for null and verify the Ok property before accessing the data.

Notes

  • This method is only available to dev players. Non-dev players will receive a warning and the method will return null.
  • Always use GetProductActionsAsync() to get valid action IDs rather than hardcoding them.
  • Manual actions will trigger webhook notifications the same way as automated actions.
  • The source is automatically set to UNITY_SDK and platform is set to IN_GAME.