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

feat(ThreadChannel): add fetchStarterMessage #6488

Merged
merged 3 commits into from Aug 24, 2021

Conversation

ImRodry
Copy link
Contributor

@ImRodry ImRodry commented Aug 21, 2021

Please describe the changes this PR makes and why it should be merged:
This PR adds a method to ThreadChannels called fetchStarterMessage that fetches the message that started the thread when this exists. I didn't find any better way to tell if a thread channel was started by a message or not so this just fetches the message with the same ID as the channel from the parent channel.

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
  • This PR changes the library's interface (methods or parameters added)

@ImRodry ImRodry changed the title feat(ThreadChannel): add starterMessage getter feat(ThreadChannel): add fetchStarterMessage Aug 21, 2021
@ImRodry
Copy link
Contributor Author

ImRodry commented Aug 21, 2021

After thinking about this for a while I opted by adding a method instead to be more in line with the direction the library has been going in recently. The getter was unreliable as it got the message from cache so this just simply fetches it.

@monbrey
Copy link
Member

monbrey commented Aug 21, 2021

When can this method return null? Wouldn't it throw if it can't fetch the message?

@ImRodry
Copy link
Contributor Author

ImRodry commented Aug 21, 2021

When can this method return null? Wouldn't it throw if it can't fetch the message?

Good point, will update

src/structures/ThreadChannel.js Outdated Show resolved Hide resolved
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
Copy link

@PuneetGopinath PuneetGopinath left a comment

Choose a reason for hiding this comment

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

I guess it has to be nullable as I tried deleting the starter message in a thread

@ImRodry
Copy link
Contributor Author

ImRodry commented Aug 23, 2021

@PuneetGopinath refer to monbrey’s comment: #6488 (comment)

@PuneetGopinath
Copy link

@PuneetGopinath refer to monbrey’s comment: #6488 (comment)

Ohk.

@monbrey
Copy link
Member

monbrey commented Aug 23, 2021

Ohk. Didn't notice, but the ?? null wasn't there.

Nor should it be there, because fetch will either resolve to a Message, or throw. Nullish-coallescing is not correct in any sense.

@iCrawl iCrawl merged commit 705c5a1 into discordjs:main Aug 24, 2021
@ImRodry ImRodry deleted the feat-starterMessage branch August 24, 2021 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants