1

I tried to follow the API to set my bot commands, but it is not working. Here is the function:

function setMyCommands($cmds) {
  $cmds_encoded = json_encode($cmds);
  apiRequest("setMyCommands?commands=".$cmds_encoded);
}

This is the commands array:

$cmds_available = [
["command" => "a", "description" => "aaa"],
["command" => "b", "description" => "bbb"],
["command" => "c", "description" => "ccc"],
];

I call this function: setMyCommands($cmds_available);

The function was successfully called. But the commands are not updated. I used apiRequest("getMyCommands") to get my commands. They are the old ones.

I was adjusting here and there. It worked once before. But then it never worked again. I don't know if I might have messed up somewhere.

Any help appreciated!

Martin
  • 155
  • 10

1 Answers1

5

This code actually works!

I just found out that if I remain in the conversation with the bot, the commands list within the conversation (by starting typing "/") will not be updated. If I switch to another conversation, then switch back to the conversation with the bot, I can then see the updated commands list.

I saw occasionally the code worked, but most of time it did not (change the commands lists in the conversation by starting typing "\"). I was confused. It was because most of the time I just remain in the same conversation and started to check if the commands were updated or not. The actually commands were updated, but the commands list in the conversation did not (again, until I switch to another conversation and come back).

I've wasted so much time on it, until finally (and accidentally) found out the real issue. Hope it can help others who were confused like me.

Martin
  • 155
  • 10
  • Same happened to me, the solution was to go to another conversation and then come back, thank you. – Jorche May 08 '22 at 07:24
  • Any way to force this refresh? Similar issue - / command icon is not shown at the bottom of the screen (next to emoji) when bot is just added to a group, need to either restart Telegram or maybe switch groups like you suggested, will need to try that. – user1106591 Aug 30 '22 at 14:54