# Bots: get() method

> The get() method of the Bots interface returns the bot with a player ID, or undefined.

The **`get()`** method of the [`Bots`](/docs/room/bots) interface returns the bot with a player ID, or `undefined` when the room has no such bot.

## Syntax

```ts
get(player)
```

### Parameters

`player`
: A player ID, such as `"bot:3"`.

### Return value

The [`Bot`](/docs/room/bot), or `undefined`.

## Examples

### Changing a bot's behaviour data from a message

```ts
// coach.ts
import { defineRoom } from "@irtio/room";

export default defineRoom({
  bots: { opponent: {} },
  onCreate(room) {
    room.bots.add("opponent", { name: "Opponent", data: { level: 1 } });
  },
  onMessage(room, _connection, message) {
    const m = message as { type?: string; bot?: string; level?: number };
    if (m.type !== "difficulty" || typeof m.bot !== "string" || typeof m.level !== "number") return;
    const bot = room.bots.get(m.bot);
    if (bot) bot.data.level = Math.min(Math.max(m.level, 1), 5);
  },
});
```

## See also

- [`Bot`](/docs/room/bot)
- `isBot()`, which tells a bot's player ID from a person's without looking it up
