README
@agmajs/core-next
Next version for @agmajs/core.
Installation
$ npm i @agmajs/core-next
Usage
const { createScript } = require('@agmajs/core-next');
const script = createScript();
Adding commands
SFC - Single File Commands
// index.js
const { createScript } = require('@agmajs/core-next');
const script = createScript();
const commands = require('./commands');
commands.forEach(command => script.addCommand(command));
// commands/index.js
module.exports = [
require('./test.js')
]
// commands/test.js
const { defineCommand } = require('@agmajs/core-next')
module.exports = defineCommand({
name: 'test',
run: (chat, args, script) => {
chat.value = 'Test';
}
});
Inline Commands
// index.js
const { createScript } = require('@agmajs/core-next');
const script = createScript();
script.addCommand({
name: 'test',
run: (chat, args, script) => {
chat.value = 'Test';
}
})
script.init();
Accessing the chat in commands
Commands get access to a paramater called "chat", with this you can mutate the value of the chat or clear it.
defineCommand({
name: 'test',
run: (chat, args, script) => {
console.log(chat.value);
chat.value = 'Test';
chat.clear();
}
});