# MentionPrefix

`variable` in `gateway` · v0.9.0

<https://seedcord.org/docs/packages/gateway/0.9.0/variables/mention-prefix>

Passes only a message that starts with a mention of the bot, like `@bot ping`. It ignores every other message
with a [`Silence`](/docs/packages/core/0.12.0/classes/silence), including a reply that pings the bot, a role mention, and a mention later in the text.

On `messageUpdate` it passes only when the edit adds the mention. An edit that keeps the mention doesn't run the
handler again. With `Partials.Message` on, discord.js also emits an edit to a message it didn't cache. That edit
runs the handler again. Attach the gate without calling it, since it doesn't take options.

A handler behind this gate can read `content` without the Message Content intent, because Discord sends the text of
a message that mentions the bot.

```ts
const MentionPrefix: import("@seedcord/core").Gate<
    EventGateContext<"messageCreate" | "messageUpdate">,
    "MentionPrefix"
>;
```

## Examples

```ts
import { Events } from 'discord.js';

\@Gated(IgnoreBots, MentionPrefix)
\@RegisterEvent([Events.MessageCreate], [Events.MessageUpdate])
class MentionCommands extends EventHandler<Events.MessageCreate | Events.MessageUpdate> {
    async execute() {
        // ...
    }
}
```

## See also

- [Gated](/docs/packages/gateway/0.9.0/functions/gated)
