test: skip setMyCommands when API mock lacks it

This commit is contained in:
Peter Steinberger
2026-01-12 22:08:53 +00:00
parent 5bc4971432
commit 59063a7c15

View File

@@ -932,18 +932,24 @@ export function createTelegramBot(opts: TelegramBotOptions) {
? listNativeCommandSpecsForConfig(cfg) ? listNativeCommandSpecsForConfig(cfg)
: []; : [];
if (nativeCommands.length > 0) { if (nativeCommands.length > 0) {
bot.api if (typeof bot.api.setMyCommands === "function") {
.setMyCommands( bot.api
nativeCommands.map((command) => ({ .setMyCommands(
command: command.name, nativeCommands.map((command) => ({
description: command.description, command: command.name,
})), description: command.description,
) })),
.catch((err) => { )
runtime.error?.( .catch((err) => {
danger(`telegram setMyCommands failed: ${String(err)}`), runtime.error?.(
); danger(`telegram setMyCommands failed: ${String(err)}`),
}); );
});
} else {
runtime.info?.(
"telegram: setMyCommands not available on api mock; skipping",
);
}
for (const command of nativeCommands) { for (const command of nativeCommands) {
bot.command(command.name, async (ctx) => { bot.command(command.name, async (ctx) => {