simply-xp 1.3.5-beta-1 → 1.3.5-beta-3

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/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "simply-xp",
3
- "version": "1.3.5-beta-1",
3
+ "version": "1.3.5-beta-3",
4
4
  "description": "A Simple, Easy and Beginner Friendly XP System",
5
5
  "main": "simplyxp.js",
6
6
  "typings": "index.d.ts",
7
7
  "scripts": {
8
- "test": "echo \"Error: no test specified\" && exit 1"
8
+ "test": "echo \"Error: no test specified\" && exit 1",
9
+ "beta": "npm publish --tag beta"
9
10
  },
10
11
  "author": "Rahuletto",
11
12
  "keywords": [
@@ -41,7 +42,7 @@
41
42
  "dependencies": {
42
43
  "@napi-rs/canvas": "^0.1.30",
43
44
  "chart.js": "^3.9.1",
44
- "mongoose": "^6.6.5"
45
+ "mongoose": "^6.8.1"
45
46
  },
46
47
  "peerDependencies": {
47
48
  "discord.js": ">=13.12.0"
package/src/connect.js CHANGED
@@ -7,14 +7,16 @@ const mongoose = require('mongoose')
7
7
 
8
8
  async function connect(db, options = []) {
9
9
  if (!db) throw new Error('[XP] Database URL was not provided')
10
-
10
+ mongoose.set('strictQuery', true);
11
+
11
12
  mongoose.connect(db, {
12
13
  useNewUrlParser: true,
13
14
  useUnifiedTopology: true
14
15
  })
15
16
 
17
+
16
18
  if (options.notify === false) return
17
19
  else return console.log('{ XP } Database Connected')
18
20
  }
19
21
 
20
- module.exports = connect
22
+ module.exports = connect
@@ -12,11 +12,8 @@ async function leaderboard(client, guildID, limit) {
12
12
  let g = client.guilds.cache.get(guildID)
13
13
 
14
14
  let leaderboard = await levels
15
- .find({
16
- guild: guildID
17
- })
15
+ .find({ guild: guildID })
18
16
  .sort([['xp', 'descending']])
19
- .exec()
20
17
 
21
18
  let led = []
22
19
 
@@ -29,9 +26,10 @@ async function leaderboard(client, guildID, limit) {
29
26
  return result
30
27
  }
31
28
 
32
- leaderboard.map((key) => {
33
- let user = g.members.cache.get(key.user)
29
+ var led2 = leaderboard.map(async (key) => {
30
+ let user = await g.members.fetch(key.user).catch(() => undefined)
34
31
  if (key.xp === 0) return
32
+ if (!user) return
35
33
 
36
34
  let pos =
37
35
  leaderboard.findIndex(
@@ -42,28 +40,18 @@ async function leaderboard(client, guildID, limit) {
42
40
  if (pos > Number(limit)) return
43
41
  }
44
42
 
45
- let shortXP = shortener(key.xp)
46
-
47
- if (!user) return
48
-
49
43
  led.push({
50
44
  guildID: key.guild,
51
45
  userID: key.user,
52
46
  xp: key.xp,
53
- shortxp: shortXP,
47
+ shortxp: shortener(key.xp),
54
48
  level: key.level,
55
49
  position: pos,
56
50
  username: user.user.username,
57
51
  tag: user.user.tag
58
52
  })
59
53
  })
60
-
61
- led = led.filter(
62
- (thing, index, self) =>
63
- index === self.findIndex((t) => t.userID === thing.userID)
64
- )
65
-
66
- return led
54
+ return Promise.all(led2).then(() => led)
67
55
  }
68
56
 
69
- module.exports = leaderboard
57
+ module.exports = leaderboard