# Function: add() (/jsdoc/pixi-vn-ink/index/namespaces/HashtagCommands/functions/add)



## Call Signature [#call-signature]

\> **add**(`handler`): `void`

Defined in: [src/handlers/hashtag-commands.ts:65](https://github.com/DRincs-Productions/pixi-vn-ink/blob/8d45a4e5f29997844c9784f1a713b33e5400b7d0/src/handlers/hashtag-commands.ts#L65)

### Parameters [#parameters]

#### handler [#handler]

[`HashtagHandler`](/jsdoc/pixi-vn-ink/index/type-aliases/HashtagHandler)

### Returns [#returns]

`void`

### Deprecated [#deprecated]

Use the two-parameter overload with [HashtagHandlerOptions](/jsdoc/pixi-vn-ink/index/interfaces/HashtagHandlerOptions) instead.

## Call Signature [#call-signature-1]

\> **add**(`handler`, `opts`): `void`

Defined in: [src/handlers/hashtag-commands.ts:90](https://github.com/DRincs-Productions/pixi-vn-ink/blob/8d45a4e5f29997844c9784f1a713b33e5400b7d0/src/handlers/hashtag-commands.ts#L90)

This function add a new handler (middleware) that will be called before the system interprets a possible Hashtag-Command that starts with `#`.
The developer can use this function to run a custom Hashtag-Command. If the function returns `true`, the system will not interpret the Hashtag-Command.
If returns a array of strings, the system will interpret the array as a new Hashtag-Command.

### Parameters [#parameters-1]

#### handler [#handler-1]

[`HashtagHandler`](/jsdoc/pixi-vn-ink/index/type-aliases/HashtagHandler)

The handler to run a custom Hashtag-Command

#### opts [#opts]

[`HashtagHandlerOptions`](/jsdoc/pixi-vn-ink/index/interfaces/HashtagHandlerOptions)

Configuration for this handler, including its name, optional description, and validation rule.

### Returns [#returns-1]

`void`

### Example [#example]

```ts title="content/ink/hashtag-commands.ts"
import { HashtagCommands } from 'pixi-vn-ink'

HashtagCommands.add((script, props, convertListStringToObj) => {
   // script: # navigate scene_name prop1 "value 1" prop2 "value 2"
   if (script[0] === "navigate" && script.length > 1) {
       let prop = undefined
       if (script.length > 2) {
           prop = convertListStringToObj(script.slice(2))
       }
       navigateTo(script[1], prop)
       return true
   }
   return false
}, { name: "navigate-command", validation: /^navigate\b/ })
```
