@agmajs/core-next

Next version for @agmajs/core.

Usage no npm install needed!

<script type="module">
  import agmajsCoreNext from 'https://cdn.skypack.dev/@agmajs/core-next';
</script>

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();

script.init();

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));

script.init();
// 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) => {
    chat.value = 'Test';
  }
});

Inline Commands

// index.js
const { createScript } = require('@agmajs/core-next');

const script = createScript();

script.addCommand({
  name: 'test',
  run: (chat, args) => {
    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) => {
    console.log(chat.value);
    chat.value = 'Test';
    chat.clear();
  }
});