aboutsummaryrefslogtreecommitdiffstats
path: root/documentation/templateCommand.js
diff options
context:
space:
mode:
authormarzavec <admin@marzavec.com>2018-05-20 02:21:08 +0200
committermarzavec <admin@marzavec.com>2018-05-20 02:21:08 +0200
commita70006b5bca3c3273ba34bfd0607235339e87583 (patch)
treef360e6d4e5e636956fa03a32a6f8064285ba424a /documentation/templateCommand.js
parentMerge pull request #12 from neelkamath/master (diff)
downloadhackchat-a70006b5bca3c3273ba34bfd0607235339e87583.tar.gz
hackchat-a70006b5bca3c3273ba34bfd0607235339e87583.zip
streamline dev flow
Diffstat (limited to 'documentation/templateCommand.js')
-rw-r--r--documentation/templateCommand.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/documentation/templateCommand.js b/documentation/templateCommand.js
new file mode 100644
index 0000000..1a4f3d2
--- /dev/null
+++ b/documentation/templateCommand.js
@@ -0,0 +1,52 @@
+/*
+ Description: This is a template module that should not be user in a production
+ enviroment
+*/
+
+// you can require() modules here
+
+// this function will only be only in the scope of the module
+const createReply = (echoInput) => {
+ if (echoInput.length > 100)
+ echoInput = 'HOW ABOUT NO?';
+
+ return `You want me to echo: ${echoInput}?`
+};
+
+/*
+ `exports.run()` is required and will always be passed (core, server, socket, data)
+
+ be sure it's async too
+ this is the main function that will run when called
+*/
+exports.run = async (core, server, socket, data) => {
+
+ server.reply({
+ cmd: 'info',
+ text: `SHOWCASE MODULE: ${core.showcase} - ${createReply(data.echo)}`
+ }, socket);
+
+};
+
+/*
+ `exports.init()` is optional, and will only be run when the module is loaded into memory
+ it will always be passed a reference to the global core class
+ note: this will fire again if a reload is issued, keep that in mind
+*/
+exports.init = (core) => {
+ if (typeof core.showcase === 'undefined') {
+ core.showcase = 'init is a handy place to put global data by assigning it to `core`';
+ }
+}
+
+// optional, if `data.echo` is missing `exports.run()` will never be called & the user will be alerted
+// remember; this will only verify that the data is not undefined, not the type of data
+exports.requiredData = ['echo'];
+
+// optional parameters are marked, all others are required
+exports.info = {
+ name: 'showcase', // actual command name
+ aliases: ['templateModule'], // optional, an array of other names this module can be executed by
+ usage: 'showcase {echo}', // used for help output, can be ommited if no parameters are required
+ description: 'Simple command module template & info' // used for help output
+};