Skip to content

2.4.0

Choose a tag to compare

@Sempai-07 Sempai-07 released this 11 Nov 18:45
· 36 commits to v2 since this release

Telegramsjs@2.4.0

Fixes

The main fix that should have been addressed in the previous update, telegramsjs@2.3.0. This issue revolved around the inability to effectively upload files, videos, and photos from local storage, limiting usage to only links. With this update, you can now achieve this using three methods: simply specifying the file path, utilizing readFileSync, and also createReadStream.

Example

  • Simple path
bot.command("video", (ctx) => {
  ctx.sendVideo({ source: "./anime.mp4" });
});
  • readFileSync
bot.command("video", (ctx) => {
  const file = fs.readFileSync("./anime.mp4");
  ctx.sendVideo({ source: file });
});
  • createReadStream
bot.command("video", (ctx) => {
  const file = fs.createReadStream("./anime.mp4");
  ctx.sendVideo({ source: file });
});
  • Links
bot.command("video", (ctx) => {
  ctx.sendVideo("https://picsum.photos/200/300/?random");
});

And yes, to send a file from local storage, always specify { source: ... }.