diff --git a/pom.xml b/pom.xml index 90960fdd2c4b81ebf2b6aa9dc5cbcc87dcc61e2b..313bccca01159f48685eac86fa6683a8b83bc48f 100644 --- a/pom.xml +++ b/pom.xml @@ -56,19 +56,5 @@ <id>sonatype-snapshots</id> <url>https://oss.sonatype.org/content/repositories/snapshots/</url> </repository> - <repository> - <id>gitlab-maven</id> - <url>${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/maven</url> - </repository> </repositories> - <distributionManagement> - <repository> - <id>gitlab-maven</id> - <url>${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/maven</url> - </repository> - <snapshotRepository> - <id>gitlab-maven</id> - <url>${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/maven</url> - </snapshotRepository> - </distributionManagement> </project> diff --git a/src/main/java/com/stream_pi/discordaction/DiscordAction.java b/src/main/java/com/stream_pi/discordaction/DiscordAction.java index f83688cdf6d4042abdb1c81a1b19c103bcd85dc0..0c390b7cbe93c2ed936976076fc0707d87414d2d 100644 --- a/src/main/java/com/stream_pi/discordaction/DiscordAction.java +++ b/src/main/java/com/stream_pi/discordaction/DiscordAction.java @@ -8,9 +8,9 @@ import com.stream_pi.util.alert.StreamPiAlert; import com.stream_pi.util.alert.StreamPiAlertType; import com.stream_pi.util.version.Version; +import java.io.IOException; + public class DiscordAction extends NormalAction { - Button newWebhookButton; - Label currentWebhook; public DiscordAction() { setName("Discord"); @@ -25,10 +25,18 @@ public class DiscordAction extends NormalAction { @Override public void initProperties() throws MinorException { Property webhookURLProperty = new StringProperty("webhook_url"); - webhookURLProperty.setControlType(ControlType.STRING); webhookURLProperty.setDisplayName("Webhook URL"); - addClientProperties(webhookURLProperty); + Property contentProperty = new StringProperty("content"); + contentProperty.setDisplayName("Webhook Text Content"); + + Property usernameProperty = new StringProperty("username"); + usernameProperty.setDisplayName("Webhook Username"); + + Property titleProperty = new StringProperty("title"); + titleProperty.setDisplayName("Webhook Title"); + + addClientProperties(webhookURLProperty, contentProperty, usernameProperty, titleProperty); } @Override @@ -37,11 +45,27 @@ public class DiscordAction extends NormalAction { } public void sendMessage() throws MinorException { - Property webhookURL = getClientProperties().getSingleProperty("file_location"); + String webhookURL = getClientProperties().getSingleProperty("webhook_url").getStringValue(); + String webhookContent = getClientProperties().getSingleProperty("content").getStringValue(); + String webhookTitle = getClientProperties().getSingleProperty("title").getStringValue(); + String webhookUser = getClientProperties().getSingleProperty("username").getStringValue(); - if (webhookURL.getStringValue().isBlank()) { - throw new MinorException("No Discord Webhook URL specified!"); + if (webhookURL.isBlank()) { + throwMinorException("No Discord Webhook URL specified!"); } + DiscordWebhook webhook = new DiscordWebhook(webhookURL); + webhook.setAuthor(webhookUser); + + DiscordWebhook.EmbedObject embed = new DiscordWebhook.EmbedObject(); + embed.setTitle(webhookTitle); + embed.setDescription(webhookContent); + + try { + webhook.addEmbed(embed); + webhook.execute(); + } catch (IOException e) { + throwMinorException(e.getMessage()); + } } } diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst deleted file mode 100644 index f00f2ffccc255dbf8df399f3d27c1ccf27f35316..0000000000000000000000000000000000000000 --- a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ /dev/null @@ -1,3 +0,0 @@ -/home/pi/discordaction/src/main/java/com/stream_pi/discordaction/DiscordAction.java -/home/pi/discordaction/src/main/java/module-info.java -/home/pi/discordaction/src/main/java/com/stream_pi/discordaction/DiscordWebhook.java