mppclone-cmapi

1.8.0 • Public • Published

cmapi

cmapi stands for custom message api. This module is meant to be used on MPPClone. It is meant to make the use of custom messages easier.

UPDATE

Apparently unpkg is terrible, so use https://cdn.jsdelivr.net/npm/mppclone-cmapi@latest/dist/cmapi.dist.js instead.

Usage

To use this module, first instantiate it on the client, then you're free to use it as you wish.

The module can detect whether or not your client is already connected, so you can choose to construct it at any point in time, but only once per client.

Node

const cmapi = require('mppclone-cmapi');
const Client = require('mppclone-client');

const client = new Client("wss://mppclone.com:8443", process.env.MPPCLONE_TOKEN);
const cm = new cmapi(client);

client.start();
client.setChannel('test/awkward');

client.on('hi', msg => {
    console.log('Connected to server');
});

cmapi.on('hello', msg => {
    console.log('Received hello');
});

Browser

If you're using a userscript manager such as tampermonkey, you can add a @require tag to your userscript header. Otherwise, you can use webpack or a script tag.

// @require     https://unpkg.com/mppclone-cmapi@latest/dist/cmapi.dist.js
<script src="https://unpkg.com/mppclone-cmapi@latest/dist/cmapi.dist.js"></script>

The usage is the same as Node, however, you don't have to create a client.

MPP.cmapi = new cmapi(MPP.client);

MPP.client.on('hi', msg => {
    console.log('Connected to server');
});

MPP.cmapi.on('hello', msg => {
    console.log('Received hello');
});

Readme

Keywords

Package Sidebar

Install

npm i mppclone-cmapi

Weekly Downloads

182

Version

1.8.0

License

ISC

Unpacked Size

16.3 kB

Total Files

7

Last publish

Collaborators

  • hri7566