Error if I run a command
Akuma95 opened this issue · 0 comments
Akuma95 commented
I use the following dependencies:
"dependencies": {
"dotenv": "^16.0.3",
"telegraf": "^4.12.2",
"telegraf-command-parts": "^1.0.3"
},
"devDependencies": {
"nodemon": "^2.0.22"
}
And use the following code:
const { Telegraf } = require('telegraf');
const commandParts = require('telegraf-command-parts');
require('dotenv').config();
const bot = new Telegraf(process.env.BOT_TOKEN)
bot.use(commandParts())
bot.start((ctx) => {
ctx.reply('Hello the bot is launched.')
})
bot.command('testCommand', (ctx) => {
console.log(ctx.state)
})
bot.launch()
If I try to launch this Bot and run the following command /testCommand Hello
I get the following error:
E:\Code\Bots\Telegram\Roulette-bot\node_modules\telegraf-command-parts\node_modules\telegraf\composer.js:178
const predicate = (ctx) => updateTypes.includes(ctx.updateType) || updateTypes.some((type) => ctx.updateSubTypes.includes(type))
^
TypeError: Cannot read properties of undefined (reading 'includes')
at E:\Code\Bots\Telegram\Roulette-bot\node_modules\telegraf-command-parts\node_modules\telegraf\composer.js:178:118
at Array.some (<anonymous>)
at predicate (E:\Code\Bots\Telegram\Roulette-bot\node_modules\telegraf-command-parts\node_modules\telegraf\composer.js:178:84)
at E:\Code\Bots\Telegram\Roulette-bot\node_modules\telegraf-command-parts\node_modules\telegraf\composer.js:154:51
at E:\Code\Bots\Telegram\Roulette-bot\node_modules\telegraf-command-parts\node_modules\telegraf\composer.js:142:43
at execute (E:\Code\Bots\Telegram\Roulette-bot\node_modules\telegraf\lib\composer.js:485:23)
at E:\Code\Bots\Telegram\Roulette-bot\node_modules\telegraf\lib\composer.js:486:27
at E:\Code\Bots\Telegram\Roulette-bot\node_modules\telegraf\lib\composer.js:161:31
at execute (E:\Code\Bots\Telegram\Roulette-bot\node_modules\telegraf\lib\composer.js:485:23)
at E:\Code\Bots\Telegram\Roulette-bot\node_modules\telegraf\lib\composer.js:474:20