1.0.0-beta.3 • Published 5 years ago

agmaio-script-lib v1.0.0-beta.3

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

agmaio-script-lib

Create an Agma.io script with ease.

Table of Contents

Features

  • Create commands per file.
  • Ability to use NPM packages in commands.

Installing

Using NPM:

$ npm install agmaio-script-lib

Using Yarn:

$ yarn add agmaio-script-lib

Example

If you wish to build your script to test/use it, you can take a look at the agmaio-script-lib-template repository.

Examples

See the agmaio-script-lib-template repository for a full example.

CommonJS usage:

const { Core } = require('agmaio-script-lib');

ES6 usage:

import { Core } from 'agmaio-script-lib';

Creating a command

const { Core, Command } = require('agmaio-script-lib');

// Create the script instance.
const Script = new Core();

// Create a command which will display 'Hello World!' in chat.
const ExampleCommand = new Command({
  name: 'example',
  run: (core, args, chatUtils) => {
    chatUtils.set('Hello World!');
  }
});

// Add the command to the script.
Script.CommandModule.addCommand(ExampleCommand);

Creating a command and using args

const { Command } = require('agmaio-script-lib');

// Create a command which will use the first argument given as name.
const ExampleArgsCommand = new Command({
  name: 'exampleArgs',
  run: (core, args, chatUtils) => {
    if (args.length) {
      chatUtils.set(`Hello, ${args[0]}!`);
    }
  }
})
1.0.0-beta.3

5 years ago

1.0.0-beta.2

5 years ago

1.0.0-beta.1

5 years ago

1.0.0-beta

5 years ago