# ゲームでの Moderation SDK の使用

> ゲームで Moderation SDK を使用する方法。

## プレイヤーを報告する##report-a-player

設定が完了したら、UAS ID を使用し、報告する理由を指定して、プレイヤーを報告できます。

プレイヤーが報告されると、Unity Dashboard に移動し、添付のレポートの情報を使用してインシデントをレビューできます。

Vivox v16.0.0 以上のパッケージを使用している場合は、レポート提出者とレポート対象者がいたチャンネルからの過去 15 分間の会話がレポートに添付されます。

以下はレポートを送信する例です。

```cs
using Unity.Services.Moderation;
using Unity.Services.Moderation.Models;
using Unity.Services.Moderation.Exceptions;

public async void Report(string userId)
{
    // userId should be the UAS id of the reported player
    // eg: the currently logged in user id is accessible with
    // var MyUserId = AuthenticationService.Instance.PlayerId

    try {
        var report = Moderation.Instance.NewReport(userId,
            new ReportReason(ReportReason.Threat));
        await Moderation.Instance.ReportPlayer(report);
        Debug.Log("Report submitted!");
    } catch (ModerationServiceException e){
        if (e.Reason == ModerationServiceExceptionReason.SelfReportError) {
            Debug.Log("Error: you can’t report yourself");
        } else {
            Debug.Log($"Error: {e.Reason}");
        }
    }
}
```

## 報告の理由##report-reason

理由は Unity によって定義されており、ゲーム内で表示する配列として使用できます。

```cs
using Unity.Services.Moderation.Models;

public ListReasons()
{
  foreach (var reason in ReportReason.PossibleReasons)
  {
      Debug.Log(reason);
  }
}
```

各理由の定数は、**Moderation (モデレーション) > Runtime (ランタイム) > Models (モデル) > ReportReasons.cs** にあります。

| 定数                                          | 理由                           |
| ------------------------------------------- | ---------------------------- |
| public const string AimSnapping             | = "aim snapping";            |
| public const string Boosting                | = "boosting";                |
| public const string Exploiting              | = "exploiting";              |
| public const string Hacking                 | = "hacking";                 |
| public const string Smurfing                | = "smurfing";                |
| public const string UnrealisticMovement     | = "unrealistic movement";    |
| public const string CollusionWithOpponent   | = "collusion with opponent"; |
| public const string LeftMatch               | = "left the match";          |
| public const string Inactive                | = "inactive";                |
| public const string Sabotage                | = "sabotage";                |
| public const string Spamming                | = "spamming";                |
| public const string HateSpeech              | = "hate speech";             |
| public const string PredatoryBehavior       | = "predatory behavior";      |
| public const string NoiseDisruption         | = "noise disruption";        |
| public const string Scamming                | = "scamming";                |
| public const string Ads                     | = "ads";                     |
| public const string Threat                  | = "threat";                  |
| public const string VerbalAbuse             | = "verbal abuse";            |
| public const string InappropriatePlayerName | = "player name";             |

## アクション##actions

アクションは、インシデントをレビューするときにダッシュボードを通じて適用されます。

アクションが適用され、アクションの適用対象のユーザーがサインインすると、Moderation サービスと統合されたさまざまな UGS パッケージからさまざまなエラーメッセージが送られてきます。エラーは、[エラーレスポンス](/services/access-control.md#error-responses) で説明されているアクセス制御規則に従います。これは想定されている動作です。

一部の SDK は、これらのエラーを独自の例外にラップするメカニズムを提供しています。例えば、Vivox SDK は、ポリシーによってユーザーがコミュニケーションへのアクセスを禁止されている場合に `MintException` を発行します。

サポートされている制裁エラーのリスト:

| パッケージ名                            | 例外                     | ユースケース                                                                    |
| --------------------------------- | ---------------------- | ------------------------------------------------------------------------- |
| com.unity.services.authentication | RequestFailedException | プレイヤーがバンされている場合、innerException に ACCOUNT\_DISABLED メッセージが含まれたこの例外を受け取ります。 |
| com.unity.services.vivox          | MintException          | プレイヤーがコミュニケーションチャンネルへのアクセスを禁止されている場合、この例外が 403 ステータスコードとともにスローされます。       |

## エビデンス管理##evidence-management

プロジェクトで Vivox バージョン 16.0.0 以上を使用している場合、SDK には、レポート提出者とレポート対象者の両方が属するチャンネルのリストに加えて、これらのチャンネルにいたその他のプレイヤーのリストが自動的に追加されます。

この情報は、レポートの [エビデンス](./evidence.md) に詳細を追加するために使用されます。

レポートコンテキストの制御を向上させるために、送信前にレポートに記載のチャンネルとプレイヤーのリストを変更できます。

```cs
 var report = Moderation.Instance.NewReport(userId, new ReportReason(ReportReason.Threat));

report.Players = new List<PlayerContext>(); // The list of extra players you want to include in screenings.
report.VivoxChannels = new List<VivoxChannel>(); // The list of channels to be screened.
```
