diff --git a/discord.gradle b/discord.gradle index 09b06d12..c4412f0d 100644 --- a/discord.gradle +++ b/discord.gradle @@ -40,17 +40,15 @@ task discordupload { "${getReleaseChangelog()}\n" if (content.length() > maxLength) { - def afterMessage = "[See more on GitHub](https://github.com/sekwah41/Advanced-Portals/releases)" + def afterMessage = "[See more on GitHub]()" - def truncatedContent = content.take(maxLength - afterMessage.length() - 1) + def truncatedContent = content.replaceAll(/(http[s]?:\/\/[^\s)]+)/, '<$1>').take(maxLength - afterMessage.length() - 1) def lastFullLine = truncatedContent.lastIndexOf("\n") - content = "${truncatedContent.take(lastFullLine)}\n" + - "${afterMessage}" + content = "${truncatedContent.take(lastFullLine)}\n" + content += afterMessage } - content = content.replaceAll(/(http[s]?:\/\/[^\s)]+)/, '<$1>') - builder.addTextBody("content", content, ContentType.create("text/plain", "UTF-8")) } @@ -63,7 +61,15 @@ task discordupload { response.getEntity() if(response.getStatusLine().getStatusCode() != 200) { - throw new RuntimeException("Failed to post build to discord") + println("Failed to post build to Discord.") + println("Status Code: " + response.getStatusLine().getStatusCode()) + println("Reason Phrase: " + response.getStatusLine().getReasonPhrase()) + + String responseContent = response.getEntity() != null ? + org.apache.http.util.EntityUtils.toString(response.getEntity()) : "No content" + println("Response Content: " + responseContent) + + throw new RuntimeException("Failed to post build to Discord") } println("Posted build")