> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dogebot.net/llms.txt
> Use this file to discover all available pages before exploring further.

# Message events

> These run when people send, change, delete or pin messages, start typing, or vote in polls.

These run when people send, change, delete or pin messages, start typing, or vote in polls.

> **Example**
>
> Delete messages that contain a bad word, or give coins for every message someone sends.

> [!NOTE]
>
> **How to use one:** go to **Events**, press **New Event**, pick the event from the list, then add blocks under it. The words in `{curly brackets}` are variables you can type into your blocks. The bot swaps them for the real thing when the event happens.

![The DogeBot event picker](https://mintcdn.com/doge-bot/0C6-zgXTpDx1QOCe/images/guide/event-picker.png?fit=max\&auto=format\&n=0C6-zgXTpDx1QOCe\&q=85\&s=9a4a944abf5b2a65384e22c7f4386887)

> [!WARNING]
>
> **When a new message is sent** runs for **every** message, even your bot's own messages. Add a check under it so your bot doesn't answer itself forever. A simple one: **Compare** `{event_user_id}` **Not Equal to** `{bot_id}`.

> [!NOTE]
>
> For message events, turn on the **Message Content Intent** for your bot in the Discord Developer Portal.

## The events

> **When a new message is sent**
>
> **When it runs:** every time someone sends a message.
>
> **Variables:** the person, message and channel variables (see [Shared variables](#variables-many-of-these-events-share) below).
>
> **Build idea:** give the person XP or coins for each message. See [Levels and XP](/build-real-systems/levels-and-xp).

> **When a message is updated or edited**
>
> **When it runs:** someone changes a message they already sent.
>
> **Variables:** the person, message and channel variables. Plus:
>
> | Type this | What you get |
> | - | - |
> | `{event_new_content}` | The message after the change |
> | `{event_old_content}` | The message before the change |
>
> **Build idea:** post the old and new text in your log channel.

> **When a message is deleted**
>
> **When it runs:** a message is deleted.
>
> **Variables:** the person, message and channel variables.
>
> **Build idea:** keep a log of deleted messages for your moderators.

> **When a message is pinned**
>
> **When it runs:** a message is pinned.
>
> **Variables:** the channel variables.
>
> **Build idea:** tell the channel that something important was pinned.

> **User Started Typing**
>
> **When it runs:** someone starts typing.
>
> **Variables:** the person and channel variables. Plus:
>
> | Type this | What you get |
> | - | - |
> | `{event_guild_id}` | The server ID |
> | `{event_guild_name}` | The server name |

## Poll events

> **When a user votes on a poll**
>
> **When it runs:** someone votes on a Discord poll.
>
> **Variables:** the person, message and channel variables. Plus:
>
> | Type this | What you get |
> | - | - |
> | `{event_poll_answer}` | The answer they voted for |
>
> **Build idea:** thank people for voting, or count the votes in a variable.

> **When a user removes their vote on a poll**
>
> **When it runs:** someone takes their vote back.
>
> **Variables:** the person, message and channel variables. Plus:
>
> | Type this | What you get |
> | - | - |
> | `{event_poll_answer}` | The answer they took back |

## Variables many of these events share

These show up again and again above, so here they are once.

**About the person**

| Type this | What you get |
| - | - |
| `{event_user_avatar}` | A link to their profile picture |
| `{event_user_id}` | Their ID |
| `{event_user_mention}` | Pings them |
| `{event_user_name}` | Their username |
| `{event_user_tag}` | Their full tag |
| `{event_user_username}` | Their username |

**About the message**

| Type this | What you get |
| - | - |
| `{event_message_attachment_1}` | A link to the first file |
| `{event_message_attachments}` | Links to all files |
| `{event_message_attachments_count}` | How many files |
| `{event_message_channel}` | Mentions the channel |
| `{event_message_channel_id}` | The channel ID |
| `{event_message_channel_name}` | The channel name |
| `{event_message_channel_type}` | What kind of channel |
| `{event_message_content}` | What the message says |
| `{event_message_createdAt}` | When it was sent |
| `{event_message_has_attachments}` | true if it has files |
| `{event_message_has_poll}` | true if it has a poll |
| `{event_message_id}` | The message ID |
| `{event_message_poll_question}` | The poll question |

**About the channel**

| Type this | What you get |
| - | - |
| `{event_channel_id}` | The channel ID |
| `{event_channel_is_thread}` | true if it is a thread |
| `{event_channel_name}` | The channel name |
| `{event_channel_parent_id}` | The category ID (or the forum, for a forum post) |
| `{event_channel_parent_name}` | The category name |
| `{event_parent_channel_id}` | The category ID |

## Example

Someone types in your chat:

```text theme={null}
hello everyone
```

In a message block under **When a new message is sent**, you write:

```text theme={null}
{event_user_mention} said: {event_message_content}
```

The bot shows: **@Sam said: hello everyone**

> **[All event groups](/event-triggers)**
>
> Back to the full list.

> **[Reaction events](/event-triggers/reaction-events)**
>
> When people react to messages.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.