Skip to content
This repository has been archived by the owner on Oct 21, 2023. It is now read-only.

Error if I run a command #8

Open
Akuma95 opened this issue Apr 14, 2023 · 0 comments
Open

Error if I run a command #8

Akuma95 opened this issue Apr 14, 2023 · 0 comments

Comments

@Akuma95
Copy link

Akuma95 commented Apr 14, 2023

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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant