question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Empty keyboard if the Extra.HTML().markup() is async

See original GitHub issue

Sync function:

Extra.HTML().markup((m) => {
	return m.inlineKeyboard([
		Markup.callbackButton('oke', 'lang1'),
	])
})

result:

Extra {
    parse_mode: 'HTML',
    reply_markup: { inline_keyboard: [ [Array] ] } }

Async function:

Extra.HTML().markup(async (m) => {
	return m.inlineKeyboard([
		Markup.callbackButton(`${(await Translate('oke'))}`, 'lang1'),
	])
})

result:

Extra {
    parse_mode: 'HTML',
    reply_markup: { } }

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ejnshteincommented, Aug 19, 2019

async always return Promise

0reactions
TorlanDeltacommented, Aug 19, 2019

Also have run into the same problem.

async function defaultBtns(m) {
  return [
   m.callbackButton("Give me money", "an_offer_we_cant_refuse") 
]
}

var _extra = Extra.markup( m=> m.inlineKeyboard(defaultBtns(m)))
console.log(_extra) // returns "Extra { reply_markup: {} } " 

Note that somehow the reply_markup was empty even though the function didn’t have any async calls in it. I spent like an hour trying to find an issue.

It is super logical that the function could be awaitable, I have no idea why it can’t do that. This is not intuitive and can potentially cause tons of misunderstanding.

I thought async-await was specifically implemented to provide a safe, readable and understandable way to wait for a completion of an asynchronous task, but this issue here kind of makes it incompatible?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pyrogram: The provided reply markup for the game is ...
But I met this error when I want to call this command /popspike to send my game to user, so I failed to...
Read more >
HTML: A good basis for accessibility - Learn web development
One key aspect of the accessibility of UI controls is that by default, browsers allow them to be manipulated by the keyboard. You...
Read more >
JSDoc: Widget: grid
A jQuery UI widget that implements a navigable data grid that supports selection and editing. It follows the DHTML Style Guide and WAI-ARIA ......
Read more >
JavaScript Tutorial: The Basics
As a result of the document.write() , the BODY section of this document ... extra white space (newlines, blanks, tabs) in an HTML...
Read more >
html5.h — Emscripten 3.1.26-git (dev) documentation
All event handlers are also automatically unregistered when the C exit() ... be an empty string if the browser or device doesn't know...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found