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
plugins: [ownerOnly('<your user id would go here>')],
@@ -69,22 +88,37 @@ export default new SparkCommand({
69
88
});
70
89
```
71
90
72
-
## Controller
91
+
## Init Plugins
92
+
93
+
Init plugins are plugins that run once a command is initialized/loaded.
73
94
74
-
The controller is what controls your flow of your code. If you do `controller.stop()` in your command, it'll stop the execution of your command.
95
+
The pattern of creating these plugins are very similar to creating any other plugin, you just have to use the `InitPlugin` type instead of `CommandPlugin`.
75
96
76
-
Please make sure to return this upon an error in your plugin. For example, if the user is not permitted to use the command, you return `controller.stop()` in your plugin.
97
+
We can create a basic `InitPlugin`, one that logs `${command.name}` whenever a command is loaded.
77
98
78
-
If you have a success in your plugin, return `controller.next()`. This will continue on with the command, and other plugins.
description: 'Logs the plugin name with a success log',
107
+
run({ client, command, controller }) {
108
+
// Logs that the command was loaded
109
+
client.logger.success(`${command.name} was successfully loaded.`);
110
+
111
+
// Continues with execution
112
+
returncontroller.next();
113
+
},
114
+
};
115
+
}
116
+
```
80
117
81
-
## Pre-Process Plugins
118
+
## Controller
82
119
83
-
Plugins that run while your command get registered are called **pre-process plugins.**
120
+
The controller is what controls your flow of your code. If you do `controller.stop()` in your command, it stops the execution of your command.
84
121
85
-
To create a pre-process plugin, just add the `preprocess: true` option to your plugin function's return object.
122
+
Please make sure to return this upon an error in your plugin. For example, if the user is not permitted to use the command, return `controller.stop()` in your plugin.
86
123
87
-
<Callout>
88
-
Pre-process plugins run while the command is registered.
89
-
This means pre-process plugins don't have access to `interaction` or `message`.
90
-
</Callout>
124
+
If you have a success in your plugin, return `controller.next()`. This will execute other plugins, if available, and then the command.
0 commit comments