javacord/src/main/java/xyz/etztech/embed/Footer.java

36 lines
1.1 KiB
Java

package xyz.etztech.embed;
import xyz.etztech.Javacord;
import java.util.ArrayList;
import java.util.List;
public class Footer {
private final String text;
private final String iconURL;
private final String proxyIconURL;
public Footer(String text) {
this.text = text;
this.iconURL = "";
this.proxyIconURL = "";
}
public Footer(String text, String iconURL, String proxyIconURL) {
this.text = text;
this.iconURL = iconURL;
this.proxyIconURL = proxyIconURL;
}
public String toJSON() {
StringBuilder builder = new StringBuilder("{");
builder.append(String.format("\"text\":\"%s\"", Javacord.escapeQuote(text)));
List<String> json = new ArrayList<>();
if (!"".equals(iconURL)) json.add(String.format("\"icon_url\":\"%s\"", Javacord.escapeQuote(iconURL)));
if (!"".equals(proxyIconURL)) json.add(String.format("\"proxy_icon_url\":\"%s\"", Javacord.escapeQuote(proxyIconURL)));
builder.append(String.join(",", json));
return builder.append("}").toString();
}
}