# チャットコマンドを実行する（player.runChatCommand）

> コード内でチャットコマンドを実行します。

- カテゴリ：プレイヤー（player）
- ブロック：チャットコマンド "jump" を 実行する
- URL：https://makecode.minecraft-okinawa.com/reference/player/run-chat-command/
- Pythonでの名前：player.run_chat_command
- 公式データ取得日：2026-11-13
- 動作確認：確認待ち

## JavaScript

```javascript
player.runChatCommand("jump")
```

## Python

```python
player.run_chat_command("jump")
```

## 引数

| 名前 | 値 | 意味 |
|---|---|---|
| command | 文字列 | 実行するチャットコマンド。たとえば：「jump」 |

## 使用例

### Let's say you have a chat command in your project that makes your agent move forward and place a block:

```javascript
player.onChat("placeforward", function () {
        agent.move(FORWARD, 1);
        agent.place(BACK);
});
```

```python
def on_on_chat():
    agent.move(FORWARD, 1)
    agent.place(BACK)
player.on_chat("placeforward", on_on_chat)
```

### You can reuse this chat command in other parts of your code to have your agent build a row:

```javascript
player.onChat("row", function () {
    agent.teleportToPlayer();
    for (let i = 0; i < 5; i++) {
        player.runChatCommand("placeforward");
    }
});
```

```python
def on_on_chat():
    agent.teleport_to_player()
    for i in range(5):
        player.run_chat_command("placeforward")
player.on_chat("row", on_on_chat)
```

## 出典

- [MakeCode for Minecraft 公式リファレンス（player.runChatCommand）](https://minecraft.makecode.com/reference/player/run-chat-command)

執筆：鈴木孝昌（現役プロジェクトマネージャー／マイクラカップ指導者）／運営：沖縄マイクラ部 プログラミングスクール「クロスウェーブ」（https://minecraft-okinawa.com/）