Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #34 from ntm-development/dev
Browse files Browse the repository at this point in the history
Weeby-JS 2.1.0
  • Loading branch information
NTMNathan authored May 17, 2022
2 parents 438e497 + 975c497 commit 1cd42a7
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 39 deletions.
4 changes: 2 additions & 2 deletions assets/effects/general.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[
"blur",
"contrast",
"edge",
"greyscale",
Expand All @@ -11,5 +10,6 @@
"threshold",
"blurple",
"invertedthreshold",
"invertedgreyscale"
"invertedgreyscale",
"oil"
]
15 changes: 15 additions & 0 deletions assets/effects/level.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
3 changes: 2 additions & 1 deletion assets/generators/oneImage.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@
"thanossnap",
"forfivehours",
"markmeta",
"squidwardcancer"
"squidwardcancer",
"petershocked"
]
3 changes: 3 additions & 0 deletions assets/gif.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"bonk",
"bored",
"brofist",
"cafe",
"cheer",
"chase",
"clap",
Expand All @@ -20,6 +21,7 @@
"cringe",
"cry",
"cuddle",
"cute",
"dab",
"dance",
"facepalm",
Expand Down Expand Up @@ -52,6 +54,7 @@
"pat",
"peace",
"pikachu",
"police",
"poke",
"pout",
"punch",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down Expand Up @@ -50,4 +50,4 @@
"discordbot",
"discord"
]
}
}
39 changes: 26 additions & 13 deletions src/lib/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
Expand All @@ -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.')}`);
Expand All @@ -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}`)
Expand All @@ -88,22 +89,33 @@ class Custom {
* @param {RankOptions} options - The options that contain the required parameters.
* @returns {Promise<buffer>} 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;
}
Expand All @@ -113,24 +125,22 @@ class Custom {
* @param {LevelUpOptions} options - The options that contain the required parameters.
* @returns {Promise<buffer>} 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;
}
Expand Down Expand Up @@ -176,15 +186,18 @@ 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.
*/

/**
* Options for creating a level up card.
* @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.
*/
4 changes: 2 additions & 2 deletions src/lib/typedefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* * Riffic
* * Minecraft
* * Pinkycupid
* * Paladins
* * Pokemon
* * Oldenglish
* * Chalkduster
Expand All @@ -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
*/
14 changes: 7 additions & 7 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
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");
32 changes: 22 additions & 10 deletions typings/lib/custom.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ declare class Custom {
* @param {RankOptions} options - The options that contain the required parameters.
* @returns {Promise<buffer>} The generated image in a buffer.
*/
rank({ avatar, username, bgColor, level, xp }?: RankOptions): Promise<any>;
rank({ avatar, username, bgColor, level, xp, progressBar, progressBarColor, status, font }?: RankOptions): Promise<any>;
/**
* Creates a customisable level up card.
* @param {LevelUpOptions} options - The options that contain the required parameters.
* @returns {Promise<buffer>} The generated image in a buffer.
*/
levelUp({ avatar, bgColor, borderColor, oldlevel, newlevel, font }?: LevelUpOptions): Promise<any>;
levelUp({ avatar, bgColor, newlevel, status, font }?: LevelUpOptions): Promise<any>;
}
declare namespace Custom {
export { GreetingOptions, BoosterOptions, RankOptions, LevelUpOptions };
Expand Down Expand Up @@ -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.
Expand All @@ -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.
*/
Expand Down
4 changes: 2 additions & 2 deletions typings/lib/typedefs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* * Riffic
* * Minecraft
* * Pinkycupid
* * Paladins
* * Pokemon
* * Oldenglish
* * Chalkduster
Expand All @@ -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');

0 comments on commit 1cd42a7

Please sign in to comment.