simply-xp 1.3.5-beta-7 → 1.3.6

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,58 @@
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
+ - Patched v1.3.5 Bugs
37
+
38
+
39
+ # But Why ?
40
+
41
+ - Easiest XP System in Discord.js
42
+ - Fastest Support ever
43
+ - Rank Card Maker
44
+ - Beginner Friendly
45
+ - Easier than other XP Systems
46
+ - Inbuilt Auto Roles system
47
+ - Flexible and simple at the same time
48
+
49
+ <br>
50
+
51
+ ## **Need Help ? Join the [Discord Server](https://discord.gg/3JzDV9T5Fn)**
52
+
53
+ <br>
54
+
55
+ <h1>👥 Contact us | Support</h1>
56
+ <p>
57
+ <a href="https://discord.gg/3JzDV9T5Fn"><img src="https://invidget.switchblade.xyz/3JzDV9T5Fn" /></a>
57
58
  </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,53 +1,55 @@
1
- {
2
- "name": "simply-xp",
3
- "version": "1.3.5-beta-7",
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
- },
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.41",
44
- "chart.js": "^3.9.1",
45
- "mongoose": "^6.11.2"
46
- },
47
- "peerDependencies": {
48
- "discord.js": ">=13.12.0"
49
- },
50
- "devDependencies": {
51
- "eslint": "^8.43.0"
52
- }
53
- }
1
+ {
2
+ "name": "simply-xp",
3
+ "version": "1.3.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": "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/Abadima/simply-xp"
42
+ },
43
+ "homepage": "https://simplyxp.js.org",
44
+ "dependencies": {
45
+ "@napi-rs/canvas": "^0.1.43",
46
+ "chart.js": "^3.9.1",
47
+ "mongoose": "^7.4.2"
48
+ },
49
+ "peerDependencies": {
50
+ "discord.js": ">=13.12.0"
51
+ },
52
+ "devDependencies": {
53
+ "eslint": "^8.47.0"
54
+ }
55
+ }
package/simplyxp.js CHANGED
@@ -1,31 +1,33 @@
1
1
  try {
2
- require('discord.js');
2
+ require("discord.js");
3
3
  } catch (e) {
4
- console.warn('[XP] Discord.js is recommended for this package.');
4
+ console.warn("[XP] Discord.js is recommended for this package.");
5
5
  }
6
6
 
7
- module.exports.roleSetup = require('./src/roleSetup');
7
+ module.exports.options = {auto_purge: false};
8
8
 
9
- module.exports.addLevel = require('./src/addLevel');
9
+ module.exports.roleSetup = require("./src/roleSetup");
10
10
 
11
- module.exports.addXP = require('./src/addXP');
11
+ module.exports.addLevel = require("./src/addLevel");
12
12
 
13
- module.exports.charts = require('./src/charts');
13
+ module.exports.addXP = require("./src/addXP");
14
14
 
15
- module.exports.connect = require('./src/connect');
15
+ module.exports.charts = require("./src/charts");
16
16
 
17
- module.exports.create = require('./src/create');
17
+ module.exports.connect = require("./src/connect");
18
18
 
19
- module.exports.fetch = require('./src/fetch');
19
+ module.exports.create = require("./src/create");
20
20
 
21
- module.exports.leaderboard = require('./src/leaderboard');
21
+ module.exports.fetch = require("./src/fetch");
22
22
 
23
- module.exports.lvlRole = require('./src/lvlRole');
23
+ module.exports.leaderboard = require("./src/leaderboard");
24
24
 
25
- module.exports.rank = require('./src/rank');
25
+ module.exports.lvlRole = require("./src/lvlRole");
26
26
 
27
- module.exports.setLevel = require('./src/setLevel');
27
+ module.exports.rank = require("./src/rank");
28
28
 
29
- module.exports.setXP = require('./src/setXP');
29
+ module.exports.setLevel = require("./src/setLevel");
30
30
 
31
- module.exports.reset = require('./src/reset');
31
+ module.exports.setXP = require("./src/setXP");
32
+
33
+ module.exports.reset = require("./src/reset");
package/src/addLevel.js CHANGED
@@ -1,5 +1,5 @@
1
- const levels = require('../src/models/level.js');
2
- let {roleSetup} = require('../simplyxp');
1
+ const levels = require("../src/models/level.js");
2
+ let {roleSetup} = require("../simplyxp");
3
3
 
4
4
  /**
5
5
  * @param {Discord.Message} message
@@ -8,11 +8,11 @@ let {roleSetup} = require('../simplyxp');
8
8
  * @param {number} level
9
9
  */
10
10
  async function addLevel(message, userID, guildID, level) {
11
- if (!userID) throw new Error('[XP] User ID was not provided.');
11
+ if (!userID) throw new Error("[XP] User ID was not provided.");
12
12
 
13
- if (!guildID) throw new Error('[XP] Guild ID was not provided.');
13
+ if (!guildID) throw new Error("[XP] Guild ID was not provided.");
14
14
 
15
- if (!level) throw new Error('[XP] Level amount is not provided.');
15
+ if (!level) throw new Error("[XP] Level amount is not provided.");
16
16
 
17
17
  let {client} = message;
18
18
 
@@ -26,7 +26,7 @@ async function addLevel(message, userID, guildID, level) {
26
26
  level: 0
27
27
  });
28
28
 
29
- await newUser.save().catch(() => console.log('[XP] Failed to save new user to database'));
29
+ await newUser.save().catch(() => console.log("[XP] Failed to save new user to database"));
30
30
 
31
31
  let xp = (level * 10) ** 2;
32
32
 
@@ -54,7 +54,7 @@ async function addLevel(message, userID, guildID, level) {
54
54
 
55
55
  let role = await roleSetup.find(client, guildID, level);
56
56
 
57
- client.emit('levelUp', message, data, role);
57
+ client.emit("levelUp", message, data, role);
58
58
  }
59
59
 
60
60
  return {
package/src/addXP.js CHANGED
@@ -1,5 +1,5 @@
1
- const levels = require('../src/models/level.js');
2
- let {roleSetup} = require('../simplyxp');
1
+ const levels = require("../src/models/level.js");
2
+ let {roleSetup} = require("../simplyxp");
3
3
 
4
4
  /**
5
5
  * @param {Discord.Message} message
@@ -9,11 +9,11 @@ let {roleSetup} = require('../simplyxp');
9
9
  */
10
10
 
11
11
  async function addXP(message, userID, guildID, xp) {
12
- if (!userID) throw new Error('[XP] User ID was not provided.');
12
+ if (!userID) throw new Error("[XP] User ID was not provided.");
13
13
 
14
- if (!guildID) throw new Error('[XP] Guild ID was not provided.');
14
+ if (!guildID) throw new Error("[XP] Guild ID was not provided.");
15
15
 
16
- if (!xp) throw new Error('[XP] XP amount is not provided.');
16
+ if (!xp) throw new Error("[XP] XP amount is not provided.");
17
17
 
18
18
  let {client} = message;
19
19
 
@@ -22,25 +22,25 @@ async function addXP(message, userID, guildID, xp) {
22
22
  if (xp.min) {
23
23
  if (!xp.max)
24
24
  throw new Error(
25
- '[XP] XP min amount is provided but max amount is not provided.'
25
+ "[XP] XP min amount is provided but max amount is not provided."
26
26
  );
27
27
 
28
28
  min = Number(xp.min);
29
29
 
30
- if (Number(xp.min).toString() === 'NaN')
31
- throw new Error('[XP] XP amount (min) is not a number.');
30
+ if (Number(xp.min).toString() === "NaN")
31
+ throw new Error("[XP] XP amount (min) is not a number.");
32
32
  }
33
33
 
34
34
  if (xp.max) {
35
35
  if (!xp.min)
36
36
  throw new Error(
37
- '[XP] XP max amount is provided but min amount is not provided.'
37
+ "[XP] XP max amount is provided but min amount is not provided."
38
38
  );
39
39
 
40
40
  max = Number(xp.max);
41
41
 
42
- if (Number(xp.max).toString() === 'NaN')
43
- throw new Error('[XP] XP amount (max) is not a number.');
42
+ if (Number(xp.max).toString() === "NaN")
43
+ throw new Error("[XP] XP amount (max) is not a number.");
44
44
  }
45
45
 
46
46
  if (xp.min && xp.max) {
@@ -60,7 +60,7 @@ async function addXP(message, userID, guildID, xp) {
60
60
  level: lvl
61
61
  });
62
62
 
63
- await newUser.save().catch(() => console.log('[XP] Failed to save new user to database'));
63
+ await newUser.save().catch(() => console.log("[XP] Failed to save new user to database"));
64
64
 
65
65
  return {
66
66
  level: 0,
@@ -92,7 +92,7 @@ async function addXP(message, userID, guildID, xp) {
92
92
 
93
93
  let role = await roleSetup.find(client, guildID, level);
94
94
 
95
- client.emit('levelUp', message, data, role);
95
+ client.emit("levelUp", message, data, role);
96
96
  }
97
97
 
98
98
  return {
package/src/charts.js CHANGED
@@ -1,18 +1,18 @@
1
- let leaderboard = require('./leaderboard');
1
+ let leaderboard = require("./leaderboard");
2
2
 
3
3
  /**
4
4
  * @param {Discord.Message} message
5
- * @param {import('../index').chartsOptions} options
5
+ * @param {import("../index").chartsOptions} options
6
6
  */
7
7
 
8
8
  async function charts(message, options) {
9
9
  try {
10
- require('canvas');
10
+ require("canvas");
11
11
  } catch {
12
- throw '[XP] This requires canvas to be installed. \n"npm install canvas"';
12
+ throw "[XP] This requires canvas to be installed. \n\"npm install canvas\"";
13
13
  }
14
- const ChartJS = require('chart.js');
15
- const Canvas = require('canvas');
14
+ const ChartJS = require("chart.js");
15
+ const Canvas = require("canvas");
16
16
  let {client} = message;
17
17
 
18
18
  let data = [];
@@ -30,30 +30,30 @@ async function charts(message, options) {
30
30
  });
31
31
 
32
32
  new ChartJS(ctx, {
33
- type: options.type || 'bar',
33
+ type: options.type || "bar",
34
34
  data: {
35
35
  labels: uzern,
36
36
  datasets: [
37
37
  {
38
- label: 'Leaderboards',
38
+ label: "Leaderboards",
39
39
  data: data,
40
40
  backgroundColor: [
41
- 'rgba(255, 99, 132, 0.5)',
42
- 'rgba(255, 159, 64, 0.5)',
43
- 'rgba(255, 205, 86, 0.5)',
44
- 'rgba(75, 192, 192, 0.5)',
45
- 'rgba(54, 162, 235, 0.5)',
46
- 'rgba(153, 102, 255, 0.5)',
47
- 'rgb(201, 203, 207, 0.5)'
41
+ "rgba(255, 99, 132, 0.5)",
42
+ "rgba(255, 159, 64, 0.5)",
43
+ "rgba(255, 205, 86, 0.5)",
44
+ "rgba(75, 192, 192, 0.5)",
45
+ "rgba(54, 162, 235, 0.5)",
46
+ "rgba(153, 102, 255, 0.5)",
47
+ "rgb(201, 203, 207, 0.5)"
48
48
  ],
49
49
  borderColor: [
50
- 'rgb(255, 99, 132)',
51
- 'rgb(255, 159, 64)',
52
- 'rgb(255, 205, 86)',
53
- 'rgb(75, 192, 192)',
54
- 'rgb(54, 162, 235)',
55
- 'rgb(153, 102, 255)',
56
- 'rgb(201, 203, 207)'
50
+ "rgb(255, 99, 132)",
51
+ "rgb(255, 159, 64)",
52
+ "rgb(255, 205, 86)",
53
+ "rgb(75, 192, 192)",
54
+ "rgb(54, 162, 235)",
55
+ "rgb(153, 102, 255)",
56
+ "rgb(201, 203, 207)"
57
57
  ],
58
58
  borderWidth: 2
59
59
  }
@@ -64,18 +64,18 @@ async function charts(message, options) {
64
64
  plugins: {
65
65
  title: {
66
66
  display: true,
67
- text: 'XP Datasheet'
67
+ text: "XP Datasheet"
68
68
  }
69
69
  }
70
70
  },
71
71
  plugins: [
72
72
  {
73
- id: 'simply-xp',
73
+ id: "simply-xp",
74
74
  beforeDraw: (chart) => {
75
- const ctx = chart.canvas.getContext('2d');
75
+ const ctx = chart.canvas.getContext("2d");
76
76
  ctx.save();
77
- ctx.globalCompositeOperation = 'destination-over';
78
- ctx.fillStyle = options.background || '#2F3136';
77
+ ctx.globalCompositeOperation = "destination-over";
78
+ ctx.fillStyle = options.background || "#2F3136";
79
79
  ctx.fillRect(0, 0, chart.width, chart.height);
80
80
  ctx.restore();
81
81
  }
@@ -84,8 +84,8 @@ async function charts(message, options) {
84
84
  }).update();
85
85
 
86
86
  return {
87
- attachment: ctx.toBuffer('image/png'),
88
- name: 'chart.png'
87
+ attachment: ctx.toBuffer("image/png"),
88
+ name: "chart.png"
89
89
  };
90
90
  }
91
91
 
package/src/connect.js CHANGED
@@ -1,22 +1,21 @@
1
- const mongoose = require('mongoose');
1
+ const mongoose = require("mongoose");
2
2
 
3
3
  /**
4
4
  * @param {string} db
5
- * @param {import('../index').connectOptions} options
5
+ * @param {import("../index").connectOptions} options
6
6
  */
7
7
 
8
8
  async function connect(db, options = []) {
9
- if (!db) throw new Error('[XP] Database URL was not provided');
10
- mongoose.set('strictQuery', true);
11
-
9
+ if (!db) throw new Error("[XP] Database URL was not provided");
10
+ mongoose.set("strictQuery", true);
11
+
12
12
  mongoose.connect(db, {
13
13
  useNewUrlParser: true,
14
14
  useUnifiedTopology: true
15
15
  });
16
16
 
17
17
 
18
- if (options.notify === false) return;
19
- else return console.log('{ XP } Database Connected');
18
+ if (options.notify) return console.log("{ XP } Database Connected");
20
19
  }
21
20
 
22
21
  module.exports = connect;
package/src/create.js CHANGED
@@ -1,4 +1,4 @@
1
- const levels = require('../src/models/level.js');
1
+ const levels = require("../src/models/level.js");
2
2
 
3
3
  /**
4
4
  * @param {string} userID
@@ -6,11 +6,11 @@ const levels = require('../src/models/level.js');
6
6
  */
7
7
 
8
8
  async function create(userID, guildID) {
9
- if (!userID) throw new Error('[XP] User ID was not provided.');
9
+ if (!userID) throw new Error("[XP] User ID was not provided.");
10
10
 
11
- if (!guildID) throw new Error('[XP] User ID was not provided.');
11
+ if (!guildID) throw new Error("[XP] User ID was not provided.");
12
12
 
13
- let uzer = await levels.findOne({ user: userID, guild: guildID });
13
+ let uzer = await levels.findOne({user: userID, guild: guildID});
14
14
 
15
15
  if (uzer) return;
16
16
 
@@ -20,7 +20,7 @@ async function create(userID, guildID) {
20
20
  });
21
21
  await newuser
22
22
  .save()
23
- .catch(() => console.log('[XP] Failed to save new use to database'));
23
+ .catch(() => console.log("[XP] Failed to save new use to database"));
24
24
 
25
25
  return true;
26
26
  }
package/src/fetch.js CHANGED
@@ -1,4 +1,4 @@
1
- const levels = require('../src/models/level.js');
1
+ const levels = require("../src/models/level.js");
2
2
 
3
3
  /**
4
4
  * @param {string} userID
@@ -6,9 +6,9 @@ const levels = require('../src/models/level.js');
6
6
  */
7
7
 
8
8
  async function fetch(userID, guildID) {
9
- if (!userID) throw new Error('[XP] User ID was not provided.');
9
+ if (!userID) throw new Error("[XP] User ID was not provided.");
10
10
 
11
- if (!guildID) throw new Error('[XP] Guild ID was not provided.');
11
+ if (!guildID) throw new Error("[XP] Guild ID was not provided.");
12
12
 
13
13
  let user = await levels.findOne({
14
14
  user: userID,
@@ -29,7 +29,7 @@ async function fetch(userID, guildID) {
29
29
  .find({
30
30
  guild: guildID
31
31
  })
32
- .sort([['xp', 'descending']])
32
+ .sort([["xp", "descending"]])
33
33
  .exec();
34
34
 
35
35
  if (user === null)
@@ -49,7 +49,7 @@ async function fetch(userID, guildID) {
49
49
  let target = targetxp * targetxp * 100;
50
50
 
51
51
  function shortener(count) {
52
- const COUNT_ABBRS = ['', 'k', 'M', 'T'];
52
+ const COUNT_ABBRS = ["", "k", "M", "T"];
53
53
 
54
54
  const i = 0 === count ? count : Math.floor(Math.log(count) / Math.log(1000));
55
55
  let result = parseFloat((count / Math.pow(1000, i)).toFixed(2));
@@ -1,4 +1,5 @@
1
- const levels = require('../src/models/level.js');
1
+ const levels = require("../src/models/level.js");
2
+ const {options} = require("../simplyxp");
2
3
 
3
4
  /**
4
5
  * @param {Discord.Client} client
@@ -7,17 +8,17 @@ const levels = require('../src/models/level.js');
7
8
  */
8
9
 
9
10
  async function leaderboard(client, guildID, limit) {
10
- if (!guildID) throw new Error('[XP] Guild ID was not provided.');
11
+ if (!guildID) throw new Error("[XP] Guild ID was not provided.");
11
12
 
12
13
  let g = client.guilds.cache.get(guildID);
13
- if (!g) throw new Error('[XP] Guild was not found.');
14
+ if (!g) throw new Error("[XP] Guild was not found.");
14
15
 
15
- let leaderboard = await levels.find({guild: guildID}).sort([['xp', 'descending']]);
16
+ let leaderboard = await levels.find({guild: guildID}).sort([["xp", "descending"]]);
16
17
 
17
18
  let led = [];
18
19
 
19
20
  function shortener(count) {
20
- const COUNT_ABBRS = ['', 'k', 'M', 'T'];
21
+ const COUNT_ABBRS = ["", "k", "M", "T"];
21
22
 
22
23
  const i = 0 === count ? count : Math.floor(Math.log(count) / Math.log(1000));
23
24
  let result = parseFloat((count / Math.pow(1000, i)).toFixed(2));
@@ -27,13 +28,11 @@ async function leaderboard(client, guildID, limit) {
27
28
 
28
29
  const led2 = leaderboard.map(async (key) => {
29
30
  const user = await g.members.fetch(key.user).catch(() => null);
30
- if (!user) return levels.deleteOne({user: key.user, guild: guildID});
31
+ if (!user && options?.auto_purge) return levels.deleteOne({user: key.user, guild: guildID});
31
32
  if (key.xp === 0) return;
32
- let pos = leaderboard.indexOf(key) + 1;
33
33
 
34
- if (limit) {
35
- if (pos > Number(limit)) return;
36
- }
34
+ let pos = leaderboard.indexOf(key) + 1;
35
+ if (limit && pos > Number(limit)) return;
37
36
 
38
37
  led.push({
39
38
  guildID: key.guild,