Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.util.regex.Pattern;

/**
* Class which contains all actions a Discord client accepts.
* Class, which contains all actions a Discord client accepts.
* <p>
* This allows you to open DM's {@link Channels#DM_CHANNEL}, specific settings
* {@link Settings.App#VOICE} and much more.
Expand All @@ -23,25 +23,25 @@
* Example:
*
* <pre>
* <code>
* {@code
* event.reply("Open Discord's secret home page!")
* .addActionRow(DiscordClientAction.Guild.GUILD_HOME_CHANNEL.asLinkButton("Open home page!", event.getGuild().getId())
* </code>
* }
* </pre>
*
* To improve readability, one might want to use a static import like:
*
* <pre>
* <code>
* {@code
* event.reply(whoIsCommandOutput)
* .addActionRow(USER.asLinkButton("Open home page!", target.getId())
* </code>
* }
* </pre>
*/
public final class DiscordClientAction {

/**
* Contains some of the more general actions
* Contains some of the more general actions.
*/
public enum General {
;
Expand All @@ -65,7 +65,7 @@ public enum General {
}

/**
* Contains guild specific actions
* Contains actions related to guilds.
*/
public enum Guild {
;
Expand Down Expand Up @@ -94,7 +94,7 @@ public enum Guild {
}

/**
* Contains actions related to channels
* Contains actions related to channels.
*/
public enum Channels {
;
Expand All @@ -110,7 +110,7 @@ public enum Channels {
}

/**
* Contains actions related to the settings menu
* Contains actions related to the settings menu.
*/
/*
* The warning is about this inner class being too long, and that it should be external This
Expand All @@ -122,7 +122,7 @@ public enum Settings {
;

/**
* Contains all user settings
* Contains all user settings.
*/
public enum User {
;
Expand All @@ -140,7 +140,7 @@ public enum User {
}

/**
* Contains all payment settings
* Contains all payment settings.
*/
public enum Payment {
;
Expand All @@ -156,7 +156,7 @@ public enum Payment {
}

/**
* Contains all app settings
* Contains all app settings.
*/
public enum App {
;
Expand Down Expand Up @@ -195,7 +195,7 @@ public enum App {
}

/**
* Contains some of the more general settings
* Contains some of the more general settings.
*/
public enum General {
;
Expand All @@ -211,6 +211,9 @@ public enum General {
}
}

/**
* Contains actions related to game libraries.
*/
public enum Library {
;

Expand All @@ -227,15 +230,15 @@ public enum Library {
}

/**
* Pattern for the arguments, finds everything within brackets
* Pattern for the arguments, finds everything within brackets.
*/
public static final Pattern argumentPattern = Pattern.compile("\\{[^}]*}");

private final String url;
private final String rawUrl;

@Contract(pure = true)
private DiscordClientAction(final String url) {
this.url = url;
rawUrl = url;
}

/**
Expand All @@ -249,7 +252,7 @@ private DiscordClientAction(final String url) {
* @see #formatUrl(String...)
*/
public String getRawUrl() {
return url;
return rawUrl;
}

/**
Expand All @@ -260,7 +263,7 @@ public String getRawUrl() {
* @throws IllegalArgumentException When missing arguments
*/
public String formatUrl(final String... arguments) {
String localUrl = url;
String localUrl = rawUrl;

for (final String argument : arguments) {
localUrl = argumentPattern.matcher(localUrl).replaceFirst(argument);
Expand Down Expand Up @@ -288,6 +291,6 @@ public Button asLinkButton(final String label, final String... arguments) {

@Override
public String toString() {
return "DiscordClientAction{" + "url='" + url + '\'' + '}';
return "DiscordClientAction{" + "url='" + rawUrl + '\'' + '}';
}
}