npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

slchat.js

v2.5.6

Published

Lightweight Fast Node.js Wrapper for slchat API

Readme

slchat.js - Lightweight Fast Node.js Wrapper for slchat API

Created by: Aarav Mehta Published on NPM: slchat.js GitHub Repository: axrxvm/slchat.js


Table of Contents

  1. Introduction
  2. Features
  3. Installation
  4. Bot Setup
  5. Command Registration
  6. Sending Messages
  7. Message Formatting
  8. Embed Building
  9. Command-Line Interface (CLI)
  10. Error Handling and Logging
  11. Cache Management
  12. Contributing
  13. License

Introduction

slchat.js is a lightweight and fast Node.js wrapper for interacting with the slchat API. This package simplifies the process of creating bots for the slchat messaging platform by providing an easy-to-use interface to interact with servers, send and format messages, and manage bot commands.

With slchat.js, developers can quickly set up and deploy bots with the following key features:

  • Easy-to-use API for interacting with the slchat platform.
  • Flexible command registration system to handle custom commands.
  • Rich message formatting options (embeds, codeblocks, images, etc.).
  • A command-line interface for managing bot configurations.
  • Simple error handling and logging.

Features

  • Fast and Lightweight: Optimized for performance and low memory usage.
  • Message Formatting: Support for rich text, embeds, and multimedia attachments.
  • Bot Management: Configure the bot's behavior with ease using the Bot class.
  • Command Handling: Register custom commands and handle user input dynamically.
  • Error Handling: Built-in error management and logging to make debugging easier.
  • CLI Interface: Simple CLI to manage bot configurations and send messages.
  • Cache Management: Reduce redundant API calls by caching data like users and servers.

Installation

To install slchat.js, you need to use npm or yarn. Run the following command to install it as a dependency in your project:

Using npm:

npm install slchat.js

Using yarn:

yarn add slchat.js

After installation, you can require it in your Node.js application:

const { Bot, command, log, errorLog, successLog } = require('slchat.js');

Bot Setup

To set up your bot, you need to create a new Bot instance. The Bot class allows you to define various configurations for your bot, such as command prefix, message handling, and error handling.

Basic Example

const bot = new Bot({
  prefix: "!",  // Define the prefix for commands (default is '!')
  onStart: () => successLog("Bot has successfully started!"),
  onError: (error) => errorLog("Error:", error),
  onMessage: (ctx) => {
    log(`Received message: ${ctx.content}`);
  },
  autoReconnect: true // Auto reconnect when disconnected
});

// Start the bot
bot.run('YOUR_BOT_TOKEN', 'YOUR_BOT_ID');

Bot Configuration Options

  • prefix: The prefix used for commands (default: !).
  • onStart: Function that is called when the bot starts successfully.
  • onError: Function that is called in case of an error.
  • onMessage: Function that is triggered when a message is received.
  • autoReconnect: Boolean value to enable auto-reconnection if the bot gets disconnected.

Once the bot is configured, you can run it by calling the run() method with your bot's token and ID.


Command Registration

Custom commands can be registered using the command() function. You can define how the bot should respond to specific commands or messages.

Basic Command Registration

command("hello", (ctx) => {
  ctx.reply("Hello, World!");
});

command("ping", (ctx) => {
  ctx.reply("Pong!");
});

Parameters

  • name: The name of the command that the bot will respond to (e.g., "hello").
  • func: A callback function that is executed when the command is invoked. The ctx object contains message details and methods for replying.

Example: Using Command Arguments

command("greet", (ctx) => {
  const name = ctx.args[0] || "User";
  ctx.reply(`Hello, ${name}!`);
});

In this example, the bot replies with "Hello, User!" unless a name is passed as an argument when the command is called.


Sending Messages

To send messages to specific servers or groups, use the say CLI Command or call the ctx.reply or bot.send function

Message Formatting

Messages can be formatted using markdown-like syntax, or you can send rich messages such as embeds or multimedia attachments.


Message Formatting

slchat.js supports various message formatting types to enhance the appearance of your messages.

Text Formatting

  • Bold: strong:<message>
  • Italic: italic:<message>
  • Strikethrough: strike:<message>
  • Underline: underline:<message>
  • Code: code:<message>
  • Codeblock: codeblock:<message>
  • Quote: quote:<message>

Embeds

The bot can send embedded messages that include titles, descriptions, and other metadata.

  • Embed Note: embed:note:<message>
  • Embed Success: embed:success:<message>
  • Embed Info: embed:info:<message>
  • Embed Warning: embed:warn:<message>
  • Embed Error: embed:error:<message>
  • Embed Clean: embed:clean:<message>

Attachments

  • Image: img:<url>
  • Audio: audio:<url>
  • Video: video:<url>

These allow you to send multimedia content as part of your message.


Embed Builder

The EmbedBuilder class provides a fluent interface for generating clean, styled HTML-based embeds for bots using the SLChat platform. It supports fields, attachments, icons, code blocks, and customizable layout behavior.

For detailed Information : see EmbedBuilder.md


Command-Line Interface (CLI)

slchat.js includes a basic CLI to manage and configure your bot. The available commands include:

  • status: Displays the bot's connection status.
  • listservers: Lists all servers the bot is currently connected to.
  • addserver <server_id>: Adds a server to the bot's connection.
  • change : Modifies a bot configuration setting.
  • exit: Exits the bot process.
  • say <server|all> : Sends a message to a specific server or all connected servers.

CLI Example

status            # View bot connection status
listservers       # View all connected servers
addserver server1 # Add a server
change prefix !   # Change command prefix
exit              # Exit bot
say all Hello!    # Send message to all servers

Error Handling and Logging

slchat.js includes built-in logging and error-handling capabilities. You can log messages at various stages of the bot’s lifecycle.

  • log(): General information logging.
  • errorLog(): Logs error messages with stack traces.
  • successLog(): Logs successful actions.

Example

const bot = new Bot({
  onError: (error) => errorLog("Error in Bot:", error),
  onStart: () => successLog("Bot has started!"),
  onMessage: (ctx) => log(`Received message: ${ctx.content}`),
});

Cache Management

The bot uses an internal cache to store data such as users and servers, which reduces the number of API calls required. This is particularly useful for improving performance in larger bots.

Cache Behavior:

  • Cached data is automatically cleared every hour.
  • You can access the cache using the getJsonCache() method to get previously fetched data.

Contributing

We welcome contributions to slchat.js! If you'd like to contribute, follow the steps below:

  1. Fork the repository on GitHub.
  2. Clone the repository to your local machine.
  3. Create a new branch for your feature or bugfix.
  4. Make your changes and commit them.
  5. Push your changes to your fork.
  6. Open a pull request with a detailed explanation of your changes.

For bug reports, feature requests, or questions, feel free to open an issue in the GitHub repository.


License

slchat.js is licensed under the MIT License. See the LICENSE file for more details.


Contact