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

Commit 1cd42a7

Browse files
authored
Merge pull request #34 from ntm-development/dev
Weeby-JS 2.1.0
2 parents 438e497 + 975c497 commit 1cd42a7

File tree

10 files changed

+83
-39
lines changed

10 files changed

+83
-39
lines changed

assets/effects/general.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
[
2-
"blur",
32
"contrast",
43
"edge",
54
"greyscale",
@@ -11,5 +10,6 @@
1110
"threshold",
1211
"blurple",
1312
"invertedthreshold",
14-
"invertedgreyscale"
13+
"invertedgreyscale",
14+
"oil"
1515
]

assets/effects/level.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,20 @@
1313
"type": "distort",
1414
"min": 0,
1515
"max": 100
16+
},
17+
{
18+
"type": "blur",
19+
"min": 1,
20+
"max": 180
21+
},
22+
{
23+
"type": "swirl",
24+
"min": -360,
25+
"max": 360
26+
},
27+
{
28+
"type": "implode",
29+
"min": -100,
30+
"max": 100
1631
}
1732
]

assets/generators/oneImage.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,6 @@
4545
"thanossnap",
4646
"forfivehours",
4747
"markmeta",
48-
"squidwardcancer"
48+
"squidwardcancer",
49+
"petershocked"
4950
]

assets/gif.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"bonk",
1313
"bored",
1414
"brofist",
15+
"cafe",
1516
"cheer",
1617
"chase",
1718
"clap",
@@ -20,6 +21,7 @@
2021
"cringe",
2122
"cry",
2223
"cuddle",
24+
"cute",
2325
"dab",
2426
"dance",
2527
"facepalm",
@@ -52,6 +54,7 @@
5254
"pat",
5355
"peace",
5456
"pikachu",
57+
"police",
5558
"poke",
5659
"pout",
5760
"punch",

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "weeby-js",
3-
"version": "2.0.2",
3+
"version": "2.1.0",
44
"description": "JavaScript Wrapper for Weeby API",
55
"main": "src/index.js",
66
"scripts": {
@@ -50,4 +50,4 @@
5050
"discordbot",
5151
"discord"
5252
]
53-
}
53+
}

src/lib/custom.js

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Custom {
4343
const circleColor = circleHex ? circleHex : '';
4444
const nameColor = nameHex ? nameHex : '';
4545
const messageColor = messageHex ? messageHex : '';
46-
const fontParams = font ? font : '';
46+
const fontParams = font ? font : 'gotham';
4747

4848
const { body } = await get(`${this.baseURL}/greeting`)
4949
.set('Authorization', `Bearer ${this.token}`)
@@ -63,6 +63,7 @@ class Custom {
6363
if (typeof name !== 'string') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The Name parameter is not a string.')}`);
6464
if (typeof background !== 'string') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The Background parameter is not a string.')}`);
6565
if (typeof title !== 'string') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The Title parameter is not a string.')}`);
66+
6667
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.')}`);
6768
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.')}`);
6869
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 {
7374
const circleColor = circleHex ? circleHex : '';
7475
const nameColor = nameHex ? nameHex : '';
7576
const messageColor = messageHex ? messageHex : '';
76-
const fontParams = font ? font : '';
77+
const fontParams = font ? font : 'nexa';
7778

7879
const { body } = await get(`${this.baseURL}/booster`)
7980
.set('Authorization', `Bearer ${this.token}`)
@@ -88,22 +89,33 @@ class Custom {
8889
* @param {RankOptions} options - The options that contain the required parameters.
8990
* @returns {Promise<buffer>} The generated image in a buffer.
9091
*/
91-
async rank({ avatar, username, bgColor, level, xp } = {}) {
92+
async rank({ avatar, username, bgColor, level, xp, progressBar, progressBarColor = '16f988', status = '16f988', font = 'nexa' } = {}) {
9293
if (typeof avatar !== 'string') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The Avatar parameter is not a string.')}`);
9394
if (typeof username !== 'string') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The Username parameter is not a string.')}`);
9495
if (typeof bgColor !== 'string') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The Background Color parameter is not a string.')}`);
9596
if (typeof level !== 'number') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The Level parameter is not a number.')}`);
9697
if (typeof xp !== 'number') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The XP parameter is not a number.')}`);
98+
if (typeof progressBar !== 'number') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The Progress Bar parameter is not a number.')}`);
99+
if (typeof progressBarColor !== 'string') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The Progress Bar Color parameter is not a hex.')}`);
100+
if (typeof status !== 'string') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The Status parameter is not a hex.')}`);
101+
97102
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.')}`);
103+
98104
if (!username) throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('Username parameter is missing. You will need to provide some text.')}`);
99105
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.')}`);
100106
if (!level) throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('Level parameter is missing. You will need to provide a number.')}`);
101107
if (!xp) throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('XP parameter is missing. You will need to provide a number.')}`);
108+
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.')}`);
109+
if (progressBar < 0) throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('Progress Bar parameter must not be lower than 0.')}`);
110+
if (progressBar > 100) throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('Progress Bar parameter must not be higher than 100.')}`);
111+
112+
113+
const fontParams = font ? font : 'nexa';
102114

103115
const { body } = await get(`${this.baseURL}/rank`)
104116
.set('Authorization', `Bearer ${this.token}`)
105117
.set('User-Agent', `Weeby-JS by NTM Development » v${version}`)
106-
.query({ avatar: avatar, username: username, bgColor: bgColor, level: level, xp: xp });
118+
.query({ avatar: avatar, username: username, bgColor: bgColor, level: level, xp: xp, progressBar: progressBar, progressBarColor: progressBarColor, status: status, font: fontParams });
107119

108120
return body;
109121
}
@@ -113,24 +125,22 @@ class Custom {
113125
* @param {LevelUpOptions} options - The options that contain the required parameters.
114126
* @returns {Promise<buffer>} The generated image in a buffer.
115127
*/
116-
async levelUp({ avatar, bgColor, borderColor, oldlevel, newlevel, font } = {}) {
128+
async levelUp({ avatar, bgColor, newlevel, status = '16f988', font = 'nexa' } = {}) {
117129
if (typeof avatar !== 'string') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The Avatar parameter is not a string.')}`);
118130
if (typeof bgColor !== 'string') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The Background Color parameter is not a string.')}`);
119-
if (typeof borderColor !== 'string') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The Border Color parameter is not a string.')}`);
120-
if (typeof oldlevel !== 'number') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The Old Level parameter is not a number.')}`);
121131
if (typeof newlevel !== 'number') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The New Level parameter is not a number.')}`);
132+
if (typeof status !== 'string') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The Status parameter is not a hex.')}`);
133+
122134
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.')}`);
123135
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.')}`);
124-
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.')}`);
125-
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.')}`);
126136
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.')}`);
127137

128-
const fontParams = font ? font : '';
138+
const fontParams = font ? font : 'nexa';
129139

130140
const { body } = await get(`${this.baseURL}/levelup`)
131141
.set('Authorization', `Bearer ${this.token}`)
132142
.set('User-Agent', `Weeby-JS by NTM Development » v${version}`)
133-
.query({ avatar: avatar, bgColor: bgColor, borderColor: borderColor, oldlevel: oldlevel, newlevel: newlevel, font: fontParams });
143+
.query({ avatar: avatar, bgColor: bgColor, newlevel: newlevel, status: status, font: fontParams });
134144

135145
return body;
136146
}
@@ -176,15 +186,18 @@ module.exports = Custom;
176186
* @property {string} bgColor - The color of the background.
177187
* @property {number} level - The level the user is currently on.
178188
* @property {number} xp - How much XP the user has.
189+
* @property {number} progressBar - The size of the progress bar. (0-100)
190+
* @property {string} [progressBarColor='16f988'] - The color of the progress bar.
191+
* @property {string} [status='43b581'] - The color of the user status.
192+
* @property {string} [font=nexa] - The font to use, 'nexa' by default.
179193
*/
180194

181195
/**
182196
* Options for creating a level up card.
183197
* @typedef {Object} LevelUpOptions
184198
* @property {string} avatar - The link to an image (.png, .jpg, .gif)
185199
* @property {string} bgColor - The color of the background. (Do not include the hashtag).
186-
* @property {string} borderColor - The color of the avatar border. (Do not include the hashtag).
187-
* @property {number} oldlevel - The old level of the user.
188200
* @property {number} newlevel - The new level of the user.
201+
* @property {string} [status='16f988'] - The color of the user status. (Do not include the hashtag).
189202
* @property {FontType} [font=nexa] - The font to use, 'nexa' by default.
190203
*/

src/lib/typedefs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
* * Riffic
99
* * Minecraft
1010
* * Pinkycupid
11-
* * Paladins
1211
* * Pokemon
1312
* * Oldenglish
1413
* * Chalkduster
@@ -18,5 +17,6 @@
1817
* * Typewriter
1918
* * Spongebob
2019
* * Cornerofthesky
21-
* @typedef {('gotham'|'stoneserif'|'roboto'|'arial'|'impact'|'riffic'|'minecraft'|'pinkycupid'|'paladins'|'pokemon'|'oldenglish'|'chalkduster'|'akbar'|'nexa'|'verdana'|'typewriter'|'spongebob'|'cornerofthesky'|'breesh')} FontType
20+
* * Breesh
21+
* @typedef {('gotham'|'stoneserif'|'roboto'|'arial'|'impact'|'riffic'|'minecraft'|'pinkycupid'|'pokemon'|'oldenglish'|'chalkduster'|'akbar'|'nexa'|'verdana'|'typewriter'|'spongebob'|'cornerofthesky'|'breesh')} FontType
2222
*/

typings/index.d.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ declare class WeebyAPI {
2424
custom: Custom;
2525
utility: Utility;
2626
}
27-
import Generators = require("./src/lib/generators");
28-
import GIF = require("./src/lib/gif");
29-
import Overlays = require("./src/lib/overlays");
30-
import Effects = require("./src/lib/effects");
31-
import JSON = require("./src/lib/json");
32-
import Custom = require("./src/lib/custom");
33-
import Utility = require("./src/lib/utility");
27+
import Generators = require("./lib/generators");
28+
import GIF = require("./lib/gif");
29+
import Overlays = require("./lib/overlays");
30+
import Effects = require("./lib/effects");
31+
import JSON = require("./lib/json");
32+
import Custom = require("./lib/custom");
33+
import Utility = require("./lib/utility");

typings/lib/custom.d.ts

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ declare class Custom {
3434
* @param {RankOptions} options - The options that contain the required parameters.
3535
* @returns {Promise<buffer>} The generated image in a buffer.
3636
*/
37-
rank({ avatar, username, bgColor, level, xp }?: RankOptions): Promise<any>;
37+
rank({ avatar, username, bgColor, level, xp, progressBar, progressBarColor, status, font }?: RankOptions): Promise<any>;
3838
/**
3939
* Creates a customisable level up card.
4040
* @param {LevelUpOptions} options - The options that contain the required parameters.
4141
* @returns {Promise<buffer>} The generated image in a buffer.
4242
*/
43-
levelUp({ avatar, bgColor, borderColor, oldlevel, newlevel, font }?: LevelUpOptions): Promise<any>;
43+
levelUp({ avatar, bgColor, newlevel, status, font }?: LevelUpOptions): Promise<any>;
4444
}
4545
declare namespace Custom {
4646
export { GreetingOptions, BoosterOptions, RankOptions, LevelUpOptions };
@@ -118,6 +118,22 @@ type RankOptions = {
118118
* - How much XP the user has.
119119
*/
120120
xp: number;
121+
/**
122+
* - The size of the progress bar. (0-100)
123+
*/
124+
progressBar: number;
125+
/**
126+
* - The color of the progress bar.
127+
*/
128+
progressBar?: string;
129+
/**
130+
* - The color of the progress bar.
131+
*/
132+
status?: string;
133+
/**
134+
* - The font to use, 'nexa' by default.
135+
*/
136+
font?: FontType;
121137
};
122138
/**
123139
* Options for creating a level up card.
@@ -131,18 +147,14 @@ type LevelUpOptions = {
131147
* - The color of the background. (Do not include the hashtag).
132148
*/
133149
bgColor: string;
134-
/**
135-
* - The color of the avatar border. (Do not include the hashtag).
136-
*/
137-
borderColor: string;
138-
/**
139-
* - The old level of the user.
140-
*/
141-
oldlevel: number;
142150
/**
143151
* - The new level of the user.
144152
*/
145153
newlevel: number;
154+
/**
155+
* - The color of the progress bar.
156+
*/
157+
status?: string;
146158
/**
147159
* - The font to use, 'nexa' by default.
148160
*/

typings/lib/typedefs.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
* * Riffic
99
* * Minecraft
1010
* * Pinkycupid
11-
* * Paladins
1211
* * Pokemon
1312
* * Oldenglish
1413
* * Chalkduster
@@ -18,5 +17,6 @@
1817
* * Typewriter
1918
* * Spongebob
2019
* * Cornerofthesky
20+
* * Breesh
2121
*/
22-
type FontType = ('gotham' | 'stoneserif' | 'roboto' | 'arial' | 'impact' | 'riffic' | 'minecraft' | 'pinkycupid' | 'paladins' | 'pokemon' | 'oldenglish' | 'chalkduster' | 'akbar' | 'nexa' | 'verdana' | 'typewriter' | 'spongebob' | 'cornerofthesky' | 'breesh');
22+
type FontType = ('gotham' | 'stoneserif' | 'roboto' | 'arial' | 'impact' | 'riffic' | 'minecraft' | 'pinkycupid' | 'pokemon' | 'oldenglish' | 'chalkduster' | 'akbar' | 'nexa' | 'verdana' | 'typewriter' | 'spongebob' | 'cornerofthesky' | 'breesh');

0 commit comments

Comments
 (0)