NoveCord Documentation

NoveCord is a flexible and lightweight Discord API wrapper built entirely with Node.js native modules. This documentation will guide you through the basic functions, events, and data structures.

Installation

npm install novecord

Quick Start

const { Client, Intents } = require('novecord');
const client = new Client({
token: 'YOUR_BOT_TOKEN',
intents: Intents.Guilds | Intents.GuildMessages
});
client.on('READY', () => {
console.log('Bot is ready!');
});
client.login();

Client

The main class that connects to Discord via WebSocket.

Constructor

new Client(options)
// Options:
// - token: Bot token (string)
// - intents: Discord Gateway Intents (bitfield)

Methods

  • .login() - Starts the bot and connects to Discord
  • .sendMessage(channelId, payload) - Sends a message
  • .on(event, callback) - Subscribe to Discord events

Properties

  • client.user - Information about the connected bot user

Intents

Bitfield values to filter events from Discord Gateway.

const { Intents } = require('novecord');
// Common intents
Intents.Guilds // Server events
Intents.GuildMessages // Message events
Intents.GuildMembers // Member events
Intents.MessageContent // Message content access
// Combine intents with bitwise OR
const intents = Intents.Guilds | Intents.GuildMessages;

REST API Wrapper

Allows you to make REST requests to Discord API.

const { REST, Routes } = require('novecord');
const rest = new REST('YOUR_BOT_TOKEN');
// GET request
const user = await rest.get(Routes.User('@me'));
// POST request
await rest.post(Routes.ChannelMessages('channel_id'), {
content: 'Hello World!'
});

Embed

Create rich content for messages.

const { Embed } = require('novecord');
const embed = new Embed()
.setTitle('My Embed')
.setDescription('This is a description')
.setColor(0x7289DA)
.addField('Field Name', 'Field Value', true)
.setFooter('Footer text')
.setTimestamp();
client.sendMessage(channelId, {
embeds: [embed]
});

Interactions

Handle slash commands, buttons, modals, and select menus.

client.on('INTERACTION_CREATE', (interaction) => {
if (interaction.type === 2) { // Application Command
if (interaction.data.name === 'ping') {
client.respondInteraction(interaction.id, interaction.token, {
content: 'Pong!'
});
}
}
});

Shard Manager

Manage shards as child processes for scaling large bots.

const { ShardManager } = require('novecord');
const manager = new ShardManager(2, 'YOUR_BOT_TOKEN', intents);
manager.spawnShard(0, './bot.js');
manager.spawnShard(1, './bot.js');
manager.on('shardMessage', (shardId, message) => {
console.log(`Shard ${shardId}: ${message}`);
});

Event System

Client and ShardManager are EventEmitter based.

// Common events
client.on('READY', () => {
console.log('Bot is ready!');
});
client.on('MESSAGE_CREATE', (message) => {
console.log(`Message: ${message.content}`);
});
client.on('INTERACTION_CREATE', (interaction) => {
// Handle slash commands, buttons, etc.
});
client.on('GUILD_CREATE', (guild) => {
console.log(`Joined guild: ${guild.name}`);
});

Message Commands Example

client.on('MESSAGE_CREATE', (message) => {
if (message.author.bot) return;
if (message.content === '!ping') {
client.sendMessage(message.channel_id, {
content: 'Pong!'
});
}
if (message.content.startsWith('!say ')) {
const text = message.content.slice(5);
client.sendMessage(message.channel_id, {
content: text
});
}
});

Slash Commands Example

// Register slash command
const { REST, Routes } = require('novecord');
const rest = new REST('YOUR_BOT_TOKEN');
await rest.post(Routes.ApplicationCommands('YOUR_CLIENT_ID'), {
name: 'hello',
description: 'Say hello to someone',
options: [{
name: 'user',
description: 'User to greet',
type: 6, // USER type
required: true
}]
});
// Handle slash command
client.on('INTERACTION_CREATE', (interaction) => {
if (interaction.data.name === 'hello') {
const user = interaction.data.options[0].value;
client.respondInteraction(interaction.id, interaction.token, {
content: `Hello <@${user}>!`
});
}
});