266 lines
6.3 KiB
Java
266 lines
6.3 KiB
Java
package com.leohabrom.discord;
|
|
|
|
import com.leohabrom.discord.DiscordActivity;
|
|
|
|
import java.net.URI;
|
|
|
|
public class DiscordActivityBuilder {
|
|
public enum Type {
|
|
PLAYING(0),
|
|
WATCHING(3),
|
|
LISTENING(2),
|
|
COMPETING(4);
|
|
|
|
private final int value;
|
|
|
|
Type(int value) {
|
|
this.value = value;
|
|
}
|
|
|
|
public int getValue() {
|
|
return value;
|
|
}
|
|
}
|
|
|
|
public enum Status {
|
|
NAME(0),
|
|
STATE(1),
|
|
DETAIL(2);
|
|
|
|
private final int value;
|
|
|
|
Status(int value) {
|
|
this.value = value;
|
|
}
|
|
|
|
public int getValue() {
|
|
return value;
|
|
}
|
|
}
|
|
|
|
public enum Platform {
|
|
ANDROID(0),
|
|
DESKTOP(1),
|
|
EMBEDDED(2),
|
|
IOS(3),
|
|
PS4(4),
|
|
PS5(5),
|
|
SAMSUNG(6),
|
|
XBOX(7);
|
|
|
|
private final int value;
|
|
|
|
Platform(int value) {
|
|
this.value = value;
|
|
}
|
|
|
|
public int getValue() {
|
|
return value;
|
|
}
|
|
}
|
|
|
|
public enum Privacy {
|
|
PRIVATE(0),
|
|
PUBLIC(1);
|
|
|
|
private final int value;
|
|
|
|
Privacy(int value) {
|
|
this.value = value;
|
|
}
|
|
|
|
public int getValue() {
|
|
return value;
|
|
}
|
|
}
|
|
|
|
public enum Button {
|
|
FIRST(0),
|
|
SECOND(1);
|
|
|
|
private final int value;
|
|
|
|
Button(int value) {
|
|
this.value = value;
|
|
}
|
|
|
|
public int getValue() {
|
|
return value;
|
|
}
|
|
}
|
|
|
|
private final DiscordActivity activity;
|
|
|
|
public DiscordActivityBuilder() {
|
|
activity = new DiscordActivity();
|
|
}
|
|
|
|
public DiscordActivityBuilder details(String details) {
|
|
activity.details = details;
|
|
return this;
|
|
}
|
|
|
|
public DiscordActivityBuilder details(String details, URI url) {
|
|
activity.details = details;
|
|
activity.detailsUrl = url.toString();
|
|
return this;
|
|
}
|
|
|
|
public DiscordActivityBuilder name(String name) {
|
|
activity.name = name;
|
|
return this;
|
|
}
|
|
|
|
public DiscordActivityBuilder state(String state) {
|
|
activity.state = state;
|
|
return this;
|
|
}
|
|
|
|
public DiscordActivityBuilder state(String state, URI url) {
|
|
activity.state = state;
|
|
activity.stateUrl = url.toString();
|
|
return this;
|
|
}
|
|
|
|
public DiscordActivityBuilder type(Type type) {
|
|
activity.type = type.getValue();
|
|
return this;
|
|
}
|
|
|
|
public DiscordActivityBuilder statusDisplay(Status status) {
|
|
activity.status = status.getValue();
|
|
return this;
|
|
}
|
|
|
|
public DiscordActivityBuilder platform(Platform platform) {
|
|
activity.platform = platform.getValue();
|
|
return this;
|
|
}
|
|
|
|
public DiscordActivityBuilder largeImage(String idOrUrl) {
|
|
activity.largeImage = idOrUrl;
|
|
return this;
|
|
}
|
|
|
|
public DiscordActivityBuilder largeImage(String idOrUrl, String text) {
|
|
activity.largeImage = idOrUrl;
|
|
activity.largeText = text;
|
|
return this;
|
|
}
|
|
|
|
public DiscordActivityBuilder largeImage(String idOrUrl, URI url) {
|
|
activity.largeImage = idOrUrl;
|
|
activity.largeUrl = url.toString();
|
|
return this;
|
|
}
|
|
|
|
public DiscordActivityBuilder largeImage(String idOrUrl, String text, URI url) {
|
|
activity.largeImage = idOrUrl;
|
|
activity.largeText = text;
|
|
activity.largeUrl = url.toString();
|
|
return this;
|
|
}
|
|
|
|
public DiscordActivityBuilder smallImage(String idOrUrl) {
|
|
activity.smallImage = idOrUrl;
|
|
return this;
|
|
}
|
|
|
|
public DiscordActivityBuilder smallImage(String idOrUrl, String text) {
|
|
activity.smallImage = idOrUrl;
|
|
activity.smallText = text;
|
|
return this;
|
|
}
|
|
|
|
public DiscordActivityBuilder smallImage(String idOrUrl, URI url) {
|
|
activity.smallImage = idOrUrl;
|
|
activity.smallUrl = url.toString();
|
|
return this;
|
|
}
|
|
|
|
public DiscordActivityBuilder smallImage(String idOrUrl, String text, URI url) {
|
|
activity.smallImage = idOrUrl;
|
|
activity.smallText = text;
|
|
activity.smallUrl = url.toString();
|
|
return this;
|
|
}
|
|
|
|
public DiscordActivityBuilder inviteCoverImage(String idOrUrl) {
|
|
activity.inviteCoverImage = idOrUrl;
|
|
return this;
|
|
}
|
|
|
|
public DiscordActivityBuilder party(String id) {
|
|
activity.partyId = id;
|
|
return this;
|
|
}
|
|
|
|
|
|
public DiscordActivityBuilder party(String id, int currentSize) {
|
|
activity.partyId = id;
|
|
activity.partyCurrentSize = currentSize;
|
|
return this;
|
|
}
|
|
|
|
|
|
public DiscordActivityBuilder party(String id, int currentSize, Privacy privacy) {
|
|
activity.partyId = id;
|
|
activity.partyCurrentSize = currentSize;
|
|
activity.partyPrivacy = privacy.getValue();
|
|
return this;
|
|
}
|
|
|
|
public DiscordActivityBuilder party(String id, Privacy privacy) {
|
|
activity.partyId = id;
|
|
activity.partyPrivacy = privacy.getValue();
|
|
return this;
|
|
}
|
|
|
|
public DiscordActivityBuilder party(String id, int currentSize, int maxSize, Privacy privacy) {
|
|
activity.partyId = id;
|
|
activity.partyCurrentSize = currentSize;
|
|
activity.partyMaxSize = maxSize;
|
|
activity.partyPrivacy = privacy.getValue();
|
|
return this;
|
|
}
|
|
|
|
public DiscordActivityBuilder time(long startTime) {
|
|
activity.startTimestamp = startTime;
|
|
return this;
|
|
}
|
|
|
|
public DiscordActivityBuilder endTime(long endTime) {
|
|
activity.startTimestamp = endTime;
|
|
return this;
|
|
}
|
|
|
|
public DiscordActivityBuilder time(long startTime, long endTime) {
|
|
activity.startTimestamp = startTime;
|
|
activity.endTimestamp = endTime;
|
|
return this;
|
|
}
|
|
|
|
public DiscordActivityBuilder button(Button id, String label, URI url) {
|
|
switch (id) {
|
|
case FIRST -> {
|
|
activity.firstButtonLabel = label;
|
|
activity.firstButtonUrl = url.toString();
|
|
}
|
|
case SECOND -> {
|
|
activity.secondButtonLabel = label;
|
|
activity.secondButtonUrl = url.toString();
|
|
}
|
|
}
|
|
return this;
|
|
}
|
|
|
|
public DiscordActivityBuilder joinSecret(String secret) {
|
|
activity.joinSecret = secret;
|
|
return this;
|
|
}
|
|
|
|
public DiscordActivity build() {
|
|
return activity;
|
|
}
|
|
}
|