+ Added help and error text

This commit is contained in:
Matthew Cech
2019-06-18 01:01:40 -07:00
parent 4946c6b4b8
commit 6f1881c65f
3 changed files with 32 additions and 8 deletions
+2 -1
View File
@@ -97,7 +97,8 @@ CharacterSearchOneCharacter=I found one character with that name! \n Owner: %s |
CharacterSearchInfo=Find a character with their name or Unique ID! `charactersearch name` or `charactersearch UniqueID` CharacterSearchInfo=Find a character with their name or Unique ID! `charactersearch name` or `charactersearch UniqueID`
[CommandColor] [CommandColor]
ColorInfo= ColorNotSearchable=Your color couldn't be parsed! Make sure it's in hex format. Try this! `!color 3F5D54`
ColorInfo=Looks up the provided hex color and outputs it as hex, rgb, hsl, hsv, xyz, and cmyk. Also attempts to name the color, and provies a sample of it! Usage example: `!color #365345` (the # can be omitted)
[CommandDoWork] [CommandDoWork]
DoWorkFinished=I finished with my work! :D DoWorkFinished=I finished with my work! :D
+10 -6
View File
@@ -4,6 +4,7 @@ import java.awt.Color;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
import java.text.DecimalFormat;
import core.Command; import core.Command;
import core.LocStrings; import core.LocStrings;
@@ -41,8 +42,8 @@ public class CommandColor extends Command
return; return;
} }
// Config // Set up the variables we'll be using based on the color, and get the color itself.
int sideLength = 150; int sideLength = 80; // It's 80x80 because as far as I know, that's the size of a thumbnail in discord.
int r = colorData.rgb.r; int r = colorData.rgb.r;
int g = colorData.rgb.g; int g = colorData.rgb.g;
int b = colorData.rgb.b; int b = colorData.rgb.b;
@@ -61,16 +62,19 @@ public class CommandColor extends Command
// Build the response // Build the response
KittyEmbed response = new KittyEmbed(); KittyEmbed response = new KittyEmbed();
String postEntry = ", ";
response.title = colorData.name.value + (colorData.name.exact_match_name ? "" : " (ish)"); response.title = colorData.name.value + (colorData.name.exact_match_name ? "" : " (ish)");
response.color = parsed; response.color = parsed;
response.descriptionText = "```"; response.descriptionText = "```";
response.descriptionText += "\nrgb: " + String.format("%1$03d", r) + " " + String.format("%1$03d", g) + " " + String.format("%1$03d", b);
response.descriptionText += "\nhsl: " + String.format("%1$03d", colorData.hsl.h) + " " + String.format("%1$02d", colorData.hsl.s) + "% " + String.format("%1$02d", colorData.hsl.l) + "%";
response.descriptionText += "\nhsv: " + String.format("%1$03d", colorData.hsv.h) + " " + String.format("%1$02d", colorData.hsv.s) + "% " + String.format("%1$02d", colorData.hsv.v) + "%";
response.descriptionText += "\n hex: #" + colorData.hex.clean; response.descriptionText += "\n hex: #" + colorData.hex.clean;
response.descriptionText += "\n rgb: " + String.format("%1$03d", r) + postEntry + String.format("%1$03d", g) + postEntry + String.format("%1$03d", b);
response.descriptionText += "\n hsl: " + String.format("%1$03d", colorData.hsl.h) + postEntry + String.format("%1$02d", colorData.hsl.s) + "%" + postEntry + String.format("%1$02d", colorData.hsl.l) + "%";
response.descriptionText += "\n hsv: " + String.format("%1$03d", colorData.hsv.h) + postEntry + String.format("%1$02d", colorData.hsv.s) + "%" + postEntry + String.format("%1$02d", colorData.hsv.v) + "%";
response.descriptionText += "\n xyz: " + String.format("%1$03d", colorData.XYZ.X) + postEntry + String.format("%1$03d", colorData.XYZ.Y) + postEntry + String.format("%1$03d", colorData.XYZ.Z);
response.descriptionText += "\ncmyk: " + String.format("%1$03d", colorData.cmyk.c) + postEntry + String.format("%1$03d", colorData.cmyk.m) + postEntry + String.format("%1$03d", colorData.cmyk.y) + postEntry + String.format("%1$03d", colorData.cmyk.k);
response.descriptionText += "```"; response.descriptionText += "```";
response.thumbnailURL = "attachment://" + tempFileName; response.thumbnailURL = "attachment://" + tempFileName;
response.footerText = "All percentages and values are rounded to the nearest whole number." + (colorData.name.exact_match_name ? "" : " " + colorData.name.value + " is actually " + colorData.name.closest_named_hex + "."); response.footerText = "All percentages and values are rounded to the nearest whole number!" + (colorData.name.exact_match_name ? "" : " '" + colorData.name.value + "' is actually " + colorData.name.closest_named_hex + ".");
// Send then delete the temp local files // Send then delete the temp local files
res.CallEmbed(response); res.CallEmbed(response);
+19
View File
@@ -10,6 +10,23 @@ public class NetworkTheColorAPI
{ {
private static final Gson jsonParser = new Gson(); private static final Gson jsonParser = new Gson();
public class tca_XYZ
{
// This is also known as the CIE 1931 colorspace.
// Value meanings: https://en.wikipedia.org/wiki/CIE_1931_color_space
public int X;
public int Y;
public int Z;
}
public class tca_cymk
{
public int c; // 0-100
public int m; // 0-100
public int y; // 0-100
public int k; // 0-100
}
public class tca_name public class tca_name
{ {
public String value; // The name of the color in english public String value; // The name of the color in english
@@ -50,6 +67,8 @@ public class NetworkTheColorAPI
public tca_rgb rgb; public tca_rgb rgb;
public tca_hsl hsl; public tca_hsl hsl;
public tca_hsv hsv; public tca_hsv hsv;
public tca_cymk cmyk;
public tca_XYZ XYZ;
} }
public ColorData LookupHex(String hex) public ColorData LookupHex(String hex)