tynoengine.js
v1.0.3
Published
A powerful, flexible Discord bot engine — commands, interactions, plugins, database, scheduler, i18n, pagination, TynoCard, and more.
Maintainers
Readme
TynoEngine.js
A simple, flexible Discord bot engine built on discord.js.
Installation
npm install tynoengine.jsQuick Start
import { Bot } from "tynoengine.js";
const bot = new Bot({ token: "YOUR_BOT_TOKEN" });
bot.start();Or use a .env file — no extra setup needed, it's loaded automatically:
# .env
BOT_TOKEN=YOUR_BOT_TOKENconst bot = new Bot({ token: process.env.BOT_TOKEN });Commands
Register slash commands — they're automatically synced with Discord on startup:
bot.addCommand({
name: "ping",
description: "Replies with Pong!",
execute: async (interaction) => {
await interaction.reply("Pong! 🏓");
},
});
// Ephemeral reply (only visible to the user)
bot.addCommand({
name: "secret",
description: "Only you can see this",
execute: async (interaction) => {
await interaction.reply({ content: "Shhh 🤫", ephemeral: true });
},
});Events
Listen to any discord.js event directly:
bot.on("messageCreate", (message) => {
if (message.content === "hello") {
message.reply("Hey there! 👋");
}
});
bot.on("guildMemberAdd", (member) => {
console.log(`${member.user.tag} joined the server`);
});Plugins
Break your bot into reusable, self-contained modules:
// plugins/greet.ts
import { Plugin } from "tynoengine.js";
const greetPlugin: Plugin = {
name: "greet",
setup(bot) {
bot.addCommand({
name: "greet",
description: "Say hello",
execute: (i) => i.reply("Hello! 👋"),
});
},
};
export default greetPlugin;// Load a single plugin
bot.use(greetPlugin);
// Load all plugins from a folder automatically
bot.loadPlugins("./plugins");Adapters
Choose the runtime that fits your infrastructure:
GatewayAdapter (default)
WebSocket connection — for regular servers, VPS, or always-on hosting.
import { Bot, GatewayAdapter } from "tynoengine.js";
const bot = new Bot({
token: "...",
adapter: new GatewayAdapter(), // this is the default
});
bot.start();ContainerAdapter
Extends GatewayAdapter with Docker/Kubernetes support:
- Graceful shutdown on
SIGTERM/SIGINT - Health check endpoint for
HEALTHCHECKor liveness probes
import { Bot, ContainerAdapter } from "tynoengine.js";
const bot = new Bot({
token: "...",
adapter: new ContainerAdapter({ healthPort: 8080 }),
});
bot.start();
// GET http://localhost:8080/ → { status: "ok", uptime: 42, tag: "MyBot#1234" }Dockerfile example:
FROM node:20-alpine
WORKDIR /app
COPY . .
RUN npm install
HEALTHCHECK --interval=30s CMD wget -qO- http://localhost:8080/ || exit 1
CMD ["node", "index.js"]LambdaAdapter
Serverless — for AWS Lambda and compatible platforms.
Discord sends HTTP POST requests to your function. No WebSocket connection is opened.
Setup:
- Go to the Discord Developer Portal → your app → Interactions Endpoint URL
- Set it to your Lambda function URL
- Copy your app's Public Key
import { Bot, LambdaAdapter } from "tynoengine.js";
const adapter = new LambdaAdapter({
publicKey: process.env.DISCORD_PUBLIC_KEY!,
});
const bot = new Bot({ token: process.env.BOT_TOKEN, adapter });
bot.addCommand({
name: "ping",
description: "Pong!",
execute: (i) => i.reply("Pong! 🏓"),
});
await bot.start();
// Export as your Lambda handler
export const handler = bot.getLambdaHandler();Full Customization
Pass any discord.js ClientOptions for complete control:
import { Bot, GatewayIntentBits, Partials } from "tynoengine.js";
const bot = new Bot({
token: "...",
debug: true,
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],
clientOptions: {
partials: [Partials.Message],
rest: { timeout: 15_000 },
},
});Access the raw discord.js client for anything TynoEngine doesn't cover yet:
const client = bot.getClient();Chaining
All setup methods are chainable:
const bot = new Bot({ token: "..." });
bot
.addCommand({ name: "ping", description: "Pong!", execute: (i) => i.reply("Pong!") })
.addCommand({ name: "help", description: "Help", execute: (i) => i.reply("...") })
.on("messageCreate", (msg) => console.log(msg.content))
.use(greetPlugin)
.start();API
new Bot(options)
| Option | Type | Description |
| --------------- | --------------------- | -------------------------------------------------------- |
| token | string | Bot token. Falls back to BOT_TOKEN env var. |
| intents | GatewayIntentBits[] | Gateway intents (default: [Guilds]) |
| clientOptions | ClientOptions | Any extra discord.js client options |
| debug | boolean | Enable verbose logging (default: false) |
| adapter | BotAdapter | GatewayAdapter | ContainerAdapter | LambdaAdapter |
Methods
| Method | Description |
| ------------------------------- | ---------------------------------------------------- |
| bot.start() | Connect to Discord |
| bot.stop() | Disconnect gracefully |
| bot.addCommand(definition) | Register a slash command |
| bot.on(event, listener) | Listen to a discord.js event |
| bot.use(plugin) | Load a plugin |
| bot.loadPlugins(dir) | Load all plugins from a directory |
| bot.getLambdaHandler() | Get serverless handler (requires LambdaAdapter) |
| bot.getClient() | Access the raw discord.js Client |
Requirements
- Node.js 16.11.0 or higher
License
MIT
