From 551c7294b5d413603f113bb5fa3a14bc49ace35e Mon Sep 17 00:00:00 2001 From: Essem Date: Sat, 25 Jun 2022 12:45:42 -0500 Subject: [PATCH] Some tweaks --- commands/general/raw.js | 2 +- commands/image-editing/gif.js | 11 +++++++++++ commands/image-editing/togif.js | 11 ----------- natives/togif.cc | 17 ++--------------- shard.js | 2 +- 5 files changed, 15 insertions(+), 28 deletions(-) create mode 100644 commands/image-editing/gif.js delete mode 100644 commands/image-editing/togif.js diff --git a/commands/general/raw.js b/commands/general/raw.js index 4337569..cddc5fb 100644 --- a/commands/general/raw.js +++ b/commands/general/raw.js @@ -10,7 +10,7 @@ class RawCommand extends Command { } static description = "Gets a direct image URL (useful for saving GIFs from sites like Tenor)"; - static aliases = ["gif", "getgif", "giflink", "imglink", "getimg", "rawgif", "rawimg"]; + static aliases = ["giflink", "imglink", "getimg", "rawgif", "rawimg"]; static flags = [{ name: "image", type: 11, diff --git a/commands/image-editing/gif.js b/commands/image-editing/gif.js new file mode 100644 index 0000000..a912701 --- /dev/null +++ b/commands/image-editing/gif.js @@ -0,0 +1,11 @@ +import ImageCommand from "../../classes/imageCommand.js"; + +class GIFCommand extends ImageCommand { + static description = "Converts an image into a GIF"; + static aliases = ["gif", "getgif", "togif", "tgif", "gifify"]; + + static noImage = "You need to provide an image to convert to GIF!"; + static command = "togif"; +} + +export default GIFCommand; diff --git a/commands/image-editing/togif.js b/commands/image-editing/togif.js deleted file mode 100644 index d305a99..0000000 --- a/commands/image-editing/togif.js +++ /dev/null @@ -1,11 +0,0 @@ -import ImageCommand from "../../classes/imageCommand.js"; - -class ToGIFCommand extends ImageCommand { - static description = "Turns an image into a gif"; - static aliases = ["tgif", "gifify"]; - - static noImage = "You need to provide an image to turn into a GIF!"; - static command = "togif"; -} - -export default ToGIFCommand; diff --git a/natives/togif.cc b/natives/togif.cc index e52751e..9999809 100644 --- a/natives/togif.cc +++ b/natives/togif.cc @@ -23,24 +23,11 @@ Napi::Value ToGif(const Napi::CallbackInfo &info) { VOption *options = VImage::option()->set("access", "sequential"); VImage in = - VImage::new_from_buffer(data.Data(), data.Length(), "", - type == "gif" ? options->set("n", -1) : options) - .colourspace(VIPS_INTERPRETATION_sRGB); - if (!in.has_alpha()) in = in.bandjoin(255); - - int pageHeight = vips_image_get_page_height(in.get_image()); - - vector img; - - img.push_back(in); - - VImage final = VImage::arrayjoin(img, VImage::option()->set("across", 1)); - final.set(VIPS_META_PAGE_HEIGHT, pageHeight + in.height()); + VImage::new_from_buffer(data.Data(), data.Length(), "", options); void *buf; size_t length; - final.write_to_buffer( - ("." + type).c_str(), &buf, &length, VImage::option()->set("dither", 0)); + in.write_to_buffer(".gif", &buf, &length); vips_thread_shutdown(); diff --git a/shard.js b/shard.js index e494dc1..d80c11e 100644 --- a/shard.js +++ b/shard.js @@ -10,7 +10,7 @@ import { log, error } from "./utils/logger.js"; // initialize command loader import { load, update } from "./utils/handler.js"; // lavalink stuff -import { checkStatus, connect, reload, status, connected, manager } from "./utils/soundplayer.js"; +import { checkStatus, connect, reload, status, connected } from "./utils/soundplayer.js"; // database stuff import database from "./utils/database.js"; // command collections