forked from Minecraft/javacord
32 lines
1.0 KiB
Java
32 lines
1.0 KiB
Java
package xyz.etztech.embed;
|
|
|
|
import xyz.etztech.Javacord;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
public class Image {
|
|
private final String url;
|
|
private final String proxyURL;
|
|
private final int height;
|
|
private final int width;
|
|
|
|
public Image(String url, String proxyURL, int height, int width) {
|
|
this.url = url;
|
|
this.proxyURL = proxyURL;
|
|
this.height = height;
|
|
this.width = width;
|
|
}
|
|
|
|
public String toJSON() {
|
|
StringBuilder builder = new StringBuilder("{");
|
|
List<String> json = new ArrayList<>();
|
|
if (!"".equals(url)) json.add(String.format("\"url\": \"%s\"", Javacord.escapeQuote(url)));
|
|
if (!"".equals(proxyURL)) json.add(String.format("\"proxy_url\": \"%s\"", Javacord.escapeQuote(proxyURL)));
|
|
if (height != 0) json.add(String.format("\"height\": \"%d\"", height));
|
|
if (width != 0) json.add(String.format("\"width\": \"%d\"", width));
|
|
builder.append(String.join(",", json));
|
|
return builder.append("}").toString();
|
|
}
|
|
}
|