simply-xp 1.3.0-dev-1 → 1.3.0-dev-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/package.json +2 -2
- package/simplyxp.js +1 -3
- package/src/charts.js +52 -47
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "simply-xp",
|
|
3
|
-
"version": "1.3.0-dev-
|
|
3
|
+
"version": "1.3.0-dev-2",
|
|
4
4
|
"description": "A Simple, Easy and Beginner Friendly XP System",
|
|
5
5
|
"main": "simplyxp.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"canvas": "^2.9.3",
|
|
44
|
-
"chart.js
|
|
44
|
+
"chart.js": "^3.8.0",
|
|
45
45
|
"mongoose": "^6.0.15"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
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/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
|
|
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
|
-
|
|
26
|
-
.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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:
|
|
82
|
+
attachment: ctx.toBuffer(),
|
|
78
83
|
name: 'chart.png'
|
|
79
84
|
}
|
|
80
85
|
return attachment
|