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.
npm install novecord
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();
The main class that connects to Discord via WebSocket.
new Client(options)// Options:// - token: Bot token (string)// - intents: Discord Gateway Intents (bitfield)
.login()
- Starts the bot and connects to Discord.sendMessage(channelId, payload)
- Sends a message.on(event, callback)
- Subscribe to Discord eventsclient.user
- Information about the connected bot userBitfield values to filter events from Discord Gateway.
const { Intents } = require('novecord');// Common intentsIntents.Guilds // Server eventsIntents.GuildMessages // Message eventsIntents.GuildMembers // Member eventsIntents.MessageContent // Message content access// Combine intents with bitwise ORconst intents = Intents.Guilds | Intents.GuildMessages;
Allows you to make REST requests to Discord API.
const { REST, Routes } = require('novecord');const rest = new REST('YOUR_BOT_TOKEN');// GET requestconst user = await rest.get(Routes.User('@me'));// POST requestawait rest.post(Routes.ChannelMessages('channel_id'), { content: 'Hello World!'});
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]});
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!' }); } }});
Client and ShardManager are EventEmitter based.
// Common eventsclient.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}`);});
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 }); }});
// Register slash commandconst { 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 commandclient.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}>!` }); }});