|
1 | 1 | # Library |
2 | 2 |
|
3 | 3 | ## Basic Information |
4 | | -Library is one of the unique triggers, that doesn't get triggered by events in your server. It can be included in other commands so you can use the code in it by calling `$includeLibrary[Library name]` |
| 4 | +Library is one of the unique triggers, that doesn't get triggered by events in your server. A library can be included (referenced) in other commands so you can use the code in it after calling `$includeLibrary[Library name]`. |
5 | 5 |
|
6 | | -The goal of this trigger is simply sharing code or functions between custom commands (you will understand in the examples) |
| 6 | +The goal of this trigger is simply sharing code, functions or objects across multiple custom commands (see the example below). |
7 | 7 |
|
8 | 8 | ## Syntax |
9 | | -the value of the trigger is the `Library name` |
| 9 | +The value of the trigger is the `Library name`. |
10 | 10 |
|
11 | 11 | ## Example |
12 | 12 | ### Create your library that contains users' information |
13 | | -> note that the library name is `users`. We will use it in next step. |
| 13 | +> Note that the library name is `users`. We will use it in next step. |
14 | 14 |
|
15 | 15 |  |
16 | 16 |
|
17 | 17 | ### Create a normal word command `whois` |
18 | | -First let's include the library, with `$includeLibrary` |
19 | | -after including, we can directly use the object and retrieve some information to display. |
| 18 | +First, let's include the library, with `$includeLibrary`. |
| 19 | +After including, we can directly use the object defined in the library and retrieve some information to display. |
20 | 20 |
|
21 | 21 |  |
22 | 22 |
|
23 | 23 | ### Output |
24 | 24 |  |
25 | 25 |
|
26 | 26 | ## What is the point? |
27 | | -Here we only included this library in 1 commands |
28 | | -what if we have 10 or 50 commands that uses this information, you can easily use it without copying the user information for each command, |
29 | | -besides if you plan to add a new user, with libraries you will only add it to the `users` library |
30 | | -but without libraries, you would have to add the same users 50 times, to every command |
| 27 | +In this example the object is only used in a single custom command. But at some point you might want to add another custom command using the same object, e.g. `listusers` sending a message with all users in it. When the object changes, e.g. you want to add another user to it, then you'll have to update the object in all custom commands accordingly. This takes time and there's a chance errors get introduced or one of the custom commands using this object is missed and now uses a different object. With a library you can use the same object across all these commands without having to copy it to each. Updating the object is done in a single place and all custom commands referencing (including) the library `users` will use the updated object at the same time. |
31 | 28 |
|
32 | | -That demonstrates Library's usefulness. |
| 29 | +In the same way you can also define functions in a library to share code across multiple custom commands. |
33 | 30 |
|
| 31 | +That demonstrates a library's usefulness. |
34 | 32 |
|
35 | 33 | ## Some functions related to Library |
36 | | -[$includeLibrary](../Unclassified/includeLibrary.md): Include your library |
| 34 | +[$includeLibrary](../Useful/includeLibrary.md): Include your library |
0 commit comments