# メッセージの編集と削除

> Edit and delete messages in channels.

Vivox では、チャンネルにすでに送信されたメッセージを編集したり削除したりする方法が提供されます。

## チャンネルメッセージを編集する

Vivox では、[`VivoxService.Instance.EditChannelTextMessageAsync(string channelName, string messageId, string newMessage)`](https://docs.unity3d.com/Packages/com.unity.services.vivox@latest/index.html?subfolder=/api/Unity.Services.Vivox.IVivoxService.html#Unity_Services_Vivox_IVivoxService_EditChannelTextMessageAsync_System_String_System_String_System_String_) を使用して、ユーザーがチャンネルに送信したメッセージのテキストを編集できるようにします。channelName はメッセージが送信されたチャンネルの名前、messageId は変更するメッセージの ID、newMessage はメッセージの更新後のテキストです。

チャンネル内の誰かによってメッセージが正常に編集されると、チャンネル内のすべてのユーザーは、編集された VivoxMessage と更新後の MessageText を含む [`VivoxService.Instance.ChannelMessageEdited`](https://docs.unity3d.com/Packages/com.unity.services.vivox@latest/index.html?subfolder=/api/Unity.Services.Vivox.IVivoxService.html#Unity_Services_Vivox_IVivoxService_ChannelMessageEdited) アクションを受信します。

```cs
public async void UpdateChannelMessageAsync(VivoxMessage messageToUpdate, string updatedMessageText)
{
    await VivoxService.Instance.EditChannelTextMessageAsync(messageToUpdate.ChannelName, messageToUpdate.MessageId, updatedMessageText);
}
```

## チャンネルメッセージを削除する

Vivox では、[`VivoxService.Instance.DeleteChannelTextMessageAsync(string channelName, string messageId)`](https://docs.unity3d.com/Packages/com.unity.services.vivox@latest/index.html?subfolder=/api/Unity.Services.Vivox.IVivoxService.html#Unity_Services_Vivox_IVivoxService_DeleteChannelTextMessageAsync_System_String_System_String_) を使用して、ユーザーがチャンネルに送信したメッセージのテキストを削除できるようにします。channelName はメッセージが送信されたチャンネルの名前、messageId は削除するメッセージの ID です。

チャンネル内の誰かによってメッセージが正常に削除されると、チャンネル内のすべてのユーザーは、削除された VivoxMessage を含む [`VivoxService.Instance.ChannelMessageDeleted`](https://docs.unity3d.com/Packages/com.unity.services.vivox@latest/index.html?subfolder=/api/Unity.Services.Vivox.IVivoxService.html#Unity_Services_Vivox_IVivoxService_ChannelMessageDeleted) アクションを受信します。

```cs
public async void DeleteChannelMessageAsync(VivoxMessage messageToDelete)
{
    await VivoxService.Instance.DeleteChannelTextMessageAsync(messageToDelete.ChannelName, messageToDelete.MessageId)
}
```
