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

Implement access and retrieval of message_reference #1686

Merged
merged 19 commits into from
Jul 30, 2021
Merged

Implement access and retrieval of message_reference #1686

merged 19 commits into from
Jul 30, 2021

Conversation

arynxd
Copy link
Contributor

@arynxd arynxd commented Jun 21, 2021

Pull Request Etiquette

Changes

  • Internal code
  • Library interface (affecting end-user code)
  • Documentation
  • Other: _____

Closes Issue: NaN

Description

This PR adds support for retrieving referenced message in cases where discord does not provide one. It also adds a MessageReference class which wraps the message_reference value seen in a message's json. It also adds some getters for referenced message id

@MinnDevelopment MinnDevelopment added this to the v4.3.1 milestone Jun 29, 2021
@MinnDevelopment
Copy link
Member

Bump

@arynxd
Copy link
Contributor Author

arynxd commented Jul 8, 2021

Sorry about the late commit, i never received the notifications for this PR.

@MinnDevelopment MinnDevelopment added size: small status: documentation needed lacks documentation, either partially or completely type: feature labels Jul 8, 2021
Copy link
Member

@MinnDevelopment MinnDevelopment left a comment

Choose a reason for hiding this comment

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

Please add back the things for referenced message that you removed.

arynxd and others added 2 commits July 9, 2021 18:12
Co-authored-by: Florian Spieß <business@minnced.club>
arynxd and others added 2 commits July 9, 2021 20:08
Co-authored-by: Florian Spieß <business@minnced.club>
arynxd and others added 4 commits July 11, 2021 18:40
Co-authored-by: Florian Spieß <business@minnced.club>
Co-authored-by: Florian Spieß <business@minnced.club>
arynxd and others added 2 commits July 13, 2021 18:26
Co-authored-by: Florian Spieß <business@minnced.club>
@arynxd arynxd changed the title Add Message#retrieveReferencedMessage and getters for referenced message id Implement access and retrieval of message_reference Jul 13, 2021
@MinnDevelopment MinnDevelopment removed the status: documentation needed lacks documentation, either partially or completely label Jul 16, 2021
Copy link
Member

@MinnDevelopment MinnDevelopment left a comment

Choose a reason for hiding this comment

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

Almost there

src/main/java/net/dv8tion/jda/api/entities/Message.java Outdated Show resolved Hide resolved
? referencedMessage.getTextChannel()
: api.getTextChannelById(channelId);

if (tc == null)
Copy link
Member

Choose a reason for hiding this comment

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

To prepare for threads we should do:

if (guildId == 0L)
    this.channel = api.getPrivateChannelById(channelId);
else
    this.channel = (MessageChannel) api.getGuildChannelById(channelId);
this.guild = api.getGuildById(guild); // is null if guildId = 0 anyway

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I assume we just trust that the API gave us the ID for a message channel? Is it worth instaneof checking it

Copy link
Member

Choose a reason for hiding this comment

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

Well messages should only ever be inside message channels, if discord changes this that would break lots of things anyway.

arynxd and others added 2 commits July 30, 2021 14:15
Co-authored-by: Florian Spieß <business@minnced.club>
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

3 participants