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 = {
cmd: this.constructor.command,
params: {}
params: {},
id: (this.interaction ?? this.message).id
};
if (this.type === "application") await this.acknowledge();
@ -49,7 +50,6 @@ class ImageCommand extends Command {
imageParams.params.type = image.type;
imageParams.url = image.url; // technically not required but can be useful for text filtering
imageParams.name = image.name;
imageParams.id = (this.interaction ?? this.message).id;
if (this.constructor.requiresGIF) imageParams.onlyGIF = true;
} catch (e) {
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)}`,
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 textWidth = width - ((width / 25) * 2);
string font_string = "Twemoji Color Emoji, " +
(font == "roboto" ? "Roboto Condensed" : font) + " " +
(font != "impact" ? "bold" : "normal") + " " +
to_string(size);
string font_string = (font == "roboto" ? "Roboto Condensed" : font) + ", Twemoji Color Emoji " +
(font != "impact" ? "bold" : "normal") +
" " + to_string(size);
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 textWidth = width - ((width / 25) * 2);
string font_string = "Twemoji Color Emoji, " +
(font == "roboto" ? "Roboto Condensed" : font) + " " +
to_string(size);
string font_string = (font == "roboto" ? "Roboto Condensed" : font) +
", Twemoji Color Emoji " + to_string(size);
string captionText = "<span background=\"white\">" + caption + "</span>";

View file

@ -27,7 +27,7 @@ Napi::Value Homebrew(const Napi::CallbackInfo &info) {
VImage::option()
->set("rgba", true)
->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()));
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;
vector<double> zeroVec = {0, 0, 0, 0};
string font_string = "Twemoji Color Font, " +
(font == "roboto" ? "Roboto Condensed" : font) + " " +
(font != "impact" ? "bold" : "normal") + " " +
to_string(size);
string font_string = (font == "roboto" ? "Roboto Condensed" : font) + ", Twemoji Color Font " +
(font != "impact" ? "bold" : "normal") +
" " + to_string(size);
VImage mask = VImage::black(rad * 2 + 1, rad * 2 + 1) + 128;
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);
string font_string =
"Twemoji Color Font, " + (font == "roboto" ? "Roboto Condensed" : font);
(font == "roboto" ? "Roboto Condensed" : font) + ", Twemoji Color Font";
auto findResult = fontPaths.find(font);
if (findResult != fontPaths.end()) {

View file

@ -41,7 +41,7 @@ Napi::Value Reddit(const Napi::CallbackInfo &info) {
captionText.c_str(),
VImage::option()
->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("align", VIPS_ALIGN_LOW));

View file

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

View file

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

View file

@ -30,8 +30,7 @@ Napi::Value Uncanny(const Napi::CallbackInfo &info) {
VImage base = VImage::black(1280, 720, VImage::option()->set("bands", 3));
string font_string = "Twemoji Color Font, " +
(font == "roboto" ? "Roboto Condensed" : font) + " " +
string font_string = (font == "roboto" ? "Roboto Condensed" : font) + ", Twemoji Color Font " +
(font != "impact" ? "bold" : "normal") + " 72";
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 rad = 1;
string font_string = "Twemoji Color Font, Upright " + to_string(size);
string font_string = "Upright, Twemoji Color Font " + to_string(size);
VImage mask;
if (dividedWidth >= 1) {

View file

@ -28,7 +28,8 @@ export function clean(text) {
.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;
if (imageServers?.length !== 0) {