nestjs-telegraf icon indicating copy to clipboard operation
nestjs-telegraf copied to clipboard

Not working properly in Nestjs 10.0.0 version

Open erosiners opened this issue 1 year ago • 5 comments

Not working properly in Nestjs 10.0.0 version

"dependencies": {
    "@nestjs/common": "^10.0.0",
    "@nestjs/core": "^10.0.0",
    "@nestjs/platform-express": "^10.0.0",
    "https-proxy-agent": "^7.0.1",
    "nestjs-telegraf": "^2.7.0",
    "reflect-metadata": "^0.1.13",
    "rxjs": "^7.8.1",
    "socks-proxy-agent": "^8.0.1",
    "telegraf": "^4.12.2"
  }
@Module({
  imports: [
    TelegrafModule.forRoot({
      token: token,
      include: [BotModule],
    }),
    UserModule,
    BotModule,
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule{}

@Module({
  providers: [BotUpdate, BotService],
})
export class BotModule {}

error message

Error: Nest can't resolve dependencies of the BotUpdate (?, BotService). Please make sure that the argument testBot at index [0] is available in the BotModule context.

Potential solutions:
- Is BotModule a valid NestJS module?
- If testBot is a provider, is it part of the current BotModule?
- If testBot is exported from a separate @Module, is that module imported within BotModule?
  @Module({
    imports: [ /* the Module containing testBot */ ]
  })

erosiners avatar Sep 01 '23 03:09 erosiners

Everything seems to be working properly on my end.

I think testBot should be inside the providers section of BotModule, such as to:

@Module({
  providers: [BotUpdate, BotService, testBot],
})
export class BotModule {}

I cannot tell what testBot is. Is it a service?

LoboAnimae avatar Sep 11 '23 05:09 LoboAnimae

any update on this? I faced the same problem

C0DDER avatar Sep 13 '23 18:09 C0DDER

Everything seems to be working properly on my end.

I think testBot should be inside the providers section of BotModule, such as to:

@Module({
  providers: [BotUpdate, BotService, testBot],
})
export class BotModule {}

I cannot tell what testBot is. Is it a service?

in my case it is the bot name specified in the @InjectBot() decorator

C0DDER avatar Sep 13 '23 18:09 C0DDER

@erosiners Have you solved this problem? I also encountered the same problem.

warriorBrian avatar Nov 28 '23 06:11 warriorBrian

@evilsprut When injecting the bot, I will be prompted to report an error. I think this is a mistake.

code:

constructor(
		private readonly configService: ConfigService,
		@InjectBot('health') private bot: Telegraf
	) {}

Error:

Please make sure that the argument "healthBot" at index [5] is available in the HealthModule context.

Potential solutions:
- Is HealthModule a valid NestJS module?
- If "healthBot" is a provider, is it part of the current HealthModule?
- If "healthBot" is exported from a separate @Module, is that module imported within HealthModule?
  @Module({
    imports: [ /* the Module containing "healthBot" */ ]
  })

And I don’t know where to solve this healthBot?

warriorBrian avatar Nov 28 '23 07:11 warriorBrian