fjodor-rybakov / discord-nestjs

👾 NestJS package for discord.js
MIT License
271 stars 49 forks source link

BotGateway `on` and `once` events doesn't work with `@nestjs/core` version `10.2.1` #1115

Closed Mnigos closed 1 year ago

Mnigos commented 1 year ago

Describe the bug Migrate Nestjs from 10.1.3 to 10.2.1

Expected behavior Should execute method with On or Once event decorators.

bot.gateway.ts

@Injectable()
export class BotGateway {
  private readonly logger = new Logger(BotGateway.name)

  constructor(@InjectDiscordClient() private readonly client: Client) {}

  @Once(Events.ClientReady)
  onClientReady(): void {
    console.log('e')
    this.logger.log(`Logged in as ${this.client.user.tag}!`)

    this.client.user.setPresence({
      activities: [
        {
          type: ActivityType.Listening,
          name: 'Rigtch Music',
        },
      ],
    })
  }

  @On(Events.GuildMemberAdd)
  onGuildMemberAdd(member): void {
    member.roles.add(
      member.guild.roles.cache.find(role => role.name === 'User')
    )
  }
}

Output on @nestjs/core version 10.2.1

⠋  TSC  Initializing type checker...[Nest] 33628  - 08/24/2023, 10:29:18 AM     LOG [NestFactory] Starting Nest application...
[Nest] 33628  - 08/24/2023, 10:29:18 AM     LOG [InstanceLoader] DiscoveryModule dependencies initialized +24ms
[Nest] 33628  - 08/24/2023, 10:29:18 AM     LOG [InstanceLoader] AppModule dependencies initialized +0ms
[Nest] 33628  - 08/24/2023, 10:29:18 AM     LOG [InstanceLoader] ConfigHostModule dependencies initialized +1ms
[Nest] 33628  - 08/24/2023, 10:29:18 AM     LOG [InstanceLoader] ConfigModule dependencies initialized +0ms
[Nest] 33628  - 08/24/2023, 10:29:18 AM     LOG [InstanceLoader] ConfigModule dependencies initialized +0ms
[Nest] 33628  - 08/24/2023, 10:29:18 AM     LOG [InstanceLoader] DiscordHostModule dependencies initialized +55ms
[Nest] 33628  - 08/24/2023, 10:29:18 AM     LOG [InstanceLoader] DiscordModule dependencies initialized +1ms
[Nest] 33628  - 08/24/2023, 10:29:18 AM     LOG [InstanceLoader] DiscordModule dependencies initialized +1ms
[Nest] 33628  - 08/24/2023, 10:29:18 AM     LOG [InstanceLoader] BotModule dependencies initialized +0ms
[Nest] 33628  - 08/24/2023, 10:29:18 AM     LOG [BotGateway] Subscribe to event(once): ready
[Nest] 33628  - 08/24/2023, 10:29:18 AM     LOG [BotGateway] Subscribe to event(on): guildMemberAdd
[Nest] 33628  - 08/24/2023, 10:29:18 AM     LOG [ApplyCommand] Subscribe to event(on): interactionCreate
[Nest] 33628  - 08/24/2023, 10:29:18 AM     LOG [ApplyCommand] Subscribe to event(on): interactionCreate
✔  TSC  Initializing type checker...
>  TSC  Found 0 issues.

Output on @nestjs/core version 10.1.3

[Nest] 34824  - 08/24/2023, 10:33:13 AM     LOG [NestFactory] Starting Nest application...
[Nest] 34824  - 08/24/2023, 10:33:13 AM     LOG [InstanceLoader] AppModule dependencies initialized +22ms
[Nest] 34824  - 08/24/2023, 10:33:13 AM     LOG [InstanceLoader] DiscoveryModule dependencies initialized +0ms
[Nest] 34824  - 08/24/2023, 10:33:13 AM     LOG [InstanceLoader] ConfigHostModule dependencies initialized +0ms
[Nest] 34824  - 08/24/2023, 10:33:13 AM     LOG [InstanceLoader] ConfigModule dependencies initialized +1ms
[Nest] 34824  - 08/24/2023, 10:33:13 AM     LOG [InstanceLoader] ConfigModule dependencies initialized +0ms
[Nest] 34824  - 08/24/2023, 10:33:13 AM     LOG [InstanceLoader] DiscordHostModule dependencies initialized +138ms
[Nest] 34824  - 08/24/2023, 10:33:13 AM     LOG [InstanceLoader] DiscordModule dependencies initialized +5ms
[Nest] 34824  - 08/24/2023, 10:33:13 AM     LOG [InstanceLoader] DiscordModule dependencies initialized +12ms
[Nest] 34824  - 08/24/2023, 10:33:13 AM     LOG [InstanceLoader] BotModule dependencies initialized +3ms
[Nest] 34824  - 08/24/2023, 10:33:13 AM     LOG [BotGateway] Subscribe to event(once): ready
[Nest] 34824  - 08/24/2023, 10:33:13 AM     LOG [BotGateway] Subscribe to event(on): guildMemberAdd
[Nest] 34824  - 08/24/2023, 10:33:13 AM     LOG [ApplyCommand] Subscribe to event(on): interactionCreate
[Nest] 34824  - 08/24/2023, 10:33:13 AM     LOG [ApplyCommand] Subscribe to event(on): interactionCreate
e
[Nest] 34824  - 08/24/2023, 10:33:14 AM     LOG [BotGateway] Logged in as Rigtch BOT#1018!
[Nest] 34824  - 08/24/2023, 10:33:15 AM     LOG [RegisterCommandService] All guild commands removed!
[Nest] 34824  - 08/24/2023, 10:33:15 AM     LOG [RegisterCommandService] All guild commands are registered!
fjodor-rybakov commented 1 year ago

I have updated the packages. Check again, please

Mnigos commented 1 year ago

not it works

ChristopherLMiller commented 1 year ago

Having this issue myself now, @discord-nestjs/core is 5.3.11 and on @nestjs/core of 10.2.8