You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ruby is a library for command resolving and parsing.
5
+
Ruby is a library for command resolving and parsing. Designed to be platform-agnostic, it can be used for Slack and Twitch bots as well as Discord bots.
6
6
7
7
## Installation
8
8
@@ -14,41 +14,138 @@ npm install @botsocket/ruby
14
14
15
15
## Usage
16
16
17
+
Setting up Ruby is often a 3 step process.
18
+
19
+
First, create a new registry. Note that only one registry should be created for the whole application:
20
+
21
+
```js
22
+
constRuby=require('@botsocket/ruby');
23
+
24
+
constregistry=Ruby.registry();
25
+
```
26
+
27
+
Next, define your commands and pass definition-specific data (recommended to store command handlers):
28
+
29
+
```js
30
+
31
+
// !ban member reason
32
+
33
+
registry.add({
34
+
name:'ban',
35
+
args: ['member', 'reason'],
36
+
37
+
data: {
38
+
handler(args, flags) {
39
+
40
+
// Do stuff
41
+
}
42
+
}
43
+
});
44
+
```
45
+
46
+
Last, find the matching definitions by parsing the command:
47
+
48
+
```js
49
+
constmatches=registry.match('!ban member reason');
0 commit comments