simply-xp 1.3.0 → 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/package.json +3 -3
- package/src/rank.js +16 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "simply-xp",
|
|
3
|
-
"version": "1.3.
|
|
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,8 +40,8 @@
|
|
|
40
40
|
"url": "https://github.com/Rahuletto/simply-xp"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"canvas": "^
|
|
44
|
-
"chart.js": "^3.8.
|
|
43
|
+
"@napi-rs/canvas": "^0.1.25",
|
|
44
|
+
"chart.js": "^3.8.1",
|
|
45
45
|
"mongoose": "^6.0.15"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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
|