# Counting

> A minigame where members write the numbers in order. A mistake restarts from 1.

Source: https://docs.mayabot.eu/modules/counting

In the counting channel members write the numbers in order: 1, 2, 3 and so on. MayaBot puts ✅ on the right number and ❌ on the wrong one; a mistake restarts the count from 1.

You'll find it in **Config > Fun**. You can have up to **3 counting channels** per server.

## Setting up

### Turn the module on

Turn on the **Counting** switch and press **+**.

### Choose the channel

Choose the **Channel**: a dedicated text channel is best, because MayaBot deletes anything that isn't a number.

### Rules and saving

Set the rules (below) and press **Save**. It starts from 1.

## The rules of the game

- Only digits count, with nothing else: `42` is fine, `042`, `+42`, `42.`, `42 hello` and `40+2` aren't. Sums aren't allowed.
- Messages that aren't numbers are deleted.
- Normally the same person can't write two numbers in a row: if they do, even with the right number, the count restarts from 1.
- A wrong number once the count has started restarts from 1 and MayaBot writes a message. A wrong number while still at 1 only gets ❌.
- After a mistake anyone can start again with `1`, even whoever made the mistake.
- If two people write at the same time, the message that arrived first counts.
- Messages from bots and webhooks are ignored.

The channel **record** is the highest number reached. The panel shows neither the current number nor the record: you see them in MayaBot's messages.

## Channel settings

| Setting | Effect |
|---|---|
| **The same player can send consecutive numbers** | Off by default. When on, the same person can write two numbers in a row. Not recommended: it ruins the game |
| **Whitelisted roles** | Up to 20 roles. If you choose at least one, only members with one of these roles can count; other people's messages are deleted. When empty, everyone can count |
| **Blacklisted roles** | Up to 20 roles. Members with one of them can't count. For each role choose **Ignore** (the message stays, with no reaction) or **Delete** (the message is deleted) |

A role can't be in both lists. If a member has one role in the whitelist and another in the blacklist, the blacklist wins.

## Counting messages

The gear icon opens **Counting messages**, with the four messages MayaBot sends. They apply to all the server's counting channels.

| Message | When it's sent | Default text |
|---|---|---|
| **Mistake** | Someone gets the number wrong or counts twice in a row | %mention% ruined the count at **%count%**! The record is still **%best%**. Starting again from **1**. |
| **New record** | Instead of Mistake, if the count had beaten the record | New record of **%count%**, then %mention% ruined the count! Starting again from **1**. |
| **Edited** | Someone edits the last valid number | This message was just edited. The next number is **%next%**. |
| **Deleted** | Someone deletes the last valid number | The last number was just deleted. The next number is **%next%**. |

Each message has the three formats of the [Automatic message](https://docs.mayabot.eu/modules/auto-messages#format), without uploaded images. The default texts follow the [server language](https://docs.mayabot.eu/getting-started/server-language) until you edit them.

Editing or deleting the last number doesn't take the count back: you carry on from the number MayaBot gives. Edits and deletions of older numbers have no effect.

In the Mistake and New record messages `%mention%` notifies whoever made the mistake. In Edited and Deleted the mention shows but doesn't notify.

## Placeholders

| Placeholder | Becomes |
|---|---|
| `%mention%` | Player mention |
| `%username%` | Player's username |
| `%displayname%` | Player's display name |
| `%userid%` | Player's ID |
| `%avatar%` | Player's avatar link, also in image fields |
| `%createdat%` | Player's account creation date |
| `%count%` | Last valid number |
| `%next%` | Next number to write |
| `%best%` | Channel record |
| `%channel%` | Channel mention |
| `%channelid%` | Channel ID |
| `%server%`, `%serverid%`, `%servericon%`, `%membercount%` | Server name, ID, icon and member count |

The player is whoever made the mistake (Mistake and New record), whoever edited the number (Edited) or whoever had written it (Deleted).

## Resetting the count

- Changing the channel of a setup resets the number and the record.
- Removing a channel from counting deletes its settings, number and record. The channel stays on Discord.
- If the channel is deleted on Discord, MayaBot removes it from counting by itself.
- Turning the module off resets nothing: when it's turned back on, counting resumes from the saved number.
- **Reset** removes all counting channels and brings the four messages back to the default texts.

## Permissions

| MayaBot's permission in the channel | Why |
|---|---|
| **View Channel** | Always |
| **Add Reactions**, **Read Message History** | Adding ✅ and ❌ |
| **Manage Messages** | Deleting messages that don't count |
| **Send Messages** | Sending the counting messages |
| **Embed Links** | Messages in the Embed (v1) format |

If a permission is missing, MayaBot skips that action without warning on Discord. The channel's row in the dashboard shows the missing permissions. The exception is **Embed Links** with a message in the Embed (v1) format: the dashboard doesn't save the channel or the messages until MayaBot has the permission in every counting channel, and shows **MayaBot doesn't have the Embed Links permission in one of the counting channels.**

## Common problems

| Problem | Fix |
|---|---|
| No reactions | Give **Add Reactions** and **Read Message History**. Check that the module is on |
| **Counting is paused: MayaBot can't read message text right now.** | A MayaBot problem, not your server's: check [status.mayabot.eu](https://status.mayabot.eu) |
| A right number is marked as a mistake | The same person wrote two numbers in a row |
| A number is deleted | It contains something other than digits, or whoever wrote it doesn't have a whitelisted role |
| Someone's messages are ignored | They have a blacklisted role set to **Ignore** |
| Normal text isn't deleted | **Manage Messages** is missing |
| After a mistake MayaBot writes nothing | **Send Messages** is missing, or the mistake happened while still at 1 |
| A person doesn't get reactions | They've blocked MayaBot. Counting works anyway |
| In a very fast channel some reactions are missing | MayaBot skips some reactions to stay within Discord's limits. The count stays correct |
