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
| Parameter | Type | Required | Description |
|---|---|---|---|
playerUserId | string | Yes | The unique ID of the target player |
productActionId | string | Yes | The ID of the product action to apply - get this from GetProductActionsAsync() |
durationInMinutes | int | Yes | How long the action should last in minutes |
playerUsername | string | Yes | The target player's display name |
numberOfStrikes | int | No | Number of strikes to add (defaults to 1) |
description | string | No | A 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
| Property | Type | Description |
|---|---|---|
Ok | bool | Indicates whether the request was successful |
Data | ActionLog | The created action log entry |
Data.Id | string | The unique ID of the action log |
Data.ActionFriendlyName | string | The display name of the action applied |
Data.ActionValue | string | The machine-readable action value |
Data.IsActive | bool | Whether the action is currently active |
Data.DurationInMinutes | int | How long the action lasts |
Data.EndDate | DateTime | When the action expires |
Message | string | Response 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
sourceis automatically set toUNITY_SDKandplatformis set toIN_GAME.