Skip to content

Commit

Permalink
v2.0.0-beta.0-fix.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Abadima committed Jan 21, 2024
1 parent 2599c8c commit e420006
Show file tree
Hide file tree
Showing 21 changed files with 142 additions and 123 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
## 🖥️ <b>[DEV] Installation</b>

```shell
npm install simply-xp@dev
npm install simply-xp@beta
```

```shell
pnpm install simply-xp@dev
pnpm install simply-xp@beta
```

```shell
yarn add simply-xp@dev
yarn add simply-xp@beta
```

<br>
Expand Down
Binary file modified Tests/charts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 7 additions & 7 deletions Tests/clean.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@ directories.forEach(directory => {
const filePath = directory + file;
const result = minify(readFileSync(filePath, "utf8"), {
compress: {
passes: 2,
reduce_funcs: true,
reduce_vars: true,
collapse_vars: true,
if_return: true,
hoist_funs: true,
hoist_vars: true,
if_return: true,
join_vars: true,
collapse_vars: true,
negate_iife: true,
passes: 2,
pure_funcs: [
"classCallCheck",
"_classCallCheck",
"_possibleConstructorReturn",
"Object.freeze",
"invariant",
"warning"
]
],
reduce_funcs: true,
reduce_vars: true
},
output: {comments: /^!|@returns/},
keep_fargs: true
keep_fargs: false
});

if (result.error) return console.error(`Error compressing ${file}: ${result.error}`);
Expand Down
Binary file modified Tests/compareCard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Tests/leaderboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Tests/rankCard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 19 additions & 12 deletions Tests/test.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const xp = require("../lib/xp");
const {XpLog} = require("../lib/src/functions/xplogs");
const { XpLog } = require("../lib/src/functions/xplogs");


const MongoURL = "mongodb+srv://test-bot:[email protected]/?retryWrites=true&w=majority";
Expand Down Expand Up @@ -27,7 +27,7 @@ async function test(dbType) {
initialize: async () => {
XpLog.info("test_plugin", "Initialized!")
},
requiredVersions: ["2"]
requiredVersions: [ "2" ]
}
]);

Expand All @@ -43,7 +43,7 @@ async function test(dbType) {
await xp.create("1234567894", "0987654321", "Snowball");
*/

await xp.roleSetup.add("0987654321", {level: 70, role: "01"});
await xp.roleSetup.add("0987654321", { level: 70, role: "01" });

await xp.addLevel("326815959358898189", "0987654321", 69, "アバディマ");

Expand All @@ -63,31 +63,37 @@ async function test(dbType) {

await xp.addLevel("1234567892", "0987654321", 10, "Jeremy");

await xp.roleSetup.add("0987654321", {level: 1, role: "01"});
await xp.roleSetup.add("0987654321", { level: 1, role: "01" });

await xp.roleSetup.remove("0987654321", 1);

await xp.rankCard(
{id: "0987654321", name: "SimplyTests"},
{ id: "0987654321", name: "SimplyTests" },
{
avatarURL: "https://i.ibb.co/WcfZPYL/Abadima.png",
id: "326815959358898189", username: "アバディマ"
},
{light: true, legacy: false}).then(results => {
{
fallbackFont: "https://cdn.jsdelivr.net/fontsource/fonts/mochiy-pop-one@latest/japanese-400-normal.woff2",
light: true, legacy: false
}).then(results => {
require("fs").writeFileSync("Tests/rankCard.png", results.attachment);
});

await xp.compareCard(
{id: "0987654321", name: "SimplyTests"},
{ id: "0987654321", name: "SimplyTests" },
{
avatarURL: "https://i.ibb.co/WcfZPYL/Abadima.png",
id: "326815959358898189", username: "Abadima"
},
{
avatarURL: "https://rahuletto.thedev.id/assets/logo.webp",
avatarURL: "data:image/webp;base64,UklGRroOAABXRUJQVlA4WAoAAAAQAAAAAAEAAAEAQUxQSMcCAAABoJZte942eyCIwR4IhSAGDYKJwRoENgMrCOQx6BAoDFIEkRkIwv1se/Phr+n+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34pyDwRMdFGy+NNpQhoSryX+ys/4bSAW9g4i9Ndo5t//dKZEV4Nffhi8zHPIhVyTcUbAtYUiM6mGHQ993G5OC2u0eIWASqxvbUEliak8isG3ejecvK7jnNnn6ve358MMV6Fyc4DtNxL/4Dn48B1PGj8qJUIL7JtSMDF0Xakca0LOmCm2+ef9fgqJ8lb+8kOm5oAzRR42lCKkYnsHz+pL9xhJAz7cOZVTEi6u0T8nEfFzzfsaTPnqrsXxEiiYtG6zid9XIu4yHKdSAvHPO3OlYNFUVbnZqdYudgbbIICauaopfLqytDmJ1tBaGzUzu7nJindABGWvmBXF1wALAw8mBab1XCEo1A+wvd40yPtokCN0O0PMOLdtBVYI1lUWupT64/fJ2c6UYCXrxc9CffTOuYa0fynAR9Ls4vMqdOBjnkKQjfzOHsQo6MLB8dRdOi7Xa0YyoN6FXn7+b0/vDc1rZS0p7W+m+TrYNJ3ffQMW0UVgajBKVYdiMflLUpAJsaR9us3BIEgRwhDJp3mQgoXAn3OzXO/E7Y5ek70rKwow1NH1AUHKW4qEwFOodJaHW9AAQzYVUA7SBWnBAOoyU8wnfa6wAAAAA==",
id: "1234567896", username: "Rahuletto"
},
{light: true}).then(results => {
{
fallbackFont: "https://cdn.jsdelivr.net/fontsource/fonts/mochiy-pop-one@latest/japanese-400-normal.woff2",
light: true
}).then(results => {
require("fs").writeFileSync("Tests/compareCard.png", results.attachment);
}
);
Expand All @@ -96,18 +102,20 @@ async function test(dbType) {
await xp.leaderboardCard(users, {
// artworkImage: "https://th.bing.com/th/id/R.8cd8594560bd9cf4b042833a4acefaa5?rik=A6B1qYN%2b5GQAcA&riu=http%3a%2f%2fwallpaperswide.com%2fdownload%2fdesert_sky-wallpaper-2560x720.jpg&ehk=rE5VYZy8njd5ZeNT2p4sP7C5psjSf%2bxLZmV%2bvlQCffs%3d&risl=&pid=ImgRaw&r=0",
//backgroundImage: new URL("https://static.vecteezy.com/system/resources/previews/000/962/809/original/abstract-gradient-background-with-colorful-and-modern-style-vector.jpg"),
fallbackFont: "https://cdn.jsdelivr.net/fontsource/fonts/mochiy-pop-one@latest/japanese-400-normal.woff2",
light: false,
rowOpacity: 1
}, {
name: "Development Hub",
imageURL: "https://cdn.discordapp.com/icons/950190034852646912/5a800bf4caf28bfcaccc214446b461c4.webp",
//memberCount: 20
}).then(results => {
}, {}).then(results => {
require("fs").writeFileSync("Tests/leaderboard.png", results.attachment);
});
});

await xp.charts("0987654321", {
fallbackFont: "https://cdn.jsdelivr.net/fontsource/fonts/mochiy-pop-one@latest/japanese-400-normal.woff2",
theme: "discord", type: "bar"
}).then(results => {
require("fs").writeFileSync("Tests/charts.png", results.attachment);
Expand All @@ -121,8 +129,7 @@ async function test(dbType) {

await xp.db.deleteMany({
collection: "simply-xps-levelroles", data: {
guild: "0987654321",
lvlrole: undefined
guild: "0987654321"
}
});
}
Expand Down
Binary file modified Tests/test.sqlite
Binary file not shown.
24 changes: 23 additions & 1 deletion [email protected]
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
# VERSION 2 CHANGELOGS

## [🎉 BETA 1](https://github.com/Abadima/simply-xp/releases/tag/v2.0.0-beta.1)
## [BETA 0 FIX 0](https://github.com/Abadima/simply-xp/releases/tag/v2.0.0-beta.0-fix.0)

### Additions

- Add `fallbackFont` option to `charts()`, `compareCard()`, `leaderboardCard()` and `rankCard()`, to use a fallback font, as part of
our bug fix.

### Improvements

- `rank()` gets minor code improvements.

### Bug Fixes

- Fix typings for `updateOptions()`
- Fix `compareCard()` and `rankCard()` unnecessary username filter, and inconsistencies.
- Swapped fonts from CDN to local, preventing future crashes.

### Improvements

- Remove URL ending checks (`comapreCard()` and `rankCard()`), to allow for better image/gif support, while still
elegantly handling errors.

## [🎉 BETA 0](https://github.com/Abadima/simply-xp/releases/tag/v2.0.0-beta.0)

### Additions

Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simply-xp",
"version": "2.0.0-beta.0",
"version": "2.0.0-beta.0-fix.0",
"description": "The easiest way to implement xp system",
"main": "lib/xp.js",
"scripts": {
Expand Down Expand Up @@ -45,12 +45,12 @@
"@napi-rs/canvas": "0.1.41"
},
"devDependencies": {
"@eslint/eslintrc": "^2.1.4",
"@eslint/eslintrc": "^3.0.0",
"@types/better-sqlite3": "^7.6.8",
"@types/node": "^20.10.5",
"@typescript-eslint/eslint-plugin": "^6.16.0",
"@typescript-eslint/parser": "^6.16.0",
"better-sqlite3": "^9.2.2",
"@types/node": "^20.11.5",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.19.0",
"better-sqlite3": "^9.3.0",
"eslint": "^8.56.0",
"mongodb": "^6.3.0",
"typescript": "^5.3.3",
Expand Down
5 changes: 3 additions & 2 deletions src/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ export interface XPResult extends UserResult {
* @returns {Promise<XPResult>} - Object of user data on success.
* @throws {XpFatal} - If parameters are not provided correctly.
*/
export async function addXP(userId: string, guildId: string,
xpData: number | { min: number, max: number }, username?: string): Promise<XPResult> {
export async function addXP(userId: string, guildId: string, xpData: number | {
min: number, max: number
}, username?: string): Promise<XPResult> {

if (typeof xpData !== "number" && (typeof xp !== "object" || !xpData.min || !xpData.max)) throw new XpFatal({
function: "addXP()", message: "XP is not a number or object, make sure you are using the correct syntax"
Expand Down
Loading

0 comments on commit e420006

Please sign in to comment.