node-telegram-bot-api: setMyCommands not working properly
Bug Report
Expected Behavior
setMyCommands actual sets the commands of the bot
Actual Behavior
Not changes, but receiving a true
Steps to reproduce the Behavior
Using:
bot.setMyCommands([
{command: "prueba", description: "Esto es una prueba"}
], { scope: {type: "all_group_chats"}, language_code: "es"});
returns true, but no changes applied.
I guess it’s the way is sending the info, because it uses internally x-www-form-urlencoded and sending it as JSON works:
const fetch = require('node-fetch');
// ....
bot.request = async function (command, json) {
return fetch(`${bot.options.baseApiUrl}/bot${bot.token}/${command}`, {
method: 'post',
body: JSON.stringify(json),
headers: { 'Content-Type': 'application/json' }
});
}
bot.request('setMyCommands', {
commands: [{command: "prueba", description: "Esto es una prueba"}],
scope: {type: "all_group_chats"},
language_code: "es"
});
I think is the mix of sending the array of commands as a stringified JSON while sending everything else as x-www-form-urlencoded format.
Maybe you should use JSON in the entire library? It seems to be the native way of Telegram API to work.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 17
I’m sending this for who doesn’t understand; ( P.S: If
node-fetchnot work, try with2.6.7version. You can install with;npm install node-fetch@2.6.7, but don’t forget uninstall previous version with;npm uninstall node-fetch. ) Sorry for my poor English 😃I tried just now, working for me. (
setMyCommandswithnode-fetch)Trying to pass the parameters in JSON.stringify() format does not recognize it either, although the server returns true
I tried restarting the client to see if the changes were made with no results.