# @scriptserver/command

> Module for registering custom commands that can be activated with chat messages

Latest version **2.0.4** (published 2021-09-15) · GPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install @scriptserver/command
pnpm add @scriptserver/command
yarn add @scriptserver/command
bun add @scriptserver/command
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.4 |
| Published | 2021-09-15 |
| First published | 2021-09-14 |
| Weekly downloads | 0 |
| License | GPL-3.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 45.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 67 |
| Author | Garrett Cox |
| Maintainers | garrettjoecox |
| Keywords | minecraft, server, scriptserver |

## Links

- npm: https://www.npmjs.com/package/@scriptserver/command
- Repository: https://github.com/garrettjoecox/scriptserver
- Homepage: https://github.com/garrettjoecox/scriptserver#readme
- Issues: https://github.com/garrettjoecox/scriptserver/issues
- npm.io page: https://npm.io/package/@scriptserver/command

## Dependencies (3)

- [@scriptserver/core](https://npm.io/package/@scriptserver/core.md) ^2.0.4
- [@scriptserver/event](https://npm.io/package/@scriptserver/event.md) ^2.0.4
- [lodash.defaultsdeep](https://npm.io/package/lodash.defaultsdeep.md) ^4.6.1

## Recent versions

- 2.0.4 (latest) — 2021-09-15
- 2.0.3 — 2021-09-15
- 2.0.2 — 2021-09-14

## README

# @scriptserver/command

[![](http://i.imgur.com/zhptNme.png)](https://github.com/garrettjoecox/scriptserver/tree/master)

#### FYI: This package is an addon for ScriptServer and requires ScriptServer to be set up, please see [here](https://github.com/garrettjoecox/scriptserver/tree/master) for more information.

## `useCommand(javaServer: JavaServer)`

```ts
import { ScriptServer, JavaServer } from '@scriptserver/core';
import { useCommand } from '@scriptserver/command';

const javaServer = new JavaServer({
  command: {
    prefix: '!',
  },
});
useCommand(javaServer);

// Or

const scriptServer = new ScriptServer({
  command: {
    prefix: '!',
  },
});
useCommand(scriptServer.javaServer);
```

## Class: JavaServer

This module does not export JavaServer, but extends it

### `javaServer.command(cmd: string, callback: (event: CommandEvent) => void)`

```ts
javaServer.command('head', ({ player, args }) => {
  javaServer.send(`give ${player} minecraft:skull 1 3 {SkullOwner:"${args[0]}"}`);
});
```

### `javaServer.on('command', (event: CommandEvent) => void)`

This is exposed for advanced uses, not necssary to use this if using the `javaServer.command` method.

## Interface: `Config`

- config: [Config](#interface-config)
  - command
    - prefix: `string` - Prefix in chat to trigger command (default: `~`)

---
_Source: https://npm.io/package/@scriptserver/command · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
