necordjs / necord

🤖 A module for creating Discord bots using NestJS, based on Discord.js
https://necord.org
MIT License
368 stars 13 forks source link

User and Emoji Providers is null or empty #1120

Closed NedcloarBR closed 7 months ago

NedcloarBR commented 8 months ago

Issue description

So it's embarrassing to say this, but the PR https://github.com/necordjs/necord/pull/1117 I did yesterday has a bug... I've been trying to find some way to fix this for 3h but I haven't found it I did the PR on emotion and forgot to test before opening it 😥 In short, the client.user only stores the client user after it emits the Ready event, and the same goes for client.emojis , but seeing by this logic the GuildProvider(client.guilds) was not supposed to work but works image image

Code sample

import { BaseGuildEmojiManager, Client, ClientUser } from "discord.js";
import { Module, OnApplicationBootstrap } from "@nestjs/common";

@Module({})
export class IssueModule implements OnApplicationBootstrap {
  public constructor(
    private readonly emojis: BaseGuildEmojiManager,
    private readonly user: ClientUser,
    private readonly client: Client
  ) {}

  public onApplicationBootstrap () {
    console.log(this.client.user)
    console.log(this.user)
    console.log(this.emojis.cache)
    console.log(this.client.emojis.cache)
  }
}

discord.js version

14.14.1

nest.js version

10.3.3

Node.js version

NodeJS v20.6.1 | TypeScript v5.4.2

Operating system

Linux 5.15 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)

Priority this issue should have

Medium (should be fixed soon)

Which partials do you have configured?

USER, CHANNEL, GUILD_MEMBER, MESSAGE, REACTION

Which gateway intents are you subscribing to?

GUILDS, GUILD_MEMBERS, GUILD_BANS, GUILD_EMOJIS_AND_STICKERS, GUILD_INTEGRATIONS, GUILD_WEBHOOKS, GUILD_INVITES, GUILD_VOICE_STATES, GUILD_PRESENCES, GUILD_MESSAGES, GUILD_MESSAGE_REACTIONS, GUILD_MESSAGE_TYPING, DIRECT_MESSAGES, DIRECT_MESSAGE_REACTIONS, DIRECT_MESSAGE_TYPING

SocketSomeone commented 7 months ago

Ohhh... This was the reason why i dont added them, also client application not injecting o_o

SocketSomeone commented 7 months ago

I will try to find solution, maybe it`ll reverted

NedcloarBR commented 7 months ago

Is there a way to delay the injection of these providers? for them to only be injected after the client login

SocketSomeone commented 7 months ago

Is there a way to delay the injection of these providers? for them to only be injected after the client login

No way, tried lazy module loader, but that not native for library usage

github-actions[bot] commented 4 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.