From aab7c1603a626ade1daf35d4273e6f7db630aa24 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 17 May 2022 10:00:07 +1000 Subject: [PATCH] Weeby-JS 2.1.0 --- assets/effects/general.json | 4 ++-- assets/effects/level.json | 15 +++++++++++++ assets/generators/oneImage.json | 3 ++- assets/gif.json | 3 +++ package.json | 12 +++++----- src/lib/custom.js | 39 ++++++++++++++++++++++----------- src/lib/typedefs.js | 4 ++-- typings/index.d.ts | 14 ++++++------ typings/lib/custom.d.ts | 32 ++++++++++++++++++--------- typings/lib/typedefs.d.ts | 4 ++-- 10 files changed, 87 insertions(+), 43 deletions(-) diff --git a/assets/effects/general.json b/assets/effects/general.json index 5bca6e5..125daaa 100644 --- a/assets/effects/general.json +++ b/assets/effects/general.json @@ -1,5 +1,4 @@ [ - "blur", "contrast", "edge", "greyscale", @@ -11,5 +10,6 @@ "threshold", "blurple", "invertedthreshold", - "invertedgreyscale" + "invertedgreyscale", + "oil" ] \ No newline at end of file diff --git a/assets/effects/level.json b/assets/effects/level.json index 11986a1..a4de32a 100644 --- a/assets/effects/level.json +++ b/assets/effects/level.json @@ -13,5 +13,20 @@ "type": "distort", "min": 0, "max": 100 + }, + { + "type": "blur", + "min": 1, + "max": 180 + }, + { + "type": "swirl", + "min": -360, + "max": 360 + }, + { + "type": "implode", + "min": -100, + "max": 100 } ] \ No newline at end of file diff --git a/assets/generators/oneImage.json b/assets/generators/oneImage.json index 7dd3d7b..9606ada 100644 --- a/assets/generators/oneImage.json +++ b/assets/generators/oneImage.json @@ -45,5 +45,6 @@ "thanossnap", "forfivehours", "markmeta", - "squidwardcancer" + "squidwardcancer", + "petershocked" ] \ No newline at end of file diff --git a/assets/gif.json b/assets/gif.json index ae1c875..41ccfcb 100644 --- a/assets/gif.json +++ b/assets/gif.json @@ -12,6 +12,7 @@ "bonk", "bored", "brofist", + "cafe", "cheer", "chase", "clap", @@ -20,6 +21,7 @@ "cringe", "cry", "cuddle", + "cute", "dab", "dance", "facepalm", @@ -52,6 +54,7 @@ "pat", "peace", "pikachu", + "police", "poke", "pout", "punch", diff --git a/package.json b/package.json index acc6151..742aeb1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "weeby-js", - "version": "2.0.2", + "version": "2.1.0", "description": "JavaScript Wrapper for Weeby API", "main": "src/index.js", "scripts": { @@ -26,13 +26,13 @@ }, "homepage": "https://js.weebyapi.xyz/", "devDependencies": { - "@discordjs/docgen": "^0.11.0", + "@discordjs/docgen": "^0.11.1", "common-tags": "^1.8.2", - "dotenv": "^16.0.0", - "eslint": "^8.11.0", + "dotenv": "^16.0.1", + "eslint": "^8.15.0", "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^6.0.0", - "typescript": "^4.6.2" + "typescript": "^4.6.4" }, "dependencies": { "chalk": "^4.1.2", @@ -50,4 +50,4 @@ "discordbot", "discord" ] -} +} \ No newline at end of file diff --git a/src/lib/custom.js b/src/lib/custom.js index a5e4bbe..f6fc094 100644 --- a/src/lib/custom.js +++ b/src/lib/custom.js @@ -43,7 +43,7 @@ class Custom { const circleColor = circleHex ? circleHex : ''; const nameColor = nameHex ? nameHex : ''; const messageColor = messageHex ? messageHex : ''; - const fontParams = font ? font : ''; + const fontParams = font ? font : 'gotham'; const { body } = await get(`${this.baseURL}/greeting`) .set('Authorization', `Bearer ${this.token}`) @@ -63,6 +63,7 @@ class Custom { if (typeof name !== 'string') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The Name parameter is not a string.')}`); if (typeof background !== 'string') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The Background parameter is not a string.')}`); if (typeof title !== 'string') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The Title parameter is not a string.')}`); + if (!icon) throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('Icon parameter is missing. You will need to provide a valid image link.')}`); if (!background) throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('Background parameter is missing. You will need to provide a valid image link.')}`); if (!name) throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('Name parameter is missing. You will need to provide some text.')}`); @@ -73,7 +74,7 @@ class Custom { const circleColor = circleHex ? circleHex : ''; const nameColor = nameHex ? nameHex : ''; const messageColor = messageHex ? messageHex : ''; - const fontParams = font ? font : ''; + const fontParams = font ? font : 'nexa'; const { body } = await get(`${this.baseURL}/booster`) .set('Authorization', `Bearer ${this.token}`) @@ -88,22 +89,33 @@ class Custom { * @param {RankOptions} options - The options that contain the required parameters. * @returns {Promise} The generated image in a buffer. */ - async rank({ avatar, username, bgColor, level, xp } = {}) { + async rank({ avatar, username, bgColor, level, xp, progressBar, progressBarColor = '16f988', status = '16f988', font = 'nexa' } = {}) { if (typeof avatar !== 'string') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The Avatar parameter is not a string.')}`); if (typeof username !== 'string') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The Username parameter is not a string.')}`); if (typeof bgColor !== 'string') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The Background Color parameter is not a string.')}`); if (typeof level !== 'number') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The Level parameter is not a number.')}`); if (typeof xp !== 'number') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The XP parameter is not a number.')}`); + if (typeof progressBar !== 'number') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The Progress Bar parameter is not a number.')}`); + if (typeof progressBarColor !== 'string') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The Progress Bar Color parameter is not a hex.')}`); + if (typeof status !== 'string') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The Status parameter is not a hex.')}`); + if (!avatar) throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('Avatar parameter is missing. You will need to provide a valid image link.')}`); + if (!username) throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('Username parameter is missing. You will need to provide some text.')}`); if (!bgColor) throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('Background Color parameter is missing. You will need to provide a valid Hex Color Code.')}`); if (!level) throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('Level parameter is missing. You will need to provide a number.')}`); if (!xp) throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('XP parameter is missing. You will need to provide a number.')}`); + if (!progressBar) throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('Progress Bar parameter is missing. You will need to provide a number.')}`); + if (progressBar < 0) throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('Progress Bar parameter must not be lower than 0.')}`); + if (progressBar > 100) throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('Progress Bar parameter must not be higher than 100.')}`); + + + const fontParams = font ? font : 'nexa'; const { body } = await get(`${this.baseURL}/rank`) .set('Authorization', `Bearer ${this.token}`) .set('User-Agent', `Weeby-JS by NTM Development » v${version}`) - .query({ avatar: avatar, username: username, bgColor: bgColor, level: level, xp: xp }); + .query({ avatar: avatar, username: username, bgColor: bgColor, level: level, xp: xp, progressBar: progressBar, progressBarColor: progressBarColor, status: status, font: fontParams }); return body; } @@ -113,24 +125,22 @@ class Custom { * @param {LevelUpOptions} options - The options that contain the required parameters. * @returns {Promise} The generated image in a buffer. */ - async levelUp({ avatar, bgColor, borderColor, oldlevel, newlevel, font } = {}) { + async levelUp({ avatar, bgColor, newlevel, status = '16f988', font = 'nexa' } = {}) { if (typeof avatar !== 'string') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The Avatar parameter is not a string.')}`); if (typeof bgColor !== 'string') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The Background Color parameter is not a string.')}`); - if (typeof borderColor !== 'string') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The Border Color parameter is not a string.')}`); - if (typeof oldlevel !== 'number') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The Old Level parameter is not a number.')}`); if (typeof newlevel !== 'number') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The New Level parameter is not a number.')}`); + if (typeof status !== 'string') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The Status parameter is not a hex.')}`); + if (!avatar) throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('Avatar parameter is missing. You will need to provide a valid image link.')}`); if (!bgColor) throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('Background Color parameter is missing. You will need to provide a valid Hex Color Code.')}`); - if (!borderColor) throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('Border Color parameter is missing. You will need to provide a valid Hex Color Code.')}`); - if (!oldlevel) throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('Old Level parameter is missing. You will need to provide a number.')}`); if (!newlevel) throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('New Level parameter is missing. You will need to provide a number.')}`); - const fontParams = font ? font : ''; + const fontParams = font ? font : 'nexa'; const { body } = await get(`${this.baseURL}/levelup`) .set('Authorization', `Bearer ${this.token}`) .set('User-Agent', `Weeby-JS by NTM Development » v${version}`) - .query({ avatar: avatar, bgColor: bgColor, borderColor: borderColor, oldlevel: oldlevel, newlevel: newlevel, font: fontParams }); + .query({ avatar: avatar, bgColor: bgColor, newlevel: newlevel, status: status, font: fontParams }); return body; } @@ -176,6 +186,10 @@ module.exports = Custom; * @property {string} bgColor - The color of the background. * @property {number} level - The level the user is currently on. * @property {number} xp - How much XP the user has. + * @property {number} progressBar - The size of the progress bar. (0-100) + * @property {string} [progressBarColor='16f988'] - The color of the progress bar. + * @property {string} [status='43b581'] - The color of the user status. + * @property {string} [font=nexa] - The font to use, 'nexa' by default. */ /** @@ -183,8 +197,7 @@ module.exports = Custom; * @typedef {Object} LevelUpOptions * @property {string} avatar - The link to an image (.png, .jpg, .gif) * @property {string} bgColor - The color of the background. (Do not include the hashtag). - * @property {string} borderColor - The color of the avatar border. (Do not include the hashtag). - * @property {number} oldlevel - The old level of the user. * @property {number} newlevel - The new level of the user. + * @property {string} [status='16f988'] - The color of the user status. (Do not include the hashtag). * @property {FontType} [font=nexa] - The font to use, 'nexa' by default. */ \ No newline at end of file diff --git a/src/lib/typedefs.js b/src/lib/typedefs.js index 0ec47f5..c139ca6 100644 --- a/src/lib/typedefs.js +++ b/src/lib/typedefs.js @@ -8,7 +8,6 @@ * * Riffic * * Minecraft * * Pinkycupid - * * Paladins * * Pokemon * * Oldenglish * * Chalkduster @@ -18,5 +17,6 @@ * * Typewriter * * Spongebob * * Cornerofthesky - * @typedef {('gotham'|'stoneserif'|'roboto'|'arial'|'impact'|'riffic'|'minecraft'|'pinkycupid'|'paladins'|'pokemon'|'oldenglish'|'chalkduster'|'akbar'|'nexa'|'verdana'|'typewriter'|'spongebob'|'cornerofthesky'|'breesh')} FontType + * * Breesh + * @typedef {('gotham'|'stoneserif'|'roboto'|'arial'|'impact'|'riffic'|'minecraft'|'pinkycupid'|'pokemon'|'oldenglish'|'chalkduster'|'akbar'|'nexa'|'verdana'|'typewriter'|'spongebob'|'cornerofthesky'|'breesh')} FontType */ \ No newline at end of file diff --git a/typings/index.d.ts b/typings/index.d.ts index d1fb6b0..31511f5 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -24,10 +24,10 @@ declare class WeebyAPI { custom: Custom; utility: Utility; } -import Generators = require("./src/lib/generators"); -import GIF = require("./src/lib/gif"); -import Overlays = require("./src/lib/overlays"); -import Effects = require("./src/lib/effects"); -import JSON = require("./src/lib/json"); -import Custom = require("./src/lib/custom"); -import Utility = require("./src/lib/utility"); \ No newline at end of file +import Generators = require("./lib/generators"); +import GIF = require("./lib/gif"); +import Overlays = require("./lib/overlays"); +import Effects = require("./lib/effects"); +import JSON = require("./lib/json"); +import Custom = require("./lib/custom"); +import Utility = require("./lib/utility"); \ No newline at end of file diff --git a/typings/lib/custom.d.ts b/typings/lib/custom.d.ts index 2ae3ddc..7b023dd 100644 --- a/typings/lib/custom.d.ts +++ b/typings/lib/custom.d.ts @@ -34,13 +34,13 @@ declare class Custom { * @param {RankOptions} options - The options that contain the required parameters. * @returns {Promise} The generated image in a buffer. */ - rank({ avatar, username, bgColor, level, xp }?: RankOptions): Promise; + rank({ avatar, username, bgColor, level, xp, progressBar, progressBarColor, status, font }?: RankOptions): Promise; /** * Creates a customisable level up card. * @param {LevelUpOptions} options - The options that contain the required parameters. * @returns {Promise} The generated image in a buffer. */ - levelUp({ avatar, bgColor, borderColor, oldlevel, newlevel, font }?: LevelUpOptions): Promise; + levelUp({ avatar, bgColor, newlevel, status, font }?: LevelUpOptions): Promise; } declare namespace Custom { export { GreetingOptions, BoosterOptions, RankOptions, LevelUpOptions }; @@ -118,6 +118,22 @@ type RankOptions = { * - How much XP the user has. */ xp: number; + /** + * - The size of the progress bar. (0-100) + */ + progressBar: number; + /** + * - The color of the progress bar. + */ + progressBar?: string; + /** + * - The color of the progress bar. + */ + status?: string; + /** + * - The font to use, 'nexa' by default. + */ + font?: FontType; }; /** * Options for creating a level up card. @@ -131,18 +147,14 @@ type LevelUpOptions = { * - The color of the background. (Do not include the hashtag). */ bgColor: string; - /** - * - The color of the avatar border. (Do not include the hashtag). - */ - borderColor: string; - /** - * - The old level of the user. - */ - oldlevel: number; /** * - The new level of the user. */ newlevel: number; + /** + * - The color of the progress bar. + */ + status?: string; /** * - The font to use, 'nexa' by default. */ diff --git a/typings/lib/typedefs.d.ts b/typings/lib/typedefs.d.ts index 4ad12eb..beb2311 100644 --- a/typings/lib/typedefs.d.ts +++ b/typings/lib/typedefs.d.ts @@ -8,7 +8,6 @@ * * Riffic * * Minecraft * * Pinkycupid - * * Paladins * * Pokemon * * Oldenglish * * Chalkduster @@ -18,5 +17,6 @@ * * Typewriter * * Spongebob * * Cornerofthesky + * * Breesh */ -type FontType = ('gotham' | 'stoneserif' | 'roboto' | 'arial' | 'impact' | 'riffic' | 'minecraft' | 'pinkycupid' | 'paladins' | 'pokemon' | 'oldenglish' | 'chalkduster' | 'akbar' | 'nexa' | 'verdana' | 'typewriter' | 'spongebob' | 'cornerofthesky' | 'breesh'); +type FontType = ('gotham' | 'stoneserif' | 'roboto' | 'arial' | 'impact' | 'riffic' | 'minecraft' | 'pinkycupid' | 'pokemon' | 'oldenglish' | 'chalkduster' | 'akbar' | 'nexa' | 'verdana' | 'typewriter' | 'spongebob' | 'cornerofthesky' | 'breesh');