Skip to content

Commit

Permalink
docs: update write-own-system
Browse files Browse the repository at this point in the history
  • Loading branch information
sogehige committed Feb 6, 2019
1 parent 5c8733f commit d663a4b
Showing 1 changed file with 42 additions and 28 deletions.
70 changes: 42 additions & 28 deletions docs/_master/howto/write-own-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,25 @@
## System template

``` javascript
'use strict'

``` typescript
// bot libraries
const constants = require('../constants')
const System = require('./_interface')
import * as constants from '../constants';
import System from './_interface';

class Yoursystem extends System {
[x: string]: any;

constructor () {
const dependsOn = []
const settings = {
commands: [],
parsers: []
}
super({settings, dependsOn})
const options: InterfaceSettings = {
settings: {
commands: [],
parsers: [],
},
ui: {},
dependsOn: [],
on: {},
};
super(options)
}
}

Expand All @@ -30,10 +34,12 @@ module.exports = new Yoursystem()
### Depends on different system
Some systems have dependencies, e.g. bet system cannot work without points system

``` javascript
const dependsOn = [
'systems.points'
]
``` typescript
const options: InterfaceSettings = {
// ...
dependsOn: ['systems.points'],
// ...
}
```

### Settings variable
Expand All @@ -48,14 +54,18 @@ Settings variable may contain settings for `yoursystem`
- `fnc`: created from second part of command name, if there is no second part `main` is default function
- `isHelper`: mark this command as helper function (e.g. price check is skipped for this command). `false`

``` javascript
const settings = {
``` typescript
const options: InterfaceSettings = {
// ...
commands: [
'!command1', // creates !command1 with default values
{ name: '!command2' }, // same as !command1
{ name: `!command3`, fnc: 'command3', permission: constants.OWNER_ONLY } // with custom values
],
settings: {
// ...
commands: [
'!command1', // creates !command1 with default values
{ name: '!command2' }, // same as !command1
{ name: `!command3`, fnc: 'command3', permission: constants.OWNER_ONLY } // with custom values
],
// ...
},
// ...
}
```
Expand All @@ -69,13 +79,17 @@ const settings = {
- `priority`: what priority should be given to parser, higher priority, sooner it will run. `constants.LOW`
- `permission`: sets default permission for parser. `constants.VIEWERS`

``` javascript
const settings = {
``` typescript
const options: InterfaceSettings = {
// ...
parsers: [
{ name: 'run' },
{ name: 'stop', fireAndForget: true } // with custom values
],
settings: {
// ...
parsers: [
{ name: 'run' },
{ name: 'stop', fireAndForget: true } // with custom values
],
// ...
},
// ...
}
```
Expand Down

0 comments on commit d663a4b

Please sign in to comment.