Telegraf: TypeError: Markup.callbackButton is not a function

Created on 10 Nov 2019  路  3Comments  路  Source: telegraf/telegraf

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

  • Telegraf.js Version: 3.33.0
  • Node.js Version: 10.16.3
  • Operating System: Ubuntu

Expected Behavior

Create a inline keyboard

Current Behavior

Error: TypeError: Markup.callbackButton is not a function

Failure Information (for bugs)

Please help provide information about the failure if this is a bug. If it is not a bug, please remove the rest of this template.

Steps to Reproduce

Please provide detailed steps for reproducing the issue.
My code:

const env = require('../.env');
const Telegraf = require('telegraf');
const Extra = require('telegraf/extra');
const Markup = require('telegraf');

const bot = new Telegraf(env.token);

let contagem = 0;

const botoes = Extra.markup(Markup.inlineKeyboard([

  Markup.callbackButton('+1', 'add 1'),
  Markup.callbackButton('+10', 'add 10'),
  Markup.callbackButton('+100', 'add 100'),
  Markup.callbackButton('-1', 'sub 1'),
  Markup.callbackButton('-10', 'sub 10'),
  Markup.callbackButton('-100', 'sub 100'),
  Markup.callbackButton('Zerar', 'reset'),
  Markup.callbackButton('Resultado', 'result')

], { columns: 3 }));

bot.start(async ctx => {
  const nome = ctx.message.from.first_name;
  await ctx.reply(`Seja bem vindo, ${nome}`);
  await ctx.reply(`A contagem atual est谩 em ${contagem}`, botoes);
});


bot.action(/add (\d+)/gi, ctx => {
  contagem += parseInt(ctx.match[1]);
  ctx.reply(`A contagem atual est谩 em ${contagem}`, botoes);
});

bot.action(/sub (\d+)/gi, ctx => {
  contagem -= parseInt(ctx.match[1]);
  ctx.reply(`A vontagem atual est谩 em ${contagem}`, botoes);
});

bot.action('reset', ctx => {
  contagem = 0;
  ctx.reply(`A vontagem atual est谩 em ${contagem}`, botoes);
});

bot.action('result', ctx => {
  ctx.answerCbQuery(`A contagem atual est谩 em ${contagem}`);
});

bot.launch();

This feature "Markup.callbackButton" is not supported anymore?

Most helpful comment

Having the same isue. What was the solution @jwandekoken ?

//create inline keyboard
Markup.inlineKeyboard([
Markup.button.callback("馃憤", "like"),
Markup.button.callback("馃憥", "dislike"),
])

//catch callback
bot.action(/.+/, ctx => {
return ctx.answerCbQuery(Oh, ${ctx.match[0]}! Great choice);
});

All 3 comments

My bad. Just found what was missing. Sry about that. Admins, you guys can delete this stupid one. Sry.

Having the same isue. What was the solution @jwandekoken ?

Having the same isue. What was the solution @jwandekoken ?

//create inline keyboard
Markup.inlineKeyboard([
Markup.button.callback("馃憤", "like"),
Markup.button.callback("馃憥", "dislike"),
])

//catch callback
bot.action(/.+/, ctx => {
return ctx.answerCbQuery(Oh, ${ctx.match[0]}! Great choice);
});

Was this page helpful?
0 / 5 - 0 ratings

Related issues

expelliamus picture expelliamus  路  3Comments

Stephirio picture Stephirio  路  3Comments

bostrot picture bostrot  路  3Comments

bostrot picture bostrot  路  3Comments

supermomme picture supermomme  路  3Comments