how to make pagination in telegram bot with telegraf

186 views Asked by At

I'm trying to building telegram bot with telegraf but I couldn't make it.

This is what I tried

  import { Pagination } from "telegraf-pagination";

  bot.command("playlist", async (ctx) => {
  const data = await getAllProducts();
  console.log(data);
  const pagination = new Pagination({
    data: data,
    header: (currentPage, pageSize, total) =>
      `Nəsimi BR: 250* 299k\nPage ${currentPage} of ${total}`,
    format: (item, index) =>
      `${index + 1}. ${item.full_name} - ${item.company}`,
    pageSize: 5,
    rowSize: 5,
    onSelect: (item, index) => {
      // You can play the song or send a link to download it here
      ctx.reply(`You selected ${item.quantity} - ${item.price_usd}`);
    },
   });
  pagination.handleActions(bot);
  let text = await pagination.text();
  let keyboard = await pagination.keyboard();
   ctx.reply(text, keyboard);
});

it gives me nothing but enter image description here

Please show me example to make pagination with telegraf. thanks

0

There are 0 answers