Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
// Code is slightly modified from the source. See license above.
const { GifCodec, GifFrame, BitmapImage } = require("gifwrap");
const Jimp = require("jimp");
const { AUTO } = Jimp;
const codec = new GifCodec();
module.exports = async (result, buffer) => {
let frames = [];
let gif;
if (Buffer.isBuffer(buffer)) {
gif = await codec.decodeGif(buffer);
({ frames } = gif);
} else if (buffer instanceof GifFrame) {
frames = [buffer];
}
frames.map(async frame => {
const image = new Jimp(frame.bitmap.width, frame.bitmap.height);
const bImage = new BitmapImage(frame);
image.bitmap = bImage.bitmap;
image.resize(result.type === "unicode" ? 72 : 128, AUTO);
return new GifFrame(bImage);
const prepareFrames = require("./PrepareFrames");
const prepareEndFrames = require("./PrepareEndFrames");
const EmojiUtils = require("./EmojiUtil");
const Jimp = require("jimp");
const { read, MIME_PNG, AUTO } = Jimp;
const { GifCodec, GifFrame, BitmapImage, GifUtil } = require("gifwrap");
const { get } = require("snekfetch");
const codec = new GifCodec();
module.exports = async emojis => {
emojis = emojis.map(e => e.trim()).filter(Boolean);
if (emojis.length > 6) emojis = emojis.splice(0, 6);
const results = await Promise.all(emojis.map(e => EmojiUtils.getEmojiMetadata(e)));
// #region SingleParamGiven
if (results.length === 1) {
if (results[0].type === "unicode") {
return {
buffer: (await get(results[0].url)).body,
};
}
if (results[0].url.endsWith(".gif")) {
const decodedGif = await codec.decodeGif((await get(results[0].url)).body);
const { frames } = decodedGif;
frames.map(async frame => {
const { get } = require("snekfetch");
const { GifCodec, BitmapImage, GifFrame } = require("gifwrap");
const Jimp = require("jimp");
const { AUTO } = Jimp;
const DJSUtil = require("discord.js/src/util/Util");
const codec = new GifCodec();
module.exports = async emojis => {
let split = emojis.map(s => s.trim()).filter(s => s !== "");
if (split.length > 3) split = split.slice(0, 3);
const getEmoji = async emoji => {
let emoji2 = DJSUtil.parseEmoji(emoji);
if (emoji2 && emoji2.animated) {
const { body } = await get(`https://cdn.discordapp.com/emojis/${emoji2.id}.gif`);
return body;
} else if (/^\d{17,19}$/.test(emoji)) {
const { body } = await get(`https://cdn.discordapp.com/emojis/${emoji}.gif`);
return body;
} else {
return null;
}
module.exports = async (result, b) => {
let frames = [];
let ogGif;
if (Buffer.isBuffer(b)) {
const c = new GifWrap.GifCodec();
const gif = await c.decodeGif(b);
frames = gif.frames;
ogGif = gif;
} else if (b instanceof GifWrap.GifFrame) {
frames = [b];
} else throw new Error("The buffer must be a GifFrame or a Buffer");
frames.map(g => new Promise((rs, rj) => new Jimp(g.bitmap.width, g.bitmap.height, (e, image) => {
if (e) rj(e);
let bImg = new GifWrap.BitmapImage(g);
image.bitmap = bImg.bitmap;
let w = result.type == "unicodeEmote" ? 72 : 128;
image.resize(w,AUTO);
rs(new GifWrap.GifFrame(bImg));
})
));
return {