Fix emoji font stack, change sonic font, fix job ID not being sent on jobs that don't require image input, some error handling fixes

This commit is contained in:
Essem 2022-09-23 17:24:28 -05:00
parent 4f66519aa7
commit 7a88f6b693
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C
14 changed files with 30 additions and 32 deletions

Binary file not shown.

View file

@ -25,7 +25,8 @@ class ImageCommand extends Command {
const imageParams = { const imageParams = {
cmd: this.constructor.command, cmd: this.constructor.command,
params: {} params: {},
id: (this.interaction ?? this.message).id
}; };
if (this.type === "application") await this.acknowledge(); if (this.type === "application") await this.acknowledge();
@ -49,7 +50,6 @@ class ImageCommand extends Command {
imageParams.params.type = image.type; imageParams.params.type = image.type;
imageParams.url = image.url; // technically not required but can be useful for text filtering imageParams.url = image.url; // technically not required but can be useful for text filtering
imageParams.name = image.name; imageParams.name = image.name;
imageParams.id = (this.interaction ?? this.message).id;
if (this.constructor.requiresGIF) imageParams.onlyGIF = true; if (this.constructor.requiresGIF) imageParams.onlyGIF = true;
} catch (e) { } catch (e) {
runningCommands.delete(this.author.id); runningCommands.delete(this.author.id);

View file

@ -163,7 +163,9 @@ export default async (client, message) => {
file: `Message: ${clean(err)}\n\nStack Trace: ${clean(err.stack)}`, file: `Message: ${clean(err)}\n\nStack Trace: ${clean(err.stack)}`,
name: "error.txt" name: "error.txt"
}]); }]);
} catch { /* silently ignore */ } } catch (e) {
_error(`While attempting to send the previous error message, another error occurred: ${e.stack || e}`);
}
} }
} }
}; };

View file

@ -33,10 +33,9 @@ Napi::Value Caption(const Napi::CallbackInfo &info) {
int nPages = vips_image_get_n_pages(in.get_image()); int nPages = vips_image_get_n_pages(in.get_image());
int textWidth = width - ((width / 25) * 2); int textWidth = width - ((width / 25) * 2);
string font_string = "Twemoji Color Emoji, " + string font_string = (font == "roboto" ? "Roboto Condensed" : font) + ", Twemoji Color Emoji " +
(font == "roboto" ? "Roboto Condensed" : font) + " " + (font != "impact" ? "bold" : "normal") +
(font != "impact" ? "bold" : "normal") + " " + " " + to_string(size);
to_string(size);
string captionText = "<span background=\"white\">" + caption + "</span>"; string captionText = "<span background=\"white\">" + caption + "</span>";

View file

@ -34,9 +34,8 @@ Napi::Value CaptionTwo(const Napi::CallbackInfo &info) {
int nPages = vips_image_get_n_pages(in.get_image()); int nPages = vips_image_get_n_pages(in.get_image());
int textWidth = width - ((width / 25) * 2); int textWidth = width - ((width / 25) * 2);
string font_string = "Twemoji Color Emoji, " + string font_string = (font == "roboto" ? "Roboto Condensed" : font) +
(font == "roboto" ? "Roboto Condensed" : font) + " " + ", Twemoji Color Emoji " + to_string(size);
to_string(size);
string captionText = "<span background=\"white\">" + caption + "</span>"; string captionText = "<span background=\"white\">" + caption + "</span>";

View file

@ -27,7 +27,7 @@ Napi::Value Homebrew(const Napi::CallbackInfo &info) {
VImage::option() VImage::option()
->set("rgba", true) ->set("rgba", true)
->set("align", VIPS_ALIGN_CENTRE) ->set("align", VIPS_ALIGN_CENTRE)
->set("font", "Twemoji Color Font, PF Square Sans Pro 96") ->set("font", "PF Square Sans Pro, Twemoji Color Font 96")
->set("fontfile", (basePath + "assets/fonts/twemoji.otf").c_str())); ->set("fontfile", (basePath + "assets/fonts/twemoji.otf").c_str()));
VImage out = bg.composite2(text, VIPS_BLEND_MODE_OVER, VImage out = bg.composite2(text, VIPS_BLEND_MODE_OVER,

View file

@ -36,10 +36,9 @@ Napi::Value Meme(const Napi::CallbackInfo &info) {
int rad = 1; int rad = 1;
vector<double> zeroVec = {0, 0, 0, 0}; vector<double> zeroVec = {0, 0, 0, 0};
string font_string = "Twemoji Color Font, " + string font_string = (font == "roboto" ? "Roboto Condensed" : font) + ", Twemoji Color Font " +
(font == "roboto" ? "Roboto Condensed" : font) + " " + (font != "impact" ? "bold" : "normal") +
(font != "impact" ? "bold" : "normal") + " " + " " + to_string(size);
to_string(size);
VImage mask = VImage::black(rad * 2 + 1, rad * 2 + 1) + 128; VImage mask = VImage::black(rad * 2 + 1, rad * 2 + 1) + 128;
mask.draw_circle({255}, rad, rad, rad, VImage::option()->set("fill", true)); mask.draw_circle({255}, rad, rad, rad, VImage::option()->set("fill", true));

View file

@ -35,7 +35,7 @@ Napi::Value Motivate(const Napi::CallbackInfo &info) {
int textWidth = width - ((width / 25) * 2); int textWidth = width - ((width / 25) * 2);
string font_string = string font_string =
"Twemoji Color Font, " + (font == "roboto" ? "Roboto Condensed" : font); (font == "roboto" ? "Roboto Condensed" : font) + ", Twemoji Color Font";
auto findResult = fontPaths.find(font); auto findResult = fontPaths.find(font);
if (findResult != fontPaths.end()) { if (findResult != fontPaths.end()) {

View file

@ -41,7 +41,7 @@ Napi::Value Reddit(const Napi::CallbackInfo &info) {
captionText.c_str(), captionText.c_str(),
VImage::option() VImage::option()
->set("rgba", true) ->set("rgba", true)
->set("font", "Twemoji Color Font, Roboto 62") ->set("font", "Roboto, Twemoji Color Font 62")
->set("fontfile", (basePath + "assets/fonts/twemoji.otf").c_str()) ->set("fontfile", (basePath + "assets/fonts/twemoji.otf").c_str())
->set("align", VIPS_ALIGN_LOW)); ->set("align", VIPS_ALIGN_LOW));

View file

@ -34,7 +34,7 @@ Napi::Value Snapchat(const Napi::CallbackInfo &info) {
int textWidth = width - ((width / 25) * 2); int textWidth = width - ((width / 25) * 2);
string font_string = string font_string =
"Twemoji Color Font, Helvetica Neue " + to_string(size); "Helvetica Neue, Twemoji Color Font " + to_string(size);
VImage textIn = VImage::text( VImage textIn = VImage::text(
".", VImage::option()->set( ".", VImage::option()->set(

View file

@ -18,12 +18,11 @@ Napi::Value Sonic(const Napi::CallbackInfo &info) {
VImage bg = VImage::new_from_file(assetPath.c_str()); VImage bg = VImage::new_from_file(assetPath.c_str());
VImage textImage = VImage textImage =
VImage::text( VImage::text(("<span foreground=\"white\">" + text + "</span>").c_str(),
("<span foreground=\"white\">" + text + "</span>").c_str(),
VImage::option() VImage::option()
->set("rgba", true) ->set("rgba", true)
->set("align", VIPS_ALIGN_CENTRE) ->set("align", VIPS_ALIGN_CENTRE)
->set("font", "Twemoji Color Font, Bitstream Vera Sans") ->set("font", "Verdana, Twemoji Color Font")
->set("fontfile", ->set("fontfile",
(basePath + "assets/fonts/twemoji.otf").c_str()) (basePath + "assets/fonts/twemoji.otf").c_str())
->set("width", 542) ->set("width", 542)

View file

@ -30,8 +30,7 @@ Napi::Value Uncanny(const Napi::CallbackInfo &info) {
VImage base = VImage::black(1280, 720, VImage::option()->set("bands", 3)); VImage base = VImage::black(1280, 720, VImage::option()->set("bands", 3));
string font_string = "Twemoji Color Font, " + string font_string = (font == "roboto" ? "Roboto Condensed" : font) + ", Twemoji Color Font " +
(font == "roboto" ? "Roboto Condensed" : font) + " " +
(font != "impact" ? "bold" : "normal") + " 72"; (font != "impact" ? "bold" : "normal") + " 72";
string captionText = "<span background=\"black\" foreground=\"white\">" + string captionText = "<span background=\"black\" foreground=\"white\">" +

View file

@ -32,7 +32,7 @@ Napi::Value Whisper(const Napi::CallbackInfo &info) {
int dividedWidth = width / 175; int dividedWidth = width / 175;
int rad = 1; int rad = 1;
string font_string = "Twemoji Color Font, Upright " + to_string(size); string font_string = "Upright, Twemoji Color Font " + to_string(size);
VImage mask; VImage mask;
if (dividedWidth >= 1) { if (dividedWidth >= 1) {

View file

@ -28,7 +28,8 @@ export function clean(text) {
.replaceAll("`", `\`${String.fromCharCode(8203)}`) .replaceAll("`", `\`${String.fromCharCode(8203)}`)
.replaceAll("@", `@${String.fromCharCode(8203)}`); .replaceAll("@", `@${String.fromCharCode(8203)}`);
const { parsed } = config(); let { parsed } = config();
if (!parsed) parsed = process.env;
const imageServers = JSON.parse(fs.readFileSync(new URL("../config/servers.json", import.meta.url), { encoding: "utf8" })).image; const imageServers = JSON.parse(fs.readFileSync(new URL("../config/servers.json", import.meta.url), { encoding: "utf8" })).image;
if (imageServers?.length !== 0) { if (imageServers?.length !== 0) {