> For the complete documentation index, see [llms.txt](https://mythicalbot.gitbook.io/arklynn-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mythicalbot.gitbook.io/arklynn-docs/miscellaneous/counter.md).

# Counter

Both commands require the `Manage Server` permission (Administrator).

| Command                         | Description                                                     |
| ------------------------------- | --------------------------------------------------------------- |
| `/setup_count channel:#channel` | Enables counting in the specified channel and posts the rules.  |
| `/setup_count_remove`           | Disables counting in the server (removes the counting channel). |

***

### How It Works

Once you run `/setup_count channel:#counting`, the bot:

1. Stores that channel as the counting channel.
2. Posts an embed with the **rules** and sets the next number to **1**.
3. Monitors all messages in that channel.

When a user sends a message, the bot:

* Checks if the message author is **different** from the previous counter.
* Tries to parse the message as a **whole number** or a **mathematical expression**.
* Compares the result with the **expected number**.
* On success: adds a ✅ reaction and increments the expected number.
* On failure: **deletes the message**, sends an error, and resets the count to **1**.

> **Note:** The count always starts at `1` and increases by `1` after each correct message. If the rules are broken, the count resets to `1`.

***

### The Rules (as shown in the bot's embed)

```
**Counting Rules:**
> **Start at 1.** The count resets to 1 if the rules are broken.
> **No double counting!** The same person cannot count two numbers in a row.
> **No cheating!** Messages must contain only the correct number or a math expression (e.g. 5+3).
> **Next number:** 1
```

***

### Supported Mathematical Expressions

The bot evaluates expressions using standard arithmetic operators. **Spaces are generally not allowed** (e.g., use `1+1`, not `1 + 1`).

| `+`   | Addition       | `1+1` → 2     |
| ----- | -------------- | ------------- |
| `-`   | Subtraction    | `2-1` → 1     |
| `*`   | Multiplication | `3*2` → 6     |
| `/`   | Division       | `6/2` → 3     |
| `( )` | Grouping       | `(4+2)/3` → 2 |

**Important rules for expressions:**

* The result must be a **whole number** (integer). Division that yields a fraction (e.g., `3/2`) is **not allowed** and will cause a reset.
* Only the operators above are supported. No `^`, `**`, `%`, or functions like `sqrt()`.
* No extra characters – only the expression itself. Emojis, punctuation, or letters make the message invalid.

#### Examples by expected number

| 1 | `1`, `2-1`, `1*1`, `(3-2)`                 | `1` (same user as previous), `1.0`, `one`, `1+0` (same as 1 but fine) |
| - | ------------------------------------------ | --------------------------------------------------------------------- |
| 2 | `2`, `1+1`, `4-2`, `2*1`, `4/2`, `(6+2)/4` | `2` (same user as previous), `2+1`, `3-0`, `two`                      |
| 3 | `3`, `2+1`, `6/2`, `9-6`, `(5+4)/3`        | `3` (same user), `1+1+1` (fine actually), `3.0`, `three`              |

> **Remember:** Even if the expression evaluates correctly, **double counting** (same user as the last count) will also cause a reset.

***

### Error Messages (from bot code)

#### 1. Double counting (same user)

text

```
<:lefted2:1492504656281206935> @Nex You cannot count twice in a row! Resetting count to **1**.
```

#### 2. Message is not a valid number or expression

text

```
<:X_:1466096728238456836> @Nex `omg girl` is not a valid number or expression.
Expected **5**. Resetting count to **1**.
```

#### 3. Expression evaluates to the wrong number

text

```
<:minusred:1492506524155772969> @Nex You said `2+2` = **4**, but expected **3**. Resetting count to **1**.
```

In all failure cases:

* The offending message is **deleted**.
* The bot sends the error message.
* The count resets to `1`.
* The next expected number becomes `1`.

***

### Setting Up – Step by Step

#### Step 1: Create a channel (optional but recommended)

Create a text channel named `#counting` or `#number-game`.

#### Step 2: Run the command

text

```
/setup_count channel:#counting
```

(Replace `#counting` with your channel name.)

#### Step 3: Bot confirms

You (the admin) see an ephemeral message:

> ✅ Counting has been enabled in #counting.

#### Step 4: Bot posts rules

In `#counting`, the bot sends an embed with the rules and the first expected number: **1**.

#### Step 5: Members start counting

* User A sends `1` → bot adds ✅ reaction, next number is `2`.
* User B sends `1+1` → ✅, next number `3`.
* User C sends `2+1` → ✅, next number `4`.
* User A tries to send `4` → ❌ **double counting** (User A sent `1` earlier, but they can count again after someone else). Actually, double counting trigger: same user cannot count **two numbers in a row**. Since User A just sent `1` and then User B and User C counted, User A can now count `4`. The bot checks `last_user_id` – if the previous message author is different, it's allowed.

#### Step 6: Mistake leads to reset

* User D sends `5` when expected number was `4` → bot deletes message, sends error, resets to `1`.
* Next expected number becomes `1` again.

***

### Removing the Counting Channel

text

```
/setup_count_remove
```

* If a counting channel exists:\
  `✅ The counting channel has been successfully removed.`
* If none exists:\
  `<:X_:1466096728238456836> No counting channel is currently set up for this server.`

After removal, the bot no longer monitors messages in that channel.

***

### Privacy & Technical Notes

* **Message Content intent:** If the bot does not have the `message_content` privileged intent, counting will not work and the bot will notify the user once. Ensure the bot is invited with that intent enabled.
* **Message deletion:** The bot needs `Manage Messages` permission to delete invalid messages.
* **Reaction:** The bot needs `Add Reactions` permission to put the checkmark on successful counts.

***

### Troubleshooting

| Issue                                               | Solution                                                                                                                                                                                                         |
| --------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `/setup_count` slash command not found              | Re‑invite the bot with `applications.commands` scope, or wait up to an hour for slash commands to sync.                                                                                                          |
| Bot does not react to messages in counting channel  | Check that the channel is correct (run `/setup_count` again). Ensure bot has `Send Messages`, `Read Messages`, `Manage Messages`, and `Add Reactions`. Also verify the bot has `message_content` intent enabled. |
| Expression `1+1` resets (invalid number/expression) | Remove spaces: `1+1` not `1 + 1`. Also check for unsupported operators like `^` or `%`.                                                                                                                          |
| Double counting resets even when different user     | The bot's `last_user_id` might be stale. Try removing and re‑setting up the counting channel.                                                                                                                    |
| Bot deletes messages but does not send error        | The bot may lack `Send Messages` permission in that channel. Check channel permissions.                                                                                                                          |
| Division expression `3/2` causes reset              | The bot expects an integer result. `3/2` = 1.5 (not integer) → invalid. Use only division that yields whole numbers.                                                                                             |

***

### FAQ

**Q: Can we use negative numbers?**\
A: No. Counting starts at 1 and increases positively.

**Q: Does the bot ignore messages that aren't counting attempts?**\
A: No – every message in the counting channel is checked. That's why you should dedicate a channel only to counting. Normal conversation will cause resets.

**Q: What if two people send the correct number at nearly the same time?**\
A: The bot processes messages in order. The first correct message advances the count; the second will be considered wrong (out of sequence) and cause a reset.

**Q: Can I change the starting number or the increment?**\
A: No – the bot always starts at 1 and increments by 1.

**Q: Does the bot support multi‑digit numbers?**\
A: Yes – any positive integer is fine.

**Q: Can I see the current count without guessing?**\
A: After each correct count, the bot does **not** announce the next number in the chat (unlike some counting bots). It only adds a reaction. To know the next number, you must remember the last correct number that received a reaction. Or an admin can check the bot's internal state, but there is no public command.

***

### Complete Example Workflow

<table data-header-hidden><thead><tr><th></th><th></th><th width="284"></th><th width="494"></th><th width="319"></th></tr></thead><tbody><tr><td>#</td><td>User</td><td>Message</td><td>Bot Action</td><td>Next Number</td></tr><tr><td>1</td><td>(Admin)</td><td><code>/setup_count channel:#count</code></td><td>Enables, posts rules</td><td>1</td></tr><tr><td>2</td><td>Alice</td><td><code>1</code></td><td>✅ reaction</td><td>2</td></tr><tr><td>3</td><td>Bob</td><td><code>2</code></td><td>✅ reaction</td><td>3</td></tr><tr><td>4</td><td><strong>Bob</strong></td><td><code>3</code></td><td>❌ double counting (Bob again), delete, reset</td><td>1</td></tr><tr><td>5</td><td>Alice</td><td><code>1</code></td><td>✅ reaction</td><td>2</td></tr><tr><td>6</td><td>Carol</td><td><code>1+1</code></td><td>✅ reaction</td><td>3</td></tr><tr><td>7</td><td><strong>David</strong></td><td><code>4</code></td><td>❌ wrong number (expected 3), delete, reset</td><td>1</td></tr><tr><td>8</td><td>Alice</td><td><code>1</code></td><td>✅ reaction</td><td>2</td></tr><tr><td>9</td><td><strong>Bob</strong></td><td><code>2-1</code> (evaluates to 1)</td><td>❌ wrong number? Wait, <code>2-1</code> = 1, but expected 2 → reset</td><td>1</td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mythicalbot.gitbook.io/arklynn-docs/miscellaneous/counter.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
