1
0
mirror of https://github.com/hack-chat/main.git synced 2024-03-22 13:20:33 +08:00
hack-chat-main/templateCommand.js

50 lines
1.4 KiB
JavaScript
Raw Normal View History

2018-03-10 15:47:00 +08:00
/*
Description: This is a template module that should not be on prod
2018-03-10 15:47:00 +08:00
*/
// 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
*/
2018-03-10 15:47:00 +08:00
exports.run = async (core, server, socket, data) => {
server.reply({
cmd: 'info',
text: `SHOWCASE MODULE: ${core.showcase} - ${createReply(data.echo)}`
2018-03-10 15:47:00 +08:00
}, 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
*/
2018-03-10 15:47:00 +08:00
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
2018-03-10 15:47:00 +08:00
exports.requiredData = ['echo'];
// optional parameters are marked, all others are required
2018-05-12 16:43:12 +08:00
exports.info = {
2018-03-10 15:47:00 +08:00
name: 'showcase', // actual command name
2018-05-12 16:43:12 +08:00
aliases: ['templateModule']
2018-03-10 15:47:00 +08:00
};