Skip to content

Latest commit

 

History

History
47 lines (32 loc) · 1.77 KB

README.md

File metadata and controls

47 lines (32 loc) · 1.77 KB

GramUS Modules

Customizing GramUS.

Introduction

GramUS can be customized with modules. GramUS modules are JavaScript files hosted in a GitHub repository, which includes some handlers that will be added to a GramUS instance after they are installed. A GramUS module can be written by you or someone else, in either JavaScript or TypeScript. But if one writes a module in TypeScript, they should build it to JavaScript before it works and gets published.

The goal of this repository is to collect useful modules for you (and by you). Anyone can add their modules to here by sending a PR.

Installing modules

For installing modules in a GramUS instance, simply use the .update command with the following syntax:

.update <user>/<repo>/<module_name>(/<branch>)

1️⃣ The < and > signs are just to tell you that the value can change, they should not be included when using the command.
2️⃣ Arguments inside ( and ) are optional.

Hello world module example

  1. Clone the GramUS repository:
git clone https://github.com/gramus/gramus
  1. Open the cloned folder with an editor.
  2. Create a new file named hello.ts in the src/handlers folder with the following code:
import { CommandHandler } from "../userbot";

export default new CommandHandler(
  async (client, event) => {
    await event.message.reply({ message: "world!" });
  },
  { commands: "hello" }
);
  1. Run your bot, and try if it works.
  2. Find your handler's compiled JavaScript file in the dist folder and fix the imports from other directories, for example replace ../userbot with ../dist/userbot.
  3. Upload it to a GitHub repository in a folder with the same name of your handler file without .js.
  4. Install it with the instruction above.