simply-xp 1.3.0 → 1.3.4

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
@@ -2,7 +2,7 @@
2
2
 
3
3
  <h2 style="font-size:2.5rem;" align="center">Simply-XP</h2>
4
4
 
5
- <h2 align="center">A Simple, Easy and Beginner friendly XP System. <br>Uses Discord.js v13<br><br>Developed by Rahuletto#0243 & Maintained by Abadima#6356</h2>
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
6
 
7
7
  <br>
8
8
  <p align="center">
@@ -28,12 +28,12 @@ yarn add simply-xp
28
28
 
29
29
  <br>
30
30
 
31
- # 🎉 What's New 🎉
31
+ # 🎉 Recent Updates 🎉
32
+
33
+ - Fixed Various Bugs
34
+ - Updated `Chart.js`
35
+ - D.JS v14 Support
32
36
 
33
- - We have patched various issues
34
- - Switched to the true **Chart.js** package!
35
- - You no longer need to use D.JS for this package, alternatives can work!
36
- - We have also updated our website guide! We hope you find it useful 😊
37
37
 
38
38
  # But Why ?
39
39
 
@@ -54,4 +54,4 @@ yarn add simply-xp
54
54
  <h1>👥 Contact us | Support</h1>
55
55
  <p>
56
56
  <a href="https://discord.gg/3JzDV9T5Fn"><img src="https://invidget.switchblade.xyz/3JzDV9T5Fn" /></a>
57
- </p>
57
+ </p>
package/package.json CHANGED
@@ -1,12 +1,11 @@
1
1
  {
2
2
  "name": "simply-xp",
3
- "version": "1.3.0",
3
+ "version": "1.3.4",
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",
9
- "prepare": "husky install"
8
+ "test": "echo \"Error: no test specified\" && exit 1"
10
9
  },
11
10
  "author": "Rahuletto",
12
11
  "keywords": [
@@ -40,13 +39,9 @@
40
39
  "url": "https://github.com/Rahuletto/simply-xp"
41
40
  },
42
41
  "dependencies": {
43
- "canvas": "^2.9.3",
44
- "chart.js": "^3.8.0",
45
- "mongoose": "^6.0.15"
46
- },
47
- "devDependencies": {
48
- "husky": "^7.0.4",
49
- "pretty-quick": "^3.1.1"
42
+ "@napi-rs/canvas": "^0.1.28",
43
+ "chart.js": "^3.9.1",
44
+ "mongoose": "^6.2.11"
50
45
  },
51
46
  "peerDependencies": {
52
47
  "discord.js": "*"
package/src/addLevel.js CHANGED
@@ -39,7 +39,7 @@ async function addLevel(message, userID, guildID, level) {
39
39
  }
40
40
  let level1 = user.level
41
41
 
42
- user.level += 1
42
+ user.level += parseFloat(level)
43
43
  user.xp = (user.level * 10) ** 2
44
44
 
45
45
  await user
package/src/rank.js CHANGED
@@ -46,11 +46,11 @@ async function rank(message, userID, guildID, options = []) {
46
46
 
47
47
  async function rankCard(message, options = []) {
48
48
  try {
49
- const Canvas = require('canvas')
50
- const { registerFont } = require('canvas')
51
- registerFont(join(__dirname, 'Fonts', 'Baloo-Regular.ttf'), {
52
- family: 'Sans Serif'
53
- })
49
+ const Canvas = require('@napi-rs/canvas')
50
+ Canvas.GlobalFonts.registerFromPath(
51
+ join(__dirname, 'Fonts', 'Baloo-Regular.ttf'),
52
+ 'Sans Serif'
53
+ )
54
54
 
55
55
  function shortener(count) {
56
56
  const COUNT_ABBRS = [
@@ -98,12 +98,13 @@ async function rank(message, userID, guildID, options = []) {
98
98
  let BackgroundRadius = '20',
99
99
  BackGroundImg =
100
100
  options.background ||
101
- 'https://pinebanana.files.wordpress.com/2011/04/rainbow.jpg',
101
+ 'https://i.ibb.co/QQvMqf7/gradient.jpg',
102
102
  AttachmentName = 'rank.png',
103
+ AttachmentDesc = 'Rank Card',
103
104
  Username = noSymbols(name),
104
105
  AvatarRoundRadius = '50',
105
106
  DrawLayerColor = '#000000',
106
- DrawLayerOpacity = '0.4',
107
+ DrawLayerOpacity = 0.4,
107
108
  BoxColor = options.color || '#096DD1',
108
109
  LevelBarFill = options.lvlbar || '#ffffff',
109
110
  LevelBarBackground = options.lvlbarBg || '#ffffff',
@@ -164,46 +165,44 @@ async function rank(message, userID, guildID, options = []) {
164
165
  ctx.closePath()
165
166
  }
166
167
 
167
- let avatar = await Canvas.loadImage(
168
- member.displayAvatarURL({ dynamic: true, format: 'png' })
169
- )
168
+ let avatar = await Canvas.loadImage(member.displayAvatarURL())
170
169
  ctx.save()
171
- RoundedBox(ctx, 40 + 30, 30, 180, 180, Number(AvatarRoundRadius))
170
+ RoundedBox(ctx, 70, 30, 180, 180, Number(AvatarRoundRadius))
172
171
  ctx.strokeStyle = BoxColor
173
- ctx.lineWidth = '10'
172
+ ctx.lineWidth = 15
174
173
  ctx.stroke()
175
174
  ctx.clip()
176
- ctx.drawImage(avatar, 40 + 30, 30, 180, 180)
175
+ ctx.drawImage(avatar, 70, 30, 180, 180)
177
176
  ctx.restore()
178
177
 
179
178
  ctx.save()
180
- RoundedBox(ctx, 40 + 30, 30 + 180 + 30 + 50 + 30, 180, 50, 20)
179
+ RoundedBox(ctx, 70, 240 + 50 + 30, 180, 50, 20)
181
180
  ctx.strokeStyle = '#BFC85A22'
182
181
  ctx.stroke()
183
182
  ctx.clip()
184
183
  ctx.fillStyle = BoxColor
185
- ctx.globalAlpha = '1'
186
- ctx.fillRect(40 + 30, 30 + 180 + 30 + 50 + 30, 180, 50)
184
+ ctx.globalAlpha = 1
185
+ ctx.fillRect(70, 320, 180, 50)
187
186
  ctx.globalAlpha = 1
188
187
  ctx.fillStyle = '#ffffff'
189
188
  ctx.font = '32px "Sans Serif"'
190
189
  ctx.textAlign = 'center'
191
- ctx.fillText(TextEXP, 40 + 30 + 180 / 2, 30 + 180 + 30 + 30 + 50 + 38)
190
+ ctx.fillText(TextEXP, 160, 358)
192
191
  ctx.restore()
193
192
 
194
193
  ctx.save()
195
- RoundedBox(ctx, 40 + 30, 30 + 180 + 30, 180, 50, 20)
194
+ RoundedBox(ctx, 70, 240, 180, 50, 20)
196
195
  ctx.strokeStyle = '#BFC85A22'
197
196
  ctx.stroke()
198
197
  ctx.clip()
199
198
  ctx.fillStyle = BoxColor
200
- ctx.globalAlpha = '1'
201
- ctx.fillRect(40 + 30, 30 + 180 + 30, 180, 50, 50)
199
+ ctx.globalAlpha = 1
200
+ ctx.fillRect(70, 240, 180, 50, 50)
202
201
  ctx.globalAlpha = 1
203
202
  ctx.fillStyle = '#ffffff'
204
203
  ctx.font = '32px "Sans Serif"'
205
204
  ctx.textAlign = 'center'
206
- ctx.fillText(LvlText, 40 + 30 + 180 / 2, 30 + 180 + 30 + 38)
205
+ ctx.fillText(LvlText, 70 + 180 / 2, 278)
207
206
  ctx.restore()
208
207
 
209
208
  ctx.save()
@@ -225,7 +224,7 @@ async function rank(message, userID, guildID, options = []) {
225
224
  ctx.shadowOffsetX = 1
226
225
  ctx.shadowOffsetY = 1
227
226
  ctx.font = '55px "Sans Serif"'
228
- ctx.fillText('#' + Rank, canvas.width - 50 - 5, 80)
227
+ ctx.fillText('#' + Rank, canvas.width - 55, 80)
229
228
  ctx.restore()
230
229
 
231
230
  ctx.save()
@@ -236,8 +235,8 @@ async function rank(message, userID, guildID, options = []) {
236
235
  ctx.fillStyle = '#ffffff'
237
236
  ctx.font = `${fsiz} "Sans Serif"`
238
237
  ctx.textAlign = 'center'
239
- ctx.fillText(message.guild.name, 60 + 660, 355)
240
- ctx.globalAlpha = '0.2'
238
+ ctx.fillText(message.guild.name, 720, 355)
239
+ ctx.globalAlpha = 0.2
241
240
  ctx.fillRect(390, 305, 660, 70)
242
241
  ctx.restore()
243
242
 
@@ -247,7 +246,7 @@ async function rank(message, userID, guildID, options = []) {
247
246
  ctx.stroke()
248
247
  ctx.clip()
249
248
  ctx.fillStyle = LevelBarBackground
250
- ctx.globalAlpha = '0.2'
249
+ ctx.globalAlpha = 0.2
251
250
  ctx.fillRect(390, 145, 660, 50, 50)
252
251
  ctx.restore()
253
252
 
@@ -260,14 +259,14 @@ async function rank(message, userID, guildID, options = []) {
260
259
  ctx.stroke()
261
260
  ctx.clip()
262
261
  ctx.fillStyle = LevelBarFill
263
- ctx.globalAlpha = '0.5'
262
+ ctx.globalAlpha = 0.5
264
263
  ctx.fillRect(390, 145, progress, 50, 50)
265
264
  ctx.restore()
266
265
 
267
266
  ctx.save()
268
267
  ctx.textAlign = 'left'
269
268
  ctx.fillStyle = '#ffffff'
270
- ctx.globalAlpha = '0.8'
269
+ ctx.globalAlpha = 0.8
271
270
  ctx.font = '30px "Sans Serif"'
272
271
  ctx.fillText('Next Level: ' + shortener(NeededXP) + ' XP', 390, 230)
273
272
  ctx.restore()
@@ -284,6 +283,7 @@ async function rank(message, userID, guildID, options = []) {
284
283
 
285
284
  const attachment = {
286
285
  attachment: canvas.toBuffer(),
286
+ description: AttachmentDesc,
287
287
  name: AttachmentName
288
288
  }
289
289
  return attachment
@@ -293,4 +293,4 @@ async function rank(message, userID, guildID, options = []) {
293
293
  }
294
294
  }
295
295
 
296
- module.exports = rank
296
+ module.exports = rank
package/src/roleSetup.js CHANGED
@@ -109,8 +109,8 @@ class roleSetup {
109
109
  gid: guildID
110
110
  })
111
111
 
112
- if (!rol || rol.length === 0) return
113
- rol = rol[0].lvlrole.find((item) => item.lvl === level) || undefined
112
+ if (!rol || !rol.length) return
113
+ rol = rol[0].lvlrole.filter((i) => i.lvl == level) || undefined
114
114
 
115
115
  if (rol) {
116
116
  return rol