simply-xp 1.3.5-beta-6 → 1.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,57 +1,57 @@
1
- <p align="center"><img align="center" style="margin-bottom:-6px" src="https://i.imgur.com/BiaHJA7.png?maxwidth=128&fidelity=grand"></p>
2
-
3
- <h2 style="font-size:2.5rem;" align="center">Simply-XP</h2>
4
-
5
- <h2 align="center">A Simple, Easy and Beginner friendly XP System. <br>Supports Discord.JS<br><br>Developed by Rahuletto#0243 & Maintained by Abadima#6356</h2>
6
-
7
- <br>
8
- <p align="center">
9
- <a href="https://www.npmjs.com/package/simply-xp"><img src="https://img.shields.io/npm/v/simply-xp.svg?style=flat-square" /></a>
10
- <a href="https://www.npmjs.com/package/simply-xp"><img src="https://img.shields.io/npm/dt/simply-xp?style=flat-square" /></a><br>
11
- <a href="https://www.npmjs.com/package/simply-xp"><img src="https://nodei.co/npm/simply-xp.png?downloadRank=true&downloads=true&downloadRank=true&stars=true" /></a><br>
12
- <a href="https://discord.gg/3JzDV9T5Fn"><img src="https://invidget.switchblade.xyz/3JzDV9T5Fn" /></a>
13
- </p>
14
-
15
- <br>
16
-
17
- ## 🖥️ <b>How to install ?
18
-
19
- ```
20
- npm install simply-xp
21
- ```
22
-
23
- (or)
24
-
25
- ```
26
- yarn add simply-xp
27
- ```
28
-
29
- <br>
30
-
31
- # 🎉 Recent Updates 🎉
32
-
33
- - Fixed Various Bugs
34
- - Updated `Chart.js`
35
- - D.JS v14 Support
36
-
37
-
38
- # But Why ?
39
-
40
- - Easiest XP System in Discord.js
41
- - Fastest Support ever
42
- - Rank Card Maker
43
- - Beginner Friendly
44
- - Easier than other XP Systems
45
- - Inbuilt Auto Roles system
46
- - Flexible and simple at the same time
47
-
48
- <br>
49
-
50
- ## **Need Help ? Join the [Discord Server](https://discord.gg/3JzDV9T5Fn)**
51
-
52
- <br>
53
-
54
- <h1>👥 Contact us | Support</h1>
55
- <p>
56
- <a href="https://discord.gg/3JzDV9T5Fn"><img src="https://invidget.switchblade.xyz/3JzDV9T5Fn" /></a>
1
+ <p align="center"><img align="center" style="margin-bottom:-6px" src="https://i.imgur.com/BiaHJA7.png?maxwidth=128&fidelity=grand"></p>
2
+
3
+ <h2 style="font-size:2.5rem;" align="center">Simply-XP</h2>
4
+
5
+ <h2 align="center">A Simple, Easy and Beginner friendly XP System. <br>Supports Discord.JS<br><br>Developed by Rahuletto#0243 & Maintained by Abadima#6356</h2>
6
+
7
+ <br>
8
+ <p align="center">
9
+ <a href="https://www.npmjs.com/package/simply-xp"><img src="https://img.shields.io/npm/v/simply-xp.svg?style=flat-square" /></a>
10
+ <a href="https://www.npmjs.com/package/simply-xp"><img src="https://img.shields.io/npm/dt/simply-xp?style=flat-square" /></a><br>
11
+ <a href="https://www.npmjs.com/package/simply-xp"><img src="https://nodei.co/npm/simply-xp.png?downloadRank=true&downloads=true&downloadRank=true&stars=true" /></a><br>
12
+ <a href="https://discord.gg/3JzDV9T5Fn"><img src="https://invidget.switchblade.xyz/3JzDV9T5Fn" /></a>
13
+ </p>
14
+
15
+ <br>
16
+
17
+ ## 🖥️ <b>How to install ?
18
+
19
+ ```
20
+ npm install simply-xp
21
+ ```
22
+
23
+ (or)
24
+
25
+ ```
26
+ yarn add simply-xp
27
+ ```
28
+
29
+ <br>
30
+
31
+ # 🎉 Recent Updates 🎉
32
+
33
+ - Fixed Various Bugs
34
+ - Updated `Chart.js`
35
+ - D.JS v14 Support
36
+
37
+
38
+ # But Why ?
39
+
40
+ - Easiest XP System in Discord.js
41
+ - Fastest Support ever
42
+ - Rank Card Maker
43
+ - Beginner Friendly
44
+ - Easier than other XP Systems
45
+ - Inbuilt Auto Roles system
46
+ - Flexible and simple at the same time
47
+
48
+ <br>
49
+
50
+ ## **Need Help ? Join the [Discord Server](https://discord.gg/3JzDV9T5Fn)**
51
+
52
+ <br>
53
+
54
+ <h1>👥 Contact us | Support</h1>
55
+ <p>
56
+ <a href="https://discord.gg/3JzDV9T5Fn"><img src="https://invidget.switchblade.xyz/3JzDV9T5Fn" /></a>
57
57
  </p>
package/index.d.ts CHANGED
@@ -3,6 +3,7 @@ import { Message, Client } from 'discord.js'
3
3
  type HexColorString = `#${string}` | string
4
4
 
5
5
  export type connectOptions = {
6
+ auto_purge?: boolean,
6
7
  notify?: boolean
7
8
  }
8
9
 
package/package.json CHANGED
@@ -1,50 +1,54 @@
1
- {
2
- "name": "simply-xp",
3
- "version": "1.3.5-beta-6",
4
- "description": "A Simple, Easy and Beginner Friendly XP System",
5
- "main": "simplyxp.js",
6
- "typings": "index.d.ts",
7
- "scripts": {
8
- "test": "echo \"Error: no test specified\" && exit 1",
9
- "beta": "npm publish --tag beta"
10
- },
11
- "author": "Rahuletto",
12
- "keywords": [
13
- "xp",
14
- "simply",
15
- "easy",
16
- "xp-system",
17
- "system",
18
- "mongoose",
19
- "discord",
20
- "discord xp",
21
- "discord-xp",
22
- "simply-djs",
23
- "discord.js",
24
- "simplydjs",
25
- "weky",
26
- "nuggies",
27
- "experience",
28
- "level role",
29
- "amari",
30
- "package",
31
- "leaderboard",
32
- "mee6",
33
- "charts",
34
- "ChartJS",
35
- "level up"
36
- ],
37
- "license": "Apache-2.0",
38
- "repository": {
39
- "type": "git",
40
- "url": "https://github.com/Rahuletto/simply-xp"
41
- },
42
- "dependencies": {
43
- "@napi-rs/canvas": "^0.1.33",
44
- "chart.js": "^3.9.1",
45
- "mongoose": "^6.8.3"
46
- },
47
- "peerDependencies": {
48
- "discord.js": ">=13.12.0"
49
- }
50
- }
1
+ {
2
+ "name": "simply-xp",
3
+ "version": "1.3.5",
4
+ "description": "A Simple, Easy and Beginner Friendly XP System",
5
+ "main": "simplyxp.js",
6
+ "typings": "index.d.ts",
7
+ "scripts": {
8
+ "test": "echo \"Error: no test specified\" && exit 1",
9
+ "beta": "eslint . --fix && npm update && npm publish --tag beta",
10
+ "legacy": "eslint . --fix && npm update && npm publish --tag legacy"
11
+ },
12
+ "author": "Rahuletto",
13
+ "keywords": [
14
+ "xp",
15
+ "simply",
16
+ "easy",
17
+ "xp-system",
18
+ "system",
19
+ "mongoose",
20
+ "discord",
21
+ "discord xp",
22
+ "discord-xp",
23
+ "simply-djs",
24
+ "discord.js",
25
+ "simplydjs",
26
+ "weky",
27
+ "nuggies",
28
+ "experience",
29
+ "level role",
30
+ "amari",
31
+ "package",
32
+ "leaderboard",
33
+ "mee6",
34
+ "charts",
35
+ "ChartJS",
36
+ "level up"
37
+ ],
38
+ "license": "Apache-2.0",
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "https://github.com/Rahuletto/simply-xp"
42
+ },
43
+ "dependencies": {
44
+ "@napi-rs/canvas": "^0.1.41",
45
+ "chart.js": "^3.9.1",
46
+ "mongoose": "^7.4.2"
47
+ },
48
+ "peerDependencies": {
49
+ "discord.js": ">=13.12.0"
50
+ },
51
+ "devDependencies": {
52
+ "eslint": "^8.46.0"
53
+ }
54
+ }
package/simplyxp.js CHANGED
@@ -1,31 +1,33 @@
1
- try {
2
- require('discord.js')
3
- } catch (e) {
4
- console.warn('[XP] Discord.js is recommended for this package.')
5
- }
6
-
7
- module.exports.roleSetup = require('./src/roleSetup')
8
-
9
- module.exports.addLevel = require('./src/addLevel')
10
-
11
- module.exports.addXP = require('./src/addXP')
12
-
13
- module.exports.charts = require('./src/charts')
14
-
15
- module.exports.connect = require('./src/connect')
16
-
17
- module.exports.create = require('./src/create')
18
-
19
- module.exports.fetch = require('./src/fetch')
20
-
21
- module.exports.leaderboard = require('./src/leaderboard')
22
-
23
- module.exports.lvlRole = require('./src/lvlRole')
24
-
25
- module.exports.rank = require('./src/rank')
26
-
27
- module.exports.setLevel = require('./src/setLevel')
28
-
29
- module.exports.setXP = require('./src/setXP')
30
-
31
- module.exports.reset = require('./src/reset')
1
+ try {
2
+ require("discord.js");
3
+ } catch (e) {
4
+ console.warn("[XP] Discord.js is recommended for this package.");
5
+ }
6
+
7
+ module.exports.roleSetup = require("./src/roleSetup");
8
+
9
+ module.exports.addLevel = require("./src/addLevel");
10
+
11
+ module.exports.addXP = require("./src/addXP");
12
+
13
+ module.exports.charts = require("./src/charts");
14
+
15
+ module.exports.connect = require("./src/connect");
16
+
17
+ module.exports.create = require("./src/create");
18
+
19
+ module.exports.fetch = require("./src/fetch");
20
+
21
+ module.exports.leaderboard = require("./src/leaderboard");
22
+
23
+ module.exports.lvlRole = require("./src/lvlRole");
24
+
25
+ module.exports.rank = require("./src/rank");
26
+
27
+ module.exports.setLevel = require("./src/setLevel");
28
+
29
+ module.exports.setXP = require("./src/setXP");
30
+
31
+ module.exports.reset = require("./src/reset");
32
+
33
+ module.exports.options = {auto_purge: false};
package/src/addLevel.js CHANGED
@@ -1,66 +1,66 @@
1
- const levels = require('../src/models/level.js')
2
- let {roleSetup} = require('../simplyxp')
3
-
4
- /**
5
- * @param {Discord.Message} message
6
- * @param {string} userID
7
- * @param {string} guildID
8
- * @param {number} level
9
- */
10
- async function addLevel(message, userID, guildID, level) {
11
- if (!userID) throw new Error('[XP] User ID was not provided.')
12
-
13
- if (!guildID) throw new Error('[XP] Guild ID was not provided.')
14
-
15
- if (!level) throw new Error('[XP] Level amount is not provided.')
16
-
17
- let {client} = message
18
-
19
- const user = await levels.findOne({user: userID, guild: guildID})
20
-
21
- if (!user) {
22
- const newUser = new levels({
23
- user: userID,
24
- guild: guildID,
25
- xp: 0,
26
- level: 0
27
- })
28
-
29
- await newUser.save().catch(() => console.log(`[XP] Failed to save new user to database`))
30
-
31
- let xp = (level * 10) ** 2
32
-
33
- return {
34
- level: level,
35
- exp: xp
36
- }
37
- }
38
- let level1 = user.level
39
-
40
- user.level += parseFloat(level)
41
- user.xp = (user.level * 10) ** 2
42
-
43
- await user.save().catch((e) =>
44
- console.log(`[XP] Failed to add Level | User: ${userID} | Err: ${e}`)
45
- )
46
-
47
- if (level1 !== level) {
48
- let data = {
49
- xp: user.xp,
50
- level: user.level,
51
- userID,
52
- guildID
53
- }
54
-
55
- let role = await roleSetup.find(client, guildID, level)
56
-
57
- client.emit('levelUp', message, data, role)
58
- }
59
-
60
- return {
61
- level: user.level,
62
- xp: user.xp
63
- }
64
- }
65
-
66
- module.exports = addLevel
1
+ const levels = require("../src/models/level.js");
2
+ let {roleSetup} = require("../simplyxp");
3
+
4
+ /**
5
+ * @param {Discord.Message} message
6
+ * @param {string} userID
7
+ * @param {string} guildID
8
+ * @param {number} level
9
+ */
10
+ async function addLevel(message, userID, guildID, level) {
11
+ if (!userID) throw new Error("[XP] User ID was not provided.");
12
+
13
+ if (!guildID) throw new Error("[XP] Guild ID was not provided.");
14
+
15
+ if (!level) throw new Error("[XP] Level amount is not provided.");
16
+
17
+ let {client} = message;
18
+
19
+ const user = await levels.findOne({user: userID, guild: guildID});
20
+
21
+ if (!user) {
22
+ const newUser = new levels({
23
+ user: userID,
24
+ guild: guildID,
25
+ xp: 0,
26
+ level: 0
27
+ });
28
+
29
+ await newUser.save().catch(() => console.log("[XP] Failed to save new user to database"));
30
+
31
+ let xp = (level * 10) ** 2;
32
+
33
+ return {
34
+ level: level,
35
+ exp: xp
36
+ };
37
+ }
38
+ let level1 = user.level;
39
+
40
+ user.level += parseFloat(level);
41
+ user.xp = (user.level * 10) ** 2;
42
+
43
+ await user.save().catch((e) =>
44
+ console.log(`[XP] Failed to add Level | User: ${userID} | Err: ${e}`)
45
+ );
46
+
47
+ if (level1 !== level) {
48
+ let data = {
49
+ xp: user.xp,
50
+ level: user.level,
51
+ userID,
52
+ guildID
53
+ };
54
+
55
+ let role = await roleSetup.find(client, guildID, level);
56
+
57
+ client.emit("levelUp", message, data, role);
58
+ }
59
+
60
+ return {
61
+ level: user.level,
62
+ xp: user.xp
63
+ };
64
+ }
65
+
66
+ module.exports = addLevel;
package/src/addXP.js CHANGED
@@ -1,103 +1,104 @@
1
- const levels = require('../src/models/level.js')
2
- let {roleSetup} = require('../simplyxp')
3
-
4
- /**
5
- * @param {Discord.Message} message
6
- * @param {string} userID
7
- * @param {string} guildID
8
- * @param {number} xp
9
- */
10
-
11
- async function addXP(message, userID, guildID, xp) {
12
- if (!userID) throw new Error('[XP] User ID was not provided.')
13
-
14
- if (!guildID) throw new Error('[XP] Guild ID was not provided.')
15
-
16
- if (!xp) throw new Error('[XP] XP amount is not provided.')
17
-
18
- let {client} = message
19
-
20
- let min
21
- let max
22
- if (xp.min) {
23
- if (!xp.max)
24
- throw new Error(
25
- '[XP] XP min amount is provided but max amount is not provided.'
26
- )
27
-
28
- min = Number(xp.min)
29
-
30
- if (Number(xp.min).toString() === 'NaN')
31
- throw new Error('[XP] XP amount (min) is not a number.')
32
- }
33
-
34
- if (xp.max) {
35
- if (!xp.min)
36
- throw new Error(
37
- '[XP] XP max amount is provided but min amount is not provided.'
38
- )
39
-
40
- max = Number(xp.max)
41
-
42
- if (Number(xp.max).toString() === 'NaN')
43
- throw new Error('[XP] XP amount (max) is not a number.')
44
- }
45
-
46
- if (xp.min && xp.max) {
47
- xp = Math.floor(Math.random() * (max - min) + min)
48
- }
49
-
50
- const user = await levels.findOne({user: userID, guild: guildID})
51
-
52
- let lvl = Math.floor(0.1 * Math.sqrt(xp))
53
-
54
- if (!user) {
55
- const newUser = new levels({
56
- user: userID,
57
- guild: guildID,
58
- xp: xp,
59
- level: lvl
60
- })
61
-
62
- await newUser.save().catch(() => console.log(`[XP] Failed to save new user to database`))
63
-
64
- return {
65
- level: 0,
66
- exp: 0
67
- }
68
- }
69
- let level1 = user.level
70
-
71
- user.xp += parseInt(xp, 10)
72
- user.level = Math.floor(0.1 * Math.sqrt(user.xp))
73
-
74
- await user.save().catch((e) => console.log(`[XP] Failed to add XP | User: ${userID} | Err: ${e}`))
75
-
76
- let level = user.level
77
-
78
- xp = user.xp
79
-
80
- if (user.xp === 0 || Math.sign(user.xp) === -1) {
81
- xp = 0
82
- }
83
-
84
- if (level1 !== level) {
85
- let data = {
86
- xp,
87
- level,
88
- userID,
89
- guildID
90
- }
91
-
92
- let role = await roleSetup.find(client, guildID, level)
93
-
94
- client.emit('levelUp', message, data, role)
95
- }
96
-
97
- return {
98
- level,
99
- xp
100
- }
101
- }
102
-
103
- module.exports = addXP
1
+ const levels = require("../src/models/level.js");
2
+ let {roleSetup} = require("../simplyxp");
3
+
4
+ /**
5
+ * @param {Discord.Message} message
6
+ * @param {string} userID
7
+ * @param {string} guildID
8
+ * @param {number} xp
9
+ */
10
+
11
+ async function addXP(message, userID, guildID, xp) {
12
+ if (!userID) throw new Error("[XP] User ID was not provided.");
13
+
14
+ if (!guildID) throw new Error("[XP] Guild ID was not provided.");
15
+
16
+ if (!xp) throw new Error("[XP] XP amount is not provided.");
17
+
18
+ let {client} = message;
19
+
20
+ let min;
21
+ let max;
22
+ if (xp.min) {
23
+ if (!xp.max)
24
+ throw new Error(
25
+ "[XP] XP min amount is provided but max amount is not provided."
26
+ );
27
+
28
+ min = Number(xp.min);
29
+
30
+ if (Number(xp.min).toString() === "NaN")
31
+ throw new Error("[XP] XP amount (min) is not a number.");
32
+ }
33
+
34
+ if (xp.max) {
35
+ if (!xp.min)
36
+ throw new Error(
37
+ "[XP] XP max amount is provided but min amount is not provided."
38
+ );
39
+
40
+ max = Number(xp.max);
41
+
42
+ if (Number(xp.max).toString() === "NaN")
43
+ throw new Error("[XP] XP amount (max) is not a number.");
44
+ }
45
+
46
+ if (xp.min && xp.max) {
47
+ xp = Math.floor(Math.random() * (max - min) + min);
48
+ }
49
+
50
+ const user = await levels.findOne({user: userID, guild: guildID});
51
+
52
+ let lvl = Math.floor(0.1 * Math.sqrt(xp));
53
+
54
+ // TODO: FIX THIS xp = xp & level = lvl
55
+ if (!user) {
56
+ const newUser = new levels({
57
+ user: userID,
58
+ guild: guildID,
59
+ xp: xp,
60
+ level: lvl
61
+ });
62
+
63
+ await newUser.save().catch(() => console.log("[XP] Failed to save new user to database"));
64
+
65
+ return {
66
+ level: 0,
67
+ exp: 0
68
+ };
69
+ }
70
+ let level1 = user.level;
71
+
72
+ user.xp += parseInt(xp, 10);
73
+ user.level = Math.floor(0.1 * Math.sqrt(user.xp));
74
+
75
+ await user.save().catch((e) => console.log(`[XP] Failed to add XP | User: ${userID} | Err: ${e}`));
76
+
77
+ let level = user.level;
78
+
79
+ xp = user.xp;
80
+
81
+ if (user.xp === 0 || Math.sign(user.xp) === -1) {
82
+ xp = 0;
83
+ }
84
+
85
+ if (level1 !== level) {
86
+ let data = {
87
+ xp,
88
+ level,
89
+ userID,
90
+ guildID
91
+ };
92
+
93
+ let role = await roleSetup.find(client, guildID, level);
94
+
95
+ client.emit("levelUp", message, data, role);
96
+ }
97
+
98
+ return {
99
+ level,
100
+ xp
101
+ };
102
+ }
103
+
104
+ module.exports = addXP;