diff --git a/src/commands/CommandColor.java b/src/commands/CommandColor.java index 5bdd9e9..a74d3a4 100644 --- a/src/commands/CommandColor.java +++ b/src/commands/CommandColor.java @@ -46,18 +46,25 @@ public class CommandColor extends Command graphics.setColor(parsed); graphics.fillRect(0, 0, sideLength, sideLength); graphics.dispose(); + GlobalLog.Log("2"); + String tempFileName = ImageUtils.writeTempImageData(img, ".png"); File file = new File(tempFileName); + GlobalLog.Log("3"); + KittyEmbed response = new KittyEmbed(); response.title = "Color Name"; response.color = parsed; response.descriptionText = "`rgba` test\n`hex` test\n`hsv` test"; response.thumbnailURL = "attachment://" + tempFileName; + GlobalLog.Log("4"); + res.CallEmbed(response); ImageUtils.BlockingFileDelete(file); + GlobalLog.Log("5"); }; diff --git a/src/dataStructures/Response.java b/src/dataStructures/Response.java index 5ce4c3b..ab0fc03 100644 --- a/src/dataStructures/Response.java +++ b/src/dataStructures/Response.java @@ -35,9 +35,15 @@ public class Response EmbedBuilder embed = new EmbedBuilder(); if(embedInfo.title != null && !embedInfo.title.isEmpty()) + { embed.setTitle(embedInfo.title); + } else + { + // We have to set the title to at least something that's not empty. + // By defualt, this creates nothing really visible. embed.setTitle(" "); + } if(embedInfo.color != null) embed.setColor(embedInfo.color); @@ -61,6 +67,7 @@ public class Response String thumbPath = embedInfo.thumbnailURL; String thumbName = thumbPath.replace("attachment://", ""); + // Build the message and send if the file is valid MessageBuilder message = new MessageBuilder(); embed.setThumbnail(thumbPath); message.setEmbed(embed.build()); diff --git a/src/utils/ImageUtils.java b/src/utils/ImageUtils.java index 23dcbdc..7d8822a 100644 --- a/src/utils/ImageUtils.java +++ b/src/utils/ImageUtils.java @@ -22,13 +22,26 @@ public class ImageUtils String name = null; synchronized(uniqueID) { - name = "imagetempwriterutil_" + (uniqueID++) + extension; + String end = extension; + if(!extension.contains(".")) + { + end = "." + extension; + } + + name = "imagetempwriterutil_" + (uniqueID++) + end; } try { File outputfile = new File(name); - ImageIO.write(data, extension, outputfile); + extension = extension.replace(".", ""); + + boolean didWrite = ImageIO.write(data, extension, outputfile); + if(!didWrite) + { + GlobalLog.Error(LogFilter.Util, "Could not identify the writer for extension type '" + extension + "' - Did you accidentally include a period or other punctuation?"); + return null; + } return name; } diff --git a/test.png b/test.png deleted file mode 100644 index 3e54667..0000000 Binary files a/test.png and /dev/null differ