# /coinflip

> Flip a coin. Heads or tails.

The bot flips a coin and shows the side.

> 🪙 @Alex flipped a coin: **Heads**!

## Setup

Create a slash command and switch to **Advanced**.

| Field | Value |
|---|---|
| Command Name | `coinflip` |
| Description | `Flip a coin` |

No arguments.

## Code

**Pre-hook:**

```python
side = random(["Heads", "Tails"])
```

**Content / Reply Message:**

```text
🪙 {user.mention} flipped a coin: **{side}**!
```

## Make it a bet

Add a **Text** argument named `guess`, with two **Choices**: `Heads` and `Tails`. Then change the pre-hook:

```python
side = random(["Heads", "Tails"])
result = "You guessed right!" if side == guess else "Better luck next time."
```

And the reply:

```text
🪙 It landed on **{side}**. {result}
```

## Related

- [/8ball](https://ccbot.app/docs/examples/8ball) picks from a longer list.
- [Economy](https://ccbot.app/docs/guides/economy) lets members bet coins.
