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

types(GuildChannelManager): correct fetch return type #8549

Merged
merged 12 commits into from Sep 11, 2022

Conversation

RedGuy12
Copy link
Contributor

@RedGuy12 RedGuy12 commented Aug 23, 2022

Please describe the changes this PR makes and why it should be merged:

The documentation for /channels/{channelId} says:

Get a channel by ID. Returns a channel object. If the channel is a thread, a thread member object is included in the returned result.

This causes me to believe that this route, and GuildChannelManager#fetch, can fetch threads. I tested it and it works.

Note that the bulk fetch type doesn't need to be updated, as the documentation for that specifically mentions the exclusion of threads:

Returns a list of guild channel objects. Does not include threads.

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating

@vercel
Copy link

vercel bot commented Aug 23, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
discord-js ✅ Ready (Inspect) Visit Preview Sep 11, 2022 at 6:27PM (UTC)

Copy link
Member

@Jiralite Jiralite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation needs to be updated too:

/**
* Obtains one or more guild channels from Discord, or the channel cache if they're already available.
* @param {Snowflake} [id] The channel's id
* @param {BaseFetchOptions} [options] Additional options for this fetch
* @returns {Promise<?GuildChannel|Collection<Snowflake, GuildChannel>>}
* @example
* // Fetch all channels from the guild (excluding threads)
* message.guild.channels.fetch()
* .then(channels => console.log(`There are ${channels.size} channels.`))
* .catch(console.error);
* @example
* // Fetch a single channel
* message.guild.channels.fetch('222197033908436994')
* .then(channel => console.log(`The channel name is: ${channel.name}`))
* .catch(console.error);
*/
async fetch(id, { cache = true, force = false } = {}) {

GuildChannel doesn't include thread channels.

@vercel vercel bot temporarily deployed to Preview August 23, 2022 19:48 Inactive
@RedGuy12
Copy link
Contributor Author

The documentation needs to be updated too:

GuildChannel doesn't include thread channels.

Done.

@vercel vercel bot temporarily deployed to Preview August 23, 2022 20:25 Inactive
Copy link
Member

@Jiralite Jiralite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fetching multiple channels actually calls ChannelManager#_add() so it appears even channels in the collection may be null.

packages/discord.js/src/managers/GuildChannelManager.js Outdated Show resolved Hide resolved
packages/discord.js/typings/index.d.ts Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Sep 2, 2022

Codecov Report

Merging #8549 (4547153) into main (4ffdada) will increase coverage by 5.53%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #8549      +/-   ##
==========================================
+ Coverage   86.47%   92.01%   +5.53%     
==========================================
  Files          87       75      -12     
  Lines        8675     7160    -1515     
  Branches     1110     1023      -87     
==========================================
- Hits         7502     6588     -914     
+ Misses       1131      531     -600     
+ Partials       42       41       -1     
Flag Coverage Δ
builders 100.00% <100.00%> (ø)
collection 100.00% <ø> (ø)
proxy 74.10% <ø> (ø)
rest 91.99% <ø> (ø)
utilities 100.00% <ø> (ø)
voice 63.86% <ø> (ø)
ws ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
packages/collection/src/collection.ts 100.00% <ø> (ø)
packages/voice/src/DataStore.ts 98.14% <ø> (ø)
packages/voice/src/networking/Networking.ts 3.18% <ø> (ø)
packages/voice/src/networking/VoiceUDPSocket.ts 90.47% <ø> (ø)
packages/voice/src/networking/VoiceWebSocket.ts 0.00% <ø> (ø)
packages/voice/src/receive/SSRCMap.ts 86.20% <ø> (ø)
packages/voice/src/receive/SpeakingMap.ts 100.00% <ø> (ø)
packages/voice/src/util/Secretbox.ts 33.33% <ø> (ø)
...s/contextMenuCommands/ContextMenuCommandBuilder.ts 100.00% <100.00%> (ø)
.../interactions/slashCommands/SlashCommandBuilder.ts 100.00% <100.00%> (ø)
... and 12 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@vercel vercel bot temporarily deployed to Preview September 2, 2022 16:12 Inactive
@vercel vercel bot temporarily deployed to Preview September 2, 2022 16:36 Inactive
Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com>
Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com>
Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com>
Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com>
@RedGuy12 RedGuy12 requested review from almeidx and Jiralite and removed request for vladfrangu, iCrawl, kyranet, SpaceEEC, almeidx and Jiralite September 6, 2022 14:07
@Jiralite Jiralite requested review from vladfrangu, kyranet, iCrawl and SpaceEEC and removed request for almeidx September 6, 2022 14:15
@vercel vercel bot temporarily deployed to Preview September 11, 2022 18:27 Inactive
@kodiakhq kodiakhq bot merged commit 1d4cdee into discordjs:main Sep 11, 2022
@RedGuy12 RedGuy12 deleted the fetch-channels-threads branch September 12, 2022 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

6 participants