Installation
Before you start you need Node.js and a bot application created in the Discord Developer Portal. From there, copy your bot's token, and; if you plan to use slash commands; its application (client) ID too.
Install the package
npm install syntx.jsNote
syntx.js already depends on discord.js and re-exports its entire API. You don't need to install or import discord.js separately; require("syntx.js") gives you ERXClient and everything discord.js exports (Client, GatewayIntentBits, EmbedBuilder, and so on) from a single package.
Set up your token
Create a .env file in the root of your project and store your credentials there. Never commit this file to a public repository.
TOKEN=your-secret-token-heresyntx.js doesn't load .env files on its own. dotenv ships as one of its dependencies, so it's already sitting in node_modules; just load it at the very top of your entry file, before requiring syntx.js:
require("dotenv").config();
const { ERXClient } = require("syntx.js");Warning
Add .env and node_modules to your .gitignore so you don't expose your token or commit dependencies.
Recommended project structure
syntx.js works well with this folder layout, especially once you start using client.handler() to auto-load files:
Tip
Not sure which gateway intents your bot needs? ERXClient requires at least one, and some events won't fire without the right ones enabled; see Client → About intents for a sane default to start from.
Once installed, continue with Your first bot.