# ContextMenuHandler

`class` in `seedcord` · v0.14.0

<https://docs.seedcord.org/packages/seedcord/0.14.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> {
    async execute() {
        const message = this.target;
    }
}
```

## Constructors

### constructor

```ts
InteractionHandler(event: Repliable, core: Core)
```

Constructs a new instance of the `InteractionHandler` class

## Properties

### core

```ts
readonly core: Core
```

### event

```ts
protected readonly event: ValidEvent
```

### logger

```ts
protected readonly logger: Logger
```

### 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.

## Methods

### execute

```ts
abstract async execute(): Promise<void>
```

Holds the main logic of your handler. The dispatcher calls it after the handler's gates pass, so a gate that refuses stops `execute()` from running.
