Skip to content

Commit

Permalink
Merge #187 into 1.7.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Azn9 committed Oct 19, 2024
2 parents 094de2a + 01bb5ea commit 17331fe
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/main/java/discord4j/discordjson/json/MessageData.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ static ImmutableMessageData.Builder builder() {
@JsonProperty("message_reference")
Possible<MessageReferenceData> messageReference();

@JsonProperty("message_snapshots")
Possible<List<MessageSnapshotsData>> messageSnapshots();

Possible<Integer> flags();

@Deprecated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ static ImmutableMessageReferenceData.Builder builder() {
return ImmutableMessageReferenceData.builder();
}

default int type() {
return 0;
}

@JsonProperty("message_id")
Possible<Id> messageId();

Expand Down
18 changes: 18 additions & 0 deletions src/main/java/discord4j/discordjson/json/MessageSnapshotsData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package discord4j.discordjson.json;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.immutables.value.Value;

@Value.Immutable
@JsonSerialize(as = ImmutableMessageSnapshotsData.class)
@JsonDeserialize(as = ImmutableMessageSnapshotsData.class)
public interface MessageSnapshotsData {

static ImmutableMessageSnapshotsData.Builder builder() {
return ImmutableMessageSnapshotsData.builder();
}

PartialMessageData message();

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ static ImmutablePartialMessageData.Builder builder() {
return ImmutablePartialMessageData.builder();
}

Id id();

@JsonProperty("channel_id")
Id channelId();

@JsonProperty("guild_id")
Possible<Id> guildId();

Expand Down Expand Up @@ -86,4 +81,6 @@ static ImmutablePartialMessageData.Builder builder() {

Possible<MessageInteractionData> interaction();

Possible<List<ComponentData>> components();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package discord4j.discordjson.json;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import discord4j.discordjson.Id;
import org.immutables.value.Value;

@Value.Immutable
@JsonSerialize(as = ImmutablePartialMessageUpdateData.class)
@JsonDeserialize(as = ImmutablePartialMessageUpdateData.class)
public interface PartialMessageUpdateData extends PartialMessageData {

static ImmutablePartialMessageUpdateData.Builder builder() {
return ImmutablePartialMessageUpdateData.builder();
}

Id id();

@JsonProperty("channel_id")
Id channelId();

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.fasterxml.jackson.annotation.JsonUnwrapped;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import discord4j.discordjson.json.PartialMessageData;
import discord4j.discordjson.json.PartialMessageUpdateData;
import org.immutables.value.Value;

@Value.Immutable
Expand All @@ -16,5 +16,5 @@ static ImmutableMessageUpdate.Builder builder() {
}

@JsonUnwrapped
PartialMessageData message();
PartialMessageUpdateData message();
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ public void testCreateMessageResponse() throws IOException {
log.info("{}", res);
}

@Test
public void testCreateMessageWithForwardResponse() throws IOException {
MessageData res = read("/rest/CreateMessageWithForwardResponse.json", MessageData.class);
log.info("{}", res);
}

@Test
public void testMessageCopyingCollectionMethods() throws IOException {
MessageData res = read("/rest/CreateMessageResponse.json", MessageData.class);
Expand Down
55 changes: 55 additions & 0 deletions src/test/resources/rest/CreateMessageWithForwardResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"type": 0,
"content": "",
"mentions": [],
"mention_roles": [],
"attachments": [],
"embeds": [],
"timestamp": "2024-08-31T02:38:50.292000+00:00",
"edited_timestamp": null,
"flags": 16384,
"components": [],
"id": "1279269138510118913",
"channel_id": "1088465252804481025",
"author": {
"id": "719574575557509202",
"username": "DoggoFN",
"avatar": "ca9e2a158768a8e7e38861c16c575ffb",
"discriminator": "9425",
"public_flags": 0,
"flags": 0,
"bot": true,
"banner": null,
"accent_color": null,
"global_name": null,
"avatar_decoration_data": null,
"banner_color": null,
"clan": null
},
"pinned": false,
"mention_everyone": false,
"tts": false,
"message_reference": {
"type": 1,
"channel_id": "1088465252804481025",
"message_id": "1265424582311936060",
"guild_id": "405699020564987914"
},
"position": 0,
"message_snapshots": [
{
"message": {
"type": 0,
"content": "What is Lorem Ipsum?\nLorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",
"mentions": [],
"mention_roles": [],
"attachments": [],
"embeds": [],
"timestamp": "2024-07-23T21:45:30.875000+00:00",
"edited_timestamp": null,
"flags": 0,
"components": []
}
}
]
}

0 comments on commit 17331fe

Please sign in to comment.