我只是想执行我的机器人脚本,它抛出了这个错误 有人可以帮忙吗?
/home/user/Desktop/bot/node_modules/telegraf/lib/composer.js:540
Error('Invalid trigger');
^
Error: Invalid trigger
at /home/user/Desktop/bot/node_modules/telegraf/lib/composer.js:540:19
at Array.map (<anonymous>)
at normaliseTriggers (/home/user/Desktop/bot/node_modules/telegraf/lib/composer.js:538:21)
at Composer.command (/home/user/Desktop/bot/node_modules/telegraf/lib/composer.js:357:26)
at Telegraf.command (/home/user/Desktop/bot/node_modules/telegraf/lib/composer.js:48:34)
at /home/user/Desktop/bot/bot.js:382:9
at Array.forEach (<anonymous>)
at Object.<anonymous> (/home/user/Desktop/bot/bot.js:381:7)
at Module._compile (node:internal/modules/cjs/loader:1469:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
Node.js v20.18.1
我已经尝试重新安装node和telegraf但它不起作用
修复示例 以下是有效机器人命令的示例:
const { Telegraf } = require('telegraf');
const bot = new Telegraf('YOUR_BOT_TOKEN');
bot.command('start', (ctx) => {
ctx.reply('Welcome to the bot!');
});
bot.command('help', (ctx) => {
ctx.reply('How can I assist you?');
});
bot.launch();