simply-xp 1.3.0-dev-1 → 1.3.2

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,55 +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>Uses Discord.js v13<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
- # 🎉 What's New 🎉
32
-
33
- - We have patched known issues, and we continue to monitor changes!
34
- - Our rank card has a new font applied
35
-
36
- # But Why ?
37
-
38
- - Easiest XP System in Discord.js
39
- - Fastest Support ever
40
- - Rank Card Maker
41
- - Beginner Friendly
42
- - Easier than other XP Systems
43
- - Inbuilt Auto Roles system
44
- - Flexible and simple at the same time
45
-
46
- <br>
47
-
48
- ## **Need Help ? Join the [Discord Server](https://discord.gg/3JzDV9T5Fn)**
49
-
50
- <br>
51
-
52
- <h1>👥 Contact us | Support</h1>
53
- <p>
54
- <a href="https://discord.gg/3JzDV9T5Fn"><img src="https://invidget.switchblade.xyz/3JzDV9T5Fn" /></a>
55
- </p>
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>Uses Discord.js v13<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
+ # 🎉 What's New 🎉
32
+
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
+
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
+ </p>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simply-xp",
3
- "version": "1.3.0-dev-1",
3
+ "version": "1.3.2",
4
4
  "description": "A Simple, Easy and Beginner Friendly XP System",
5
5
  "main": "simplyxp.js",
6
6
  "typings": "index.d.ts",
@@ -40,12 +40,12 @@
40
40
  "url": "https://github.com/Rahuletto/simply-xp"
41
41
  },
42
42
  "dependencies": {
43
- "canvas": "^2.9.3",
44
- "chart.js-image": "^6.0.3",
43
+ "@napi-rs/canvas": "^0.1.25",
44
+ "chart.js": "^3.8.1",
45
45
  "mongoose": "^6.0.15"
46
46
  },
47
47
  "devDependencies": {
48
- "husky": "^7.0.0",
48
+ "husky": "^7.0.4",
49
49
  "pretty-quick": "^3.1.1"
50
50
  },
51
51
  "peerDependencies": {
package/simplyxp.js CHANGED
@@ -1,9 +1,7 @@
1
1
  try {
2
2
  require('discord.js')
3
3
  } catch (e) {
4
- console.warn(
5
- '[XP] DJS V13 is recommended for this package. \n Debug Notice: \n' + e
6
- )
4
+ console.warn('[XP] Discord.js is recommended for this package.')
7
5
  }
8
6
 
9
7
  module.exports.roleSetup = require('./src/roleSetup')
package/src/addLevel.js CHANGED
@@ -39,8 +39,8 @@ async function addLevel(message, userID, guildID, level) {
39
39
  }
40
40
  let level1 = user.level
41
41
 
42
- user.xp += (level * 10) ** 2
43
- user.level += Math.floor(0.1 * Math.sqrt(user.xp))
42
+ user.level += 1
43
+ user.xp = (user.level * 10) ** 2
44
44
 
45
45
  await user
46
46
  .save()
package/src/charts.js CHANGED
@@ -7,12 +7,14 @@ let leaderboard = require('./leaderboard')
7
7
 
8
8
  async function charts(message, options = []) {
9
9
  let { client } = message
10
- const ChartJSImage = require('chart.js-image')
10
+ const ChartJS = require('chart.js')
11
+ const Canvas = require('canvas')
11
12
 
12
13
  let data = []
13
14
  let pos = options?.position || 5
14
15
  let uzern = []
15
16
 
17
+ let ctx = Canvas.createCanvas(950, 526)
16
18
  await leaderboard(client, message.guild.id).then((e) => {
17
19
  e.forEach((m) => {
18
20
  if (m.position <= pos) {
@@ -22,59 +24,62 @@ async function charts(message, options = []) {
22
24
  })
23
25
  })
24
26
 
25
- const line_chart = ChartJSImage()
26
- .chart({
27
- type: options.type || 'bar',
28
- data: {
29
- labels: uzern,
30
- datasets: [
31
- {
32
- label: 'Leaderboards',
33
- data: data,
34
- backgroundColor: [
35
- 'rgba(255, 99, 132, 0.5)',
36
- 'rgba(255, 159, 64, 0.5)',
37
- 'rgba(255, 205, 86, 0.5)',
38
- 'rgba(75, 192, 192, 0.5)',
39
- 'rgba(54, 162, 235, 0.5)',
40
- 'rgba(153, 102, 255, 0.5)',
41
- 'rgb(201, 203, 207, 0.5)'
42
- ],
43
- borderColor: [
44
- 'rgb(255, 99, 132)',
45
- 'rgb(255, 159, 64)',
46
- 'rgb(255, 205, 86)',
47
- 'rgb(75, 192, 192)',
48
- 'rgb(54, 162, 235)',
49
- 'rgb(153, 102, 255)',
50
- 'rgb(201, 203, 207)'
51
- ],
52
- borderWidth: 2
53
- }
54
- ]
55
- },
56
- options: {
57
- plugins: {
58
- legend: {
59
- labels: {
60
- font: {
61
- family: 'Courier New'
62
- }
63
- }
64
- }
65
- },
27
+ new ChartJS(ctx, {
28
+ type: options.type || 'bar',
29
+ data: {
30
+ labels: uzern,
31
+ datasets: [
32
+ {
33
+ label: 'Leaderboards',
34
+ data: data,
35
+ backgroundColor: [
36
+ 'rgba(255, 99, 132, 0.5)',
37
+ 'rgba(255, 159, 64, 0.5)',
38
+ 'rgba(255, 205, 86, 0.5)',
39
+ 'rgba(75, 192, 192, 0.5)',
40
+ 'rgba(54, 162, 235, 0.5)',
41
+ 'rgba(153, 102, 255, 0.5)',
42
+ 'rgb(201, 203, 207, 0.5)'
43
+ ],
44
+ borderColor: [
45
+ 'rgb(255, 99, 132)',
46
+ 'rgb(255, 159, 64)',
47
+ 'rgb(255, 205, 86)',
48
+ 'rgb(75, 192, 192)',
49
+ 'rgb(54, 162, 235)',
50
+ 'rgb(153, 102, 255)',
51
+ 'rgb(201, 203, 207)'
52
+ ],
53
+ borderWidth: 2
54
+ }
55
+ ]
56
+ },
57
+ options: {
58
+ animation: false,
59
+ plugins: {
66
60
  title: {
67
61
  display: true,
68
62
  text: 'XP Datasheet'
69
63
  }
70
64
  }
71
- })
72
- .backgroundColor(options.background || '#2F3136')
73
- .width(940) // 500px
74
- .height(520) // 300px
65
+ },
66
+ plugins: [
67
+ {
68
+ id: 'simply-xp',
69
+ beforeDraw: (chart) => {
70
+ const ctx = chart.canvas.getContext('2d')
71
+ ctx.save()
72
+ ctx.globalCompositeOperation = 'destination-over'
73
+ ctx.fillStyle = options.background || '#2F3136'
74
+ ctx.fillRect(0, 0, chart.width, chart.height)
75
+ ctx.restore()
76
+ }
77
+ }
78
+ ]
79
+ }).update()
75
80
 
76
81
  const attachment = {
77
- attachment: line_chart.toURL(),
82
+ attachment: ctx.toBuffer(),
78
83
  name: 'chart.png'
79
84
  }
80
85
  return attachment
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 = [
@@ -100,10 +100,11 @@ async function rank(message, userID, guildID, options = []) {
100
100
  options.background ||
101
101
  'https://pinebanana.files.wordpress.com/2011/04/rainbow.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,13 +165,11 @@ 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
170
  RoundedBox(ctx, 40 + 30, 30, 180, 180, Number(AvatarRoundRadius))
172
171
  ctx.strokeStyle = BoxColor
173
- ctx.lineWidth = '10'
172
+ ctx.lineWidth = 10
174
173
  ctx.stroke()
175
174
  ctx.clip()
176
175
  ctx.drawImage(avatar, 40 + 30, 30, 180, 180)
@@ -182,7 +181,7 @@ async function rank(message, userID, guildID, options = []) {
182
181
  ctx.stroke()
183
182
  ctx.clip()
184
183
  ctx.fillStyle = BoxColor
185
- ctx.globalAlpha = '1'
184
+ ctx.globalAlpha = 1
186
185
  ctx.fillRect(40 + 30, 30 + 180 + 30 + 50 + 30, 180, 50)
187
186
  ctx.globalAlpha = 1
188
187
  ctx.fillStyle = '#ffffff'
@@ -197,7 +196,7 @@ async function rank(message, userID, guildID, options = []) {
197
196
  ctx.stroke()
198
197
  ctx.clip()
199
198
  ctx.fillStyle = BoxColor
200
- ctx.globalAlpha = '1'
199
+ ctx.globalAlpha = 1
201
200
  ctx.fillRect(40 + 30, 30 + 180 + 30, 180, 50, 50)
202
201
  ctx.globalAlpha = 1
203
202
  ctx.fillStyle = '#ffffff'
@@ -237,7 +236,7 @@ async function rank(message, userID, guildID, options = []) {
237
236
  ctx.font = `${fsiz} "Sans Serif"`
238
237
  ctx.textAlign = 'center'
239
238
  ctx.fillText(message.guild.name, 60 + 660, 355)
240
- ctx.globalAlpha = '0.2'
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