A powerful and easy-to-use Revolt.chat API wrapper for Node.js. Build feature-rich bots with minimal code.
npm install revolt-script- π― 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
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');const { Client } = require('revolt-script');
const client = new Client();client.user- The bot's user objectclient.users- User manager (cache & fetch)client.channels- Channel manager (cache & fetch)client.servers- Server manager (cache & fetch)client.readyAt- Timestamp when bot became readyclient.isLoggedIn- Boolean indicating login status
Authenticate and connect the bot to Revolt.
await client.login('YOUR_BOT_TOKEN');Disconnect the bot and cleanup resources.
await client.destroy();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);
});message.id- Message IDmessage.content- Message contentmessage.author- Message author (User object)message.authorID- Author's user IDmessage.channel- Channel object where message was sentmessage.channelID- Channel IDmessage.attachments- Array of attachmentsmessage.mentions- Array of mentioned usersmessage.editedAt- Timestamp of last edit (null if not edited)
await message.channel.sendMessage('Hello World!');await message.channel.sendMessage('Reply text', [], message.id);const attachments = [{ id: 'file_id_here' }];
await message.channel.sendMessage('File attached', attachments);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]);Quick reply to a message.
await message.reply('Thanks for your message!');Create rich, beautiful embeds with the EmbedBuilder class.
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]);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]);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]);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]);| 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 | - |
user.id- User IDuser.username- Usernameuser.discriminator- User discriminator (e.g., "0001")user.tag- Full tag (username#discriminator)user.bot- Boolean indicating if user is a botuser.online- Online statususer.status- User status objectuser.avatar- Avatar objectuser.isClientUser- Boolean indicating if this is the bot user
// 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');Fetch detailed user profile.
const profile = await user.fetchProfile();Open a DM channel with the user.
const dmChannel = await user.openDM();
await dmChannel.sendMessage('Hello!');channel.id- Channel IDchannel.name- Channel namechannel.description- Channel descriptionchannel.serverID- Server ID (if in a server)channel.owner- Channel owner ID
// Fetch from API
const channel = await client.channels.fetch('CHANNEL_ID');
// Get from cache
const cachedChannel = client.channels.get('CHANNEL_ID');Send a message to the channel.
Parameters:
content(string) - Message contentattachments(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, []);Refresh channel data from API.
await channel.fetch();server.id- Server IDserver.name- Server nameserver.description- Server descriptionserver.ownerID- Owner user IDserver.owner- Owner user objectserver.channels- Array of channel IDsserver.roles- Roles objectserver.icon- Server icon objectserver.systemMessages- System messages configuration
// Fetch from API
const server = await client.servers.fetch('SERVER_ID');
// Get from cache
const cachedServer = client.servers.get('SERVER_ID');Fetch all server members.
const members = await server.fetchMembers();
members.forEach(member => {
console.log(`${member.user.tag} - ${member.nickname || 'No nickname'}`);
});Leave the server.
await server.leave();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');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');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');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');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);
});- Visit the Revolt Developer Portal
- Create a new bot
- Copy your bot token
- Invite the bot to your server
- 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
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]);This project is licensed under the ISC License.
- β¨ 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! π