Creating a Telegram bot using Discord.js syntax

Sempai-07 - Sep 11 - - Dev Community

Telegramsjs




Bot API
NPM Version
NPM Downloads

About

telegramsjs is a powerful Node.js module that allows you to easily interact with the
Telegram API.

  • Object-oriented
  • Predictable abstractions
  • Performant
  • 100% coverage of the Telegram API

Installation

npm install telegramsjs
yarn add telegramsjs
Enter fullscreen mode Exit fullscreen mode

Optional packages

Example usage

Install telegramsjs:

npm install telegramsjs
yarn add telegramsjs
Enter fullscreen mode Exit fullscreen mode

Afterwards we can create a quite simple example bot:

// ECMAscript/TypeScript
import { TelegramClient } from "telegramsjs";
// CommonJS
const { TelegramClient } = require("telegramsjs");

const client = new TelegramClient("TELEGRAM_BOT_TOKEN");

client.on("ready", async ({ user }) => {
  await user.setCommands([
    {
      command: "/start",
      description: "Starting command",
    },
  ]);

  console.log(`Bot @${user.username} is the ready status!`);
});

client.on("message", async (message) => {
  if (message.content === "/start") {
    return await message.reply(
      `Hello ${message.author.username ? `@${message.author.username}` : message.author.firstName}!`,
    );
  }
});

client.login();
Enter fullscreen mode Exit fullscreen mode

Documentation

For more information and detailed documentation, please visit the documentation.

Contributions

We welcome contributions to the development of TelegramsJS ! If you have any ideas or suggestions, please visit the Official Support Server or the Official Telegram Channel.

Example

For a comprehensive example of using the library, please refer to the GitHub page.

License

Telegramsjs is available under the MIT license. For more information, please refer to the LICENSE file.

.
Terabox Video Player