Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GuildChannelManager#fetch(id) returns array of all channels when channel is not found #10667

Closed
RappyTV opened this issue Dec 28, 2024 · 2 comments

Comments

@RappyTV
Copy link

RappyTV commented Dec 28, 2024

Which package is this bug report for?

discord.js

Issue description

  1. Fetch a guild with GuildManager#fetch
  2. Fetch channels of that guild with GuildChannelManager#fetch(id) with an invalid id and a catch clause
  3. You won't receive the value from the catch clause but an array of all channels

Code sample

async function fetchGuild() {
    return client.guilds.fetch(config.guildId);
}
async function doSomethingWithChannel(): void {
    const channel = await (await fetchGuild()).channels.fetch('channelID', { force: true }).catch(() => null);
    if(!channel || !channel.isSendable()) return; // Code fails here because channel is an array of all channels and not null
    console.log(channel.id);
}

Versions

  • discord.js v14.16.3
  • bun 1.1.42
  • typescript ^5.0.0

Issue priority

Medium (should be fixed soon)

Which partials do you have configured?

No Partials

Which gateway intents are you subscribing to?

Guilds, GuildMembers, GuildMessages

I have tested this issue on a development release

No response

@RappyTV RappyTV changed the title GuildChannelManager#fetch(id) does not return GuildBasedChannel but array of all channels GuildChannelManager#fetch(id) returns array of all channels when channel is not found Dec 28, 2024
@Qjuh
Copy link
Contributor

Qjuh commented Dec 28, 2024

I can‘t reproduce that. Did you actually provide the id hardcoded like your example suggests? Or could it be that you actually passed undefined as id there, because you passed a variable that didn’t exist? In which case this would be expected behavior.

@RappyTV
Copy link
Author

RappyTV commented Dec 29, 2024

oh yea sorry I was using an environment variable which I later corrected. my bad

@RappyTV RappyTV closed this as not planned Won't fix, can't repro, duplicate, stale Dec 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants