4
4
5
5
import com .javadiscord .jdi .core .models .guild .EntityMetadata ;
6
6
import com .javadiscord .jdi .core .models .guild .PrivacyLevel ;
7
+ import com .javadiscord .jdi .core .models .scheduled_event .ScheduledEntityType ;
7
8
import com .javadiscord .jdi .internal .api .guild_scheduled_event .ModifyScheduledEventRequest ;
8
9
9
10
public class ModifyScheduledEventBuilder {
@@ -14,9 +15,9 @@ public class ModifyScheduledEventBuilder {
14
15
private Optional <String > name ;
15
16
private Optional <Integer > privacyLevel ;
16
17
private Optional <Long > scheduledStartTime ;
17
- private Optional <Long > scheduledEndTim ;
18
+ private Optional <Long > scheduledEndTime ;
18
19
private Optional <String > description ;
19
- private Optional <Integer > entityType ;
20
+ private Optional <ScheduledEntityType > entityType ;
20
21
private Optional <Integer > status ;
21
22
private Optional <String > image ;
22
23
@@ -28,7 +29,7 @@ public ModifyScheduledEventBuilder(long guildId, long scheduledEventId) {
28
29
this .name = Optional .empty ();
29
30
this .privacyLevel = Optional .empty ();
30
31
this .scheduledStartTime = Optional .empty ();
31
- this .scheduledEndTim = Optional .empty ();
32
+ this .scheduledEndTime = Optional .empty ();
32
33
this .description = Optional .empty ();
33
34
this .entityType = Optional .empty ();
34
35
this .status = Optional .empty ();
@@ -60,8 +61,8 @@ public ModifyScheduledEventBuilder scheduledStartTime(long scheduledStartTime) {
60
61
return this ;
61
62
}
62
63
63
- public ModifyScheduledEventBuilder scheduledEndTim (long scheduledEndTim ) {
64
- this .scheduledEndTim = Optional .of (scheduledEndTim );
64
+ public ModifyScheduledEventBuilder scheduledEndTime (long scheduledEndTim ) {
65
+ this .scheduledEndTime = Optional .of (scheduledEndTim );
65
66
return this ;
66
67
}
67
68
@@ -70,12 +71,12 @@ public ModifyScheduledEventBuilder description(String description) {
70
71
return this ;
71
72
}
72
73
73
- public ModifyScheduledEventBuilder entityType (Integer entityType ) {
74
+ public ModifyScheduledEventBuilder entityType (ScheduledEntityType entityType ) {
74
75
this .entityType = Optional .of (entityType );
75
76
return this ;
76
77
}
77
78
78
- public ModifyScheduledEventBuilder status (Integer status ) {
79
+ public ModifyScheduledEventBuilder status (int status ) {
79
80
this .status = Optional .of (status );
80
81
return this ;
81
82
}
@@ -86,6 +87,20 @@ public ModifyScheduledEventBuilder image(String image) {
86
87
}
87
88
88
89
public ModifyScheduledEventRequest build () {
90
+ if (entityType .isPresent () && entityType .get () == ScheduledEntityType .EXTERNAL ) {
91
+ if (entityMetadata .isEmpty () || scheduledEndTime .isEmpty ()) {
92
+ throw new IllegalArgumentException (
93
+ "When entityType is EXTERNAL, both entityMetadata and scheduledEndTime must"
94
+ + " be provided"
95
+ );
96
+ }
97
+ if (channelId .isPresent ()) {
98
+ throw new IllegalArgumentException (
99
+ "When entityType is EXTERNAL, channelId must not be provided"
100
+ );
101
+ }
102
+ }
103
+
89
104
return new ModifyScheduledEventRequest (
90
105
guildId ,
91
106
scheduledEventId ,
@@ -94,7 +109,7 @@ public ModifyScheduledEventRequest build() {
94
109
name ,
95
110
privacyLevel ,
96
111
scheduledStartTime ,
97
- scheduledEndTim ,
112
+ scheduledEndTime ,
98
113
description ,
99
114
entityType ,
100
115
status ,
0 commit comments