-
Notifications
You must be signed in to change notification settings - Fork 7
81 implement guild template api #90
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
Changes from all commits
ea7091e
d46a8a4
2c31c93
b1ce2dc
588549b
978611b
1ae167a
8215dd3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. revert |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,6 @@ public DiscordRequestBuilder create() { | |
// entityMetadata (entity_metadata), scheduledEndTime are all required | ||
if (entityType.isPresent() && entityType.get() == 3) { | ||
if (entityMetadata.isEmpty() || scheduledEndTime.isEmpty()) { | ||
// TODO: replace with custom exceptions when implemented | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dont remove this todo |
||
throw new IllegalArgumentException( | ||
"When entityType is EXTERNAL, both entityMetadata and scheduledEndTime must" | ||
+ " be provided"); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.javadiscord.jdi.internal.api.guild_template; | ||
|
||
import com.javadiscord.jdi.internal.api.DiscordRequest; | ||
import com.javadiscord.jdi.internal.api.DiscordRequestBuilder; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
public record CreateGuildFromTemplateRequest( | ||
String templateCode, String name, Optional<String> icon) implements DiscordRequest { | ||
|
||
@Override | ||
public DiscordRequestBuilder create() { | ||
Map<String, String> body = new HashMap<>(); | ||
body.put("name", name); | ||
icon.ifPresent(it -> body.put("icon", it)); | ||
|
||
return new DiscordRequestBuilder() | ||
.post() | ||
.path("/guilds/templates/%s".formatted(templateCode)) | ||
.body(body); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.javadiscord.jdi.internal.api.guild_template; | ||
|
||
import com.javadiscord.jdi.internal.api.DiscordRequest; | ||
import com.javadiscord.jdi.internal.api.DiscordRequestBuilder; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
public record CreateGuildTemplateRequest(long guildId, String name, Optional<String> description) | ||
implements DiscordRequest { | ||
|
||
@Override | ||
public DiscordRequestBuilder create() { | ||
Map<String, String> body = new HashMap<>(); | ||
body.put("name", name); | ||
description.ifPresent(d -> body.put("description", d)); | ||
|
||
return new DiscordRequestBuilder() | ||
.post() | ||
.path("/guilds/%s/templates".formatted(guildId)) | ||
.body(body); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.javadiscord.jdi.internal.api.guild_template; | ||
|
||
import com.javadiscord.jdi.internal.api.DiscordRequest; | ||
import com.javadiscord.jdi.internal.api.DiscordRequestBuilder; | ||
|
||
public record DeleteGuildTemplateRequest(long guildId, String templateCode) | ||
implements DiscordRequest { | ||
|
||
@Override | ||
public DiscordRequestBuilder create() { | ||
return new DiscordRequestBuilder() | ||
.delete() | ||
.path("/guilds/%s/templates/%s".formatted(guildId, templateCode)); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.javadiscord.jdi.internal.api.guild_template; | ||
|
||
import com.javadiscord.jdi.internal.api.DiscordRequest; | ||
import com.javadiscord.jdi.internal.api.DiscordRequestBuilder; | ||
|
||
public record GetGuildTemplateRequest(String templateCode) implements DiscordRequest { | ||
|
||
@Override | ||
public DiscordRequestBuilder create() { | ||
return new DiscordRequestBuilder() | ||
.get() | ||
.path("/guilds/templates/%s".formatted(templateCode)); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.javadiscord.jdi.internal.api.guild_template; | ||
|
||
import com.javadiscord.jdi.internal.api.DiscordRequest; | ||
import com.javadiscord.jdi.internal.api.DiscordRequestBuilder; | ||
|
||
public record GetGuildTemplatesRequest(long guildId) implements DiscordRequest { | ||
|
||
@Override | ||
public DiscordRequestBuilder create() { | ||
return new DiscordRequestBuilder().get().path("/guilds/%s/templates".formatted(guildId)); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.javadiscord.jdi.internal.api.guild_template; | ||
|
||
import com.javadiscord.jdi.internal.api.DiscordRequest; | ||
import com.javadiscord.jdi.internal.api.DiscordRequestBuilder; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
public record ModifyGuildTemplateRequest( | ||
long guildId, String templateCode, Optional<String> name, Optional<String> description) | ||
implements DiscordRequest { | ||
|
||
@Override | ||
public DiscordRequestBuilder create() { | ||
Map<String, String> body = new HashMap<>(); | ||
name.ifPresent(n -> body.put("name", n)); | ||
description.ifPresent(desc -> body.put("description", desc)); | ||
|
||
return new DiscordRequestBuilder() | ||
.patch() | ||
.path("/guilds/%s/templates/%s".formatted(guildId, templateCode)) | ||
.body(body); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.javadiscord.jdi.internal.api.guild_template; | ||
|
||
import com.javadiscord.jdi.internal.api.DiscordRequest; | ||
import com.javadiscord.jdi.internal.api.DiscordRequestBuilder; | ||
|
||
public record SyncGuildTemplateRequest(long guildId, String templateCode) | ||
implements DiscordRequest { | ||
|
||
@Override | ||
public DiscordRequestBuilder create() { | ||
return new DiscordRequestBuilder() | ||
.put() | ||
.path("/guilds/%s/templates/%s".formatted(guildId, templateCode)); | ||
} | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. revert |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.javadiscord.jdi.core.models.guild; | ||
|
||
public enum AllowedMentionType { | ||
ROLES, | ||
USERS, | ||
EVERYONE | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. revert |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.javadiscord.jdi.core.models.guild; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import java.util.List; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public record AllowedMentions( | ||
@JsonProperty("parse") List<AllowedMentionType> mentionTypes, | ||
@JsonProperty("roles") List<Long> roles, | ||
@JsonProperty("users") List<Long> users, | ||
@JsonProperty("replied_user") boolean repliedUser) {} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. revert |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.javadiscord.jdi.core.models.guild; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.javadiscord.jdi.core.models.message.MessageAttachment; | ||
import com.javadiscord.jdi.core.models.message.embed.Embed; | ||
|
||
import java.util.List; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public record ForumMediaThreadMessageParam( | ||
@JsonProperty("content") String content, | ||
@JsonProperty("embeds") List<Embed> embeds, | ||
@JsonProperty("allowed_mentions") List<AllowedMentions> allowedMentions, | ||
@JsonProperty("components") List<Object> components, | ||
@JsonProperty("sticker_ids") List<Long> stickerIds, | ||
@JsonProperty("attachments") List<MessageAttachment> attachments, | ||
@JsonProperty("flags") int flags) {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,6 @@ | |
|
||
import java.time.OffsetDateTime; | ||
|
||
// TODO: finish implementation | ||
// https://discord.com/developers/docs/resources/guild#integration-object | ||
Comment on lines
-10
to
-11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is not done add it back |
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public record Integration( | ||
@JsonProperty("id") long id, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. revert |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.javadiscord.jdi.core.models.guild; | ||
|
||
public enum WidgetStyle { | ||
SHIELD, | ||
BANNER1, | ||
BANNER2, | ||
BANNER3, | ||
BANNER4, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert