remove useless lines
This commit is contained in:
parent
832361e4c7
commit
484c4dc7fd
1 changed files with 1 additions and 18 deletions
|
@ -68,7 +68,6 @@ public class DiscordWebhook {
|
||||||
|
|
||||||
for (EmbedObject embed : this.embeds) {
|
for (EmbedObject embed : this.embeds) {
|
||||||
JSONObject jsonEmbed = new JSONObject();
|
JSONObject jsonEmbed = new JSONObject();
|
||||||
|
|
||||||
jsonEmbed.put("title", embed.getTitle());
|
jsonEmbed.put("title", embed.getTitle());
|
||||||
jsonEmbed.put("description", embed.getDescription());
|
jsonEmbed.put("description", embed.getDescription());
|
||||||
jsonEmbed.put("url", embed.getUrl());
|
jsonEmbed.put("url", embed.getUrl());
|
||||||
|
@ -78,65 +77,49 @@ public class DiscordWebhook {
|
||||||
int rgb = color.getRed();
|
int rgb = color.getRed();
|
||||||
rgb = (rgb << 8) + color.getGreen();
|
rgb = (rgb << 8) + color.getGreen();
|
||||||
rgb = (rgb << 8) + color.getBlue();
|
rgb = (rgb << 8) + color.getBlue();
|
||||||
|
|
||||||
jsonEmbed.put("color", rgb);
|
jsonEmbed.put("color", rgb);
|
||||||
}
|
}
|
||||||
|
|
||||||
EmbedObject.Footer footer = embed.getFooter();
|
EmbedObject.Footer footer = embed.getFooter();
|
||||||
EmbedObject.Image image = embed.getImage();
|
EmbedObject.Image image = embed.getImage();
|
||||||
EmbedObject.Thumbnail thumbnail = embed.getThumbnail();
|
EmbedObject.Thumbnail thumbnail = embed.getThumbnail();
|
||||||
EmbedObject.Author author = embed.getAuthor();
|
EmbedObject.Author author = embed.getAuthor();
|
||||||
List<EmbedObject.Field> fields = embed.getFields();
|
List<EmbedObject.Field> fields = embed.getFields();
|
||||||
|
|
||||||
if (footer != null) {
|
if (footer != null) {
|
||||||
JSONObject jsonFooter = new JSONObject();
|
JSONObject jsonFooter = new JSONObject();
|
||||||
|
|
||||||
jsonFooter.put("text", footer.getText());
|
jsonFooter.put("text", footer.getText());
|
||||||
jsonFooter.put("icon_url", footer.getIconUrl());
|
jsonFooter.put("icon_url", footer.getIconUrl());
|
||||||
jsonEmbed.put("footer", jsonFooter);
|
jsonEmbed.put("footer", jsonFooter);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (image != null) {
|
if (image != null) {
|
||||||
JSONObject jsonImage = new JSONObject();
|
JSONObject jsonImage = new JSONObject();
|
||||||
|
|
||||||
jsonImage.put("url", image.getUrl());
|
jsonImage.put("url", image.getUrl());
|
||||||
jsonEmbed.put("image", jsonImage);
|
jsonEmbed.put("image", jsonImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (thumbnail != null) {
|
if (thumbnail != null) {
|
||||||
JSONObject jsonThumbnail = new JSONObject();
|
JSONObject jsonThumbnail = new JSONObject();
|
||||||
|
|
||||||
jsonThumbnail.put("url", thumbnail.getUrl());
|
jsonThumbnail.put("url", thumbnail.getUrl());
|
||||||
jsonEmbed.put("thumbnail", jsonThumbnail);
|
jsonEmbed.put("thumbnail", jsonThumbnail);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (author != null) {
|
if (author != null) {
|
||||||
JSONObject jsonAuthor = new JSONObject();
|
JSONObject jsonAuthor = new JSONObject();
|
||||||
|
|
||||||
jsonAuthor.put("name", author.getName());
|
jsonAuthor.put("name", author.getName());
|
||||||
jsonAuthor.put("url", author.getUrl());
|
jsonAuthor.put("url", author.getUrl());
|
||||||
jsonAuthor.put("icon_url", author.getIconUrl());
|
jsonAuthor.put("icon_url", author.getIconUrl());
|
||||||
jsonEmbed.put("author", jsonAuthor);
|
jsonEmbed.put("author", jsonAuthor);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<JSONObject> jsonFields = new ArrayList<>();
|
List<JSONObject> jsonFields = new ArrayList<>();
|
||||||
for (EmbedObject.Field field : fields) {
|
for (EmbedObject.Field field : fields) {
|
||||||
JSONObject jsonField = new JSONObject();
|
JSONObject jsonField = new JSONObject();
|
||||||
|
|
||||||
jsonField.put("name", field.getName());
|
jsonField.put("name", field.getName());
|
||||||
jsonField.put("value", field.getValue());
|
jsonField.put("value", field.getValue());
|
||||||
jsonField.put("inline", field.isInline());
|
jsonField.put("inline", field.isInline());
|
||||||
|
|
||||||
jsonFields.add(jsonField);
|
jsonFields.add(jsonField);
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonEmbed.put("fields", jsonFields.toArray());
|
jsonEmbed.put("fields", jsonFields.toArray());
|
||||||
embedObjects.add(jsonEmbed);
|
embedObjects.add(jsonEmbed);
|
||||||
}
|
}
|
||||||
|
|
||||||
json.put("embeds", embedObjects.toArray());
|
json.put("embeds", embedObjects.toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
URL url = new URL(this.url);
|
URL url = new URL(this.url);
|
||||||
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
||||||
connection.addRequestProperty("Content-Type", "application/json");
|
connection.addRequestProperty("Content-Type", "application/json");
|
||||||
|
@ -147,9 +130,9 @@ public class DiscordWebhook {
|
||||||
stream.write(json.toString().getBytes(StandardCharsets.UTF_16));
|
stream.write(json.toString().getBytes(StandardCharsets.UTF_16));
|
||||||
stream.flush();
|
stream.flush();
|
||||||
stream.close();
|
stream.close();
|
||||||
|
|
||||||
connection.getInputStream().close();
|
connection.getInputStream().close();
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
|
this.embeds.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class EmbedObject {
|
public static class EmbedObject {
|
||||||
|
|
Loading…
Reference in a new issue