TeleJS
TeleJS is a framework built in top of node-telegram-bot-api to help you build telegram bots more flexible and powerful.
TeleJS is pretty new, expect bugs!
@TeleJS Alpha v1.0.0
Guide
Creating a client for our bot
const { TeleClient } = require("telejs-framework");
const client = new TeleClient("token", {
owners: ["owner_id"],
});
Creating a command handler
const { TeleClient, CommandHandler } = require("telejs-framework");
const client = new TeleClient("token", {
owners: ["owner_id"],
});
const commandHandler = new CommandHandler(client, {
prefix: "!",
directory: "./commands",
});
commandHandler.loadCommands();
Creating a command
Command files must be inside the directory path specified inside CommandHandler options.
const { Command } = require("telejs-framework");
class Ping extends Command {
constructor() {
super({
name: "ping",
aliases: ["p"],
description: "Ping pong command",
category: "general",
});
}
async execute(message) {
return this.client.sendMessage(message.chat.id, "Pong!");
}
}
module.exports = Ping;
Creating a listener handler
const {
TeleClient,
CommandHandler,
ListenerHandler,
} = require("telejs-framework");
const client = new TeleClient("token", {
owners: ["owner_id"],
});
const commandHandler = new CommandHandler(client, {
prefix: "!",
directory: "./commands",
});
const listenerHandler = new ListenerHandler(client, {
directory: "./listeners",
});
listenerHandler.setEmitters({
commandHandler,
});
listenerHandler.loadListeners();
commandHandler.loadCommands();
Creating a listener
Listener files must be inside the directory path specified inside ListenerHandler options.
const { Listener } = require("telejs-framework");
class MessageListener extends Listener {
constructor() {
super({
name: "message",
event: "message",
emitter: "client",
once: false,
});
}
async execute(message) {
console.log(message);
}
}
module.exports = MessageListener;
More detailed guide and docs will be available soon!
Contact
Github repo is coming with the next update!
Discord Server
Telegram