# ContextMenuHandler

`class` in `seedcord` · v0.12.0

<https://docs.seedcord.org/packages/seedcord/0.12.0/classes/context-menu-handler>

Base class for a context-menu command handler (right-click a user or a message).

Pass the kind from `discord.js`'s ApplicationCommandType as the generic, the same value as `@ContextMenuRoute`. Read the right-clicked entity from `this.target`, a `User` for a user menu and a `Message` for a message menu. Context menus carry no options, so a handler registered for several names reads `this.target` uniformly with no per-name branch.

```ts
abstract class ContextMenuHandler<
    Kind extends ContextMenuKind,
    Cache extends CacheType = "cached"
> extends InteractionHandler<InteractionFor<Kind, Cache>>
```

## Examples

```ts
\@ContextMenuRoute(ApplicationCommandType.Message, 'Report Message')
class ReportMessage extends ContextMenuHandler<ApplicationCommandType.Message> {
    \@Catchable()
    async execute() {
        const message = this.target;
    }
}
```

## Properties

### target

```ts
protected target: TargetFor<Kind, Cache>
```

### targetMember

```ts
protected targetMember: TargetMemberFor<Kind, Cache>
```

The invoking guild member, resolved only on user menus. Reading it on a message menu is a compile error since the type is `never` there.
