Skip to content

Commit

Permalink
docs: add example for running random command in alias
Browse files Browse the repository at this point in the history
Fixes #1861

[skip-tests]
  • Loading branch information
sogehige committed Feb 11, 2019
1 parent 33f9acf commit da8d446
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/_master/_sidebar.md
Expand Up @@ -46,6 +46,7 @@
* How To
* [Phillips Hue](_master/howto/phillipshue.md)
* [Eval snippets](_master/howto/eval.md)
* [Run random command](_master/howto/run-random-command.md)
* [Write own system](_master/howto/write-own-system.md)
* Integrations
* [Twitter](_master/integrations/twitter.md)
Expand Down
25 changes: 25 additions & 0 deletions docs/_master/howto/run-random-command.md
@@ -0,0 +1,25 @@
!> You need to have **alias** system enabled

## Example

### Custom variable $_randomCommands

For randomizing commands, you will need to create **eval** custom variable with
run script set to **When variable is used**

```javascript
// set of commands
const commands = [
'!me',
'!top time',
'!points',
];

// return random command
return _.sample(commands);
```

### Alias configuration

Create alias `!youraliashere` with response `$_randomCommands`, this will
trigger random command.

0 comments on commit da8d446

Please sign in to comment.