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 🙏

© 2025 – Pkg Stats / Ryan Hefner

revolt-script

v1.0.0

Published

Powerful and easy-to-use Revolt API wrapper for Node.js

Readme

🚀 revolt-script

A powerful and easy-to-use Revolt.chat API wrapper for Node.js. Build feature-rich bots with minimal code.

npm version License: ISC

📦 Installation

npm install revolt-script

✨ Features

  • 🎯 Simple & Intuitive API - Easy to learn and use
  • 🔄 WebSocket Support - Real-time message handling
  • 📨 Rich Messaging - Text, embeds, replies, and attachments
  • 🎨 Embed Builder - Create beautiful rich messages
  • 🔐 Bot Token Authentication - Secure authentication
  • 👥 User, Channel & Server Management - Complete API coverage
  • High Performance - Optimized WebSocket connections
  • 🛠️ Modular Architecture - Easy to extend and customize
  • 📚 Full TypeScript-like Structure - Clean and organized code

🚀 Quick Start

Basic Bot Example

const { Client, Constants } = require('revolt-script');

const client = new Client();

client.on(Constants.EVENTS.READY, () => {
  console.log(`Bot is ready! Logged in as ${client.user.tag}`);
  console.log(`Connected to ${client.servers.cache.size} servers`);
});

client.on(Constants.EVENTS.MESSAGE, async (message) => {
  // Ignore bot messages
  if (message.author.bot) return;
  
  if (message.content === '!ping') {
    await message.channel.sendMessage('Pong! 🏓');
  }
});

client.login('YOUR_BOT_TOKEN');

📖 Documentation

Client

Creating a Client

const { Client } = require('revolt-script');

const client = new Client();

Client Properties

  • client.user - The bot's user object
  • client.users - User manager (cache & fetch)
  • client.channels - Channel manager (cache & fetch)
  • client.servers - Server manager (cache & fetch)
  • client.readyAt - Timestamp when bot became ready
  • client.isLoggedIn - Boolean indicating login status

Client Methods

client.login(token)

Authenticate and connect the bot to Revolt.

await client.login('YOUR_BOT_TOKEN');
client.destroy()

Disconnect the bot and cleanup resources.

await client.destroy();

Events

Subscribe to events using the Constants.EVENTS object:

const { Constants } = require('revolt-script');

// Bot ready
client.on(Constants.EVENTS.READY, () => {
  console.log('Bot is ready!');
});

// Message received
client.on(Constants.EVENTS.MESSAGE, (message) => {
  console.log(`Message: ${message.content}`);
});

// Message updated
client.on(Constants.EVENTS.MESSAGE_UPDATE, (data) => {
  console.log('Message was updated');
});

// Message deleted
client.on(Constants.EVENTS.MESSAGE_DELETE, (data) => {
  console.log('Message was deleted');
});

// Channel events
client.on(Constants.EVENTS.CHANNEL_CREATE, (channel) => {});
client.on(Constants.EVENTS.CHANNEL_UPDATE, (data) => {});
client.on(Constants.EVENTS.CHANNEL_DELETE, (data) => {});

// Server events
client.on(Constants.EVENTS.SERVER_CREATE, (server) => {});
client.on(Constants.EVENTS.SERVER_UPDATE, (data) => {});
client.on(Constants.EVENTS.SERVER_DELETE, (data) => {});

// Member events
client.on(Constants.EVENTS.MEMBER_JOIN, (data) => {});
client.on(Constants.EVENTS.MEMBER_LEAVE, (data) => {});
client.on(Constants.EVENTS.MEMBER_UPDATE, (data) => {});

// User events
client.on(Constants.EVENTS.USER_UPDATE, (data) => {});

// Error handling
client.on('error', (error) => {
  console.error('Error:', error);
});

Messages

Message Properties

  • message.id - Message ID
  • message.content - Message content
  • message.author - Message author (User object)
  • message.authorID - Author's user ID
  • message.channel - Channel object where message was sent
  • message.channelID - Channel ID
  • message.attachments - Array of attachments
  • message.mentions - Array of mentioned users
  • message.editedAt - Timestamp of last edit (null if not edited)

Sending Messages

Simple Message
await message.channel.sendMessage('Hello World!');
Reply to a Message
await message.channel.sendMessage('Reply text', [], message.id);
Message with Attachments
const attachments = [{ id: 'file_id_here' }];
await message.channel.sendMessage('File attached', attachments);
Message with Embeds
const { EmbedBuilder } = require('revolt-script');

const embed = new EmbedBuilder()
  .setTitle('Title')
  .setDescription('Description')
  .setColour('#FF5733')
  .build();

await message.channel.sendMessage('Check this out:', [], null, [embed]);

Message Methods

message.reply(content)

Quick reply to a message.

await message.reply('Thanks for your message!');

🎨 Embed Builder

Create rich, beautiful embeds with the EmbedBuilder class.

Basic Embed

const { EmbedBuilder } = require('revolt-script');

const embed = new EmbedBuilder()
  .setTitle('🎉 Welcome!')
  .setDescription('This is a beautiful embed message')
  .setColour('#3498db')
  .setURL('https://revolt.chat')
  .setSiteName('Revolt')
  .build();

await channel.sendMessage('', [], null, [embed]);

Embed with Image

const embed = new EmbedBuilder()
  .setTitle('Beautiful Image')
  .setDescription('Check out this image')
  .setColour('#2ecc71')
  .setImage('https://exemple.com/image.jpg', 800, 600, 'Large')
  .build();

await channel.sendMessage('', [], null, [embed]);

Embed with Video

const embed = new EmbedBuilder()
  .setTitle('Video Embed')
  .setDescription('Watch this video')
  .setColour('#e74c3c')
  .setVideo('https://example.com/video.mp4', 1920, 1080)
  .build();

await channel.sendMessage('', [], null, [embed]);

Multiple Embeds

const embed1 = new EmbedBuilder()
  .setTitle('First Embed')
  .setColour('#FF0000')
  .build();

const embed2 = new EmbedBuilder()
  .setTitle('Second Embed')
  .setColour('#00FF00')
  .build();

await channel.sendMessage('Multiple embeds:', [], null, [embed1, embed2]);

EmbedBuilder Methods

| Method | Description | Parameters | |--------|-------------|------------| | setTitle(title) | Set embed title | title (string) | | setDescription(description) | Set embed description | description (string) | | setColour(colour) / setColor(color) | Set embed color | colour (string) - Hex code or CSS color | | setURL(url) | Set embed URL | url (string) | | setIconURL(iconUrl) | Set icon URL | iconUrl (string) | | setSiteName(siteName) | Set site name | siteName (string) | | setType(type) | Set embed type | type (string) - Text, Website, Image, Video | | setImage(url, width, height, size) | Add image | url (string), width (number), height (number), size (string) | | setVideo(url, width, height) | Add video | url (string), width (number), height (number) | | build() | Build and return embed object | - | | toJSON() | Convert to JSON string | - |

Users

User Properties

  • user.id - User ID
  • user.username - Username
  • user.discriminator - User discriminator (e.g., "0001")
  • user.tag - Full tag (username#discriminator)
  • user.bot - Boolean indicating if user is a bot
  • user.online - Online status
  • user.status - User status object
  • user.avatar - Avatar object
  • user.isClientUser - Boolean indicating if this is the bot user

Fetching Users

// Fetch from API
const user = await client.users.fetch('USER_ID');
console.log(user.username);

// Get from cache
const cachedUser = client.users.get('USER_ID');

User Methods

user.fetchProfile()

Fetch detailed user profile.

const profile = await user.fetchProfile();
user.openDM()

Open a DM channel with the user.

const dmChannel = await user.openDM();
await dmChannel.sendMessage('Hello!');

Channels

Channel Properties

  • channel.id - Channel ID
  • channel.name - Channel name
  • channel.description - Channel description
  • channel.serverID - Server ID (if in a server)
  • channel.owner - Channel owner ID

Fetching Channels

// Fetch from API
const channel = await client.channels.fetch('CHANNEL_ID');

// Get from cache
const cachedChannel = client.channels.get('CHANNEL_ID');

Channel Methods

channel.sendMessage(content, attachments, repliesToID, embeds)

Send a message to the channel.

Parameters:

  • content (string) - Message content
  • attachments (array) - Array of attachment objects (default: [])
  • repliesToID (string) - ID of message to reply to (default: null)
  • embeds (array) - Array of embed objects (default: [])
await channel.sendMessage('Hello!', [], null, []);
channel.fetch()

Refresh channel data from API.

await channel.fetch();

Servers

Server Properties

  • server.id - Server ID
  • server.name - Server name
  • server.description - Server description
  • server.ownerID - Owner user ID
  • server.owner - Owner user object
  • server.channels - Array of channel IDs
  • server.roles - Roles object
  • server.icon - Server icon object
  • server.systemMessages - System messages configuration

Fetching Servers

// Fetch from API
const server = await client.servers.fetch('SERVER_ID');

// Get from cache
const cachedServer = client.servers.get('SERVER_ID');

Server Methods

server.fetchMembers()

Fetch all server members.

const members = await server.fetchMembers();
members.forEach(member => {
  console.log(`${member.user.tag} - ${member.nickname || 'No nickname'}`);
});
server.leave()

Leave the server.

await server.leave();

🎯 Advanced Examples

Command Handler

const { Client, Constants, EmbedBuilder } = require('revolt-script');

const client = new Client();
const prefix = '!';

const commands = {
  ping: async (message) => {
    await message.channel.sendMessage('Pong! 🏓');
  },
  
  info: async (message) => {
    const embed = new EmbedBuilder()
      .setTitle('ℹ️ Bot Information')
      .setDescription(`
        **Servers:** ${client.servers.cache.size}
        **Users:** ${client.users.cache.size}
        **Uptime:** ${Math.floor(process.uptime())}s
      `)
      .setColour('#3498db')
      .build();
    
    await message.channel.sendMessage('', [], null, [embed]);
  },
  
  help: async (message) => {
    const embed = new EmbedBuilder()
      .setTitle('📚 Help Menu')
      .setDescription(`
        **Commands:**
        \`${prefix}ping\` - Check bot latency
        \`${prefix}info\` - Bot information
        \`${prefix}help\` - This menu
      `)
      .setColour('#2ecc71')
      .build();
    
    await message.channel.sendMessage('', [], null, [embed]);
  }
};

client.on(Constants.EVENTS.MESSAGE, async (message) => {
  if (message.author.bot) return;
  if (!message.content.startsWith(prefix)) return;
  
  const args = message.content.slice(prefix.length).trim().split(/ +/);
  const commandName = args.shift().toLowerCase();
  
  const command = commands[commandName];
  if (command) {
    try {
      await command(message, args);
    } catch (error) {
      console.error(`Error executing ${commandName}:`, error);
      await message.channel.sendMessage('An error occurred while executing that command.');
    }
  }
});

client.login('YOUR_BOT_TOKEN');

Moderation Bot

const { Client, Constants, EmbedBuilder } = require('revolt-script');

const client = new Client();

// Bad words filter
const badWords = ['badword1', 'badword2'];

client.on(Constants.EVENTS.MESSAGE, async (message) => {
  if (message.author.bot) return;
  
  const hasBadWord = badWords.some(word => 
    message.content.toLowerCase().includes(word)
  );
  
  if (hasBadWord) {
    const embed = new EmbedBuilder()
      .setTitle('⚠️ Warning')
      .setDescription('Please do not use inappropriate language!')
      .setColour('#e74c3c')
      .build();
    
    await message.channel.sendMessage('', [], message.id, [embed]);
  }
});

client.login('YOUR_BOT_TOKEN');

Welcome Bot

const { Client, Constants, EmbedBuilder } = require('revolt-script');

const client = new Client();
const WELCOME_CHANNEL_ID = 'YOUR_CHANNEL_ID';

client.on(Constants.EVENTS.MEMBER_JOIN, async (data) => {
  const channel = client.channels.get(WELCOME_CHANNEL_ID);
  if (!channel) return;
  
  const embed = new EmbedBuilder()
    .setTitle('👋 Welcome!')
    .setDescription(`Welcome to the server! Please read the rules.`)
    .setColour('#2ecc71')
    .build();
  
  await channel.sendMessage('', [], null, [embed]);
});

client.login('YOUR_BOT_TOKEN');

Auto-Responder Bot

const { Client, Constants } = require('revolt-script');

const client = new Client();

const responses = {
  'hello': 'Hi there! 👋',
  'how are you': 'I\'m doing great, thanks for asking!',
  'bye': 'Goodbye! See you later! 👋'
};

client.on(Constants.EVENTS.MESSAGE, async (message) => {
  if (message.author.bot) return;
  
  const content = message.content.toLowerCase();
  
  for (const [trigger, response] of Object.entries(responses)) {
    if (content.includes(trigger)) {
      await message.channel.sendMessage(response);
      break;
    }
  }
});

client.login('YOUR_BOT_TOKEN');

🔧 Error Handling

const { Client, Errors } = require('revolt-script');

const client = new Client();

// Handle WebSocket errors
client.on('error', (error) => {
  if (error instanceof Errors.WebSocketError) {
    console.error('WebSocket error:', error.message);
  } else if (error instanceof Errors.APIError) {
    console.error('API error:', error.code, error.message);
  } else if (error instanceof Errors.HTTPError) {
    console.error('HTTP error:', error.status, error.message);
  } else {
    console.error('Unknown error:', error);
  }
});

// Handle login errors
client.login('YOUR_BOT_TOKEN').catch(err => {
  console.error('Failed to login:', err.message);
  process.exit(1);
});

❓ FAQ

How do I get a bot token?

  1. Visit the Revolt Developer Portal
  2. Create a new bot
  3. Copy your bot token
  4. Invite the bot to your server

Why am I not receiving messages?

  • Ensure your bot token is correct
  • Make sure the bot is added to the server
  • Check that the WebSocket connection is established
  • Verify you're listening to the correct events

How do I send embeds?

Use the EmbedBuilder class:

const { EmbedBuilder } = require('revolt-script');

const embed = new EmbedBuilder()
  .setTitle('Title')
  .setDescription('Description')
  .setColour('#FF5733')
  .build();

await channel.sendMessage('', [], null, [embed]);

📄 License

This project is licensed under the ISC License.

🔗 Links

📝 Changelog

v1.0.0

  • ✨ Initial release
  • 📨 Message sending support
  • 🎨 Embed builder
  • 🔄 WebSocket connection
  • 👥 User, channel, and server management
  • 🔐 Bot token authentication
  • ⚡ Event handling system

Made with ❤️ for the Revolt community

Build amazing bots with revolt-script! 🚀