2020-07-30 21:25:24 +00:00
|
|
|
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<>();
|
2021-06-11 02:50:39 +00:00
|
|
|
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));
|
2020-07-30 21:25:24 +00:00
|
|
|
builder.append(String.join(",", json));
|
|
|
|
return builder.append("}").toString();
|
|
|
|
}
|
|
|
|
}
|