simply-xp 1.2.0-test-1 → 1.3.0-dev-1

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/src/rank.js CHANGED
@@ -1,282 +1,296 @@
1
- let Discord = require('discord.js')
2
- const levels = require('../src/models/level.js')
3
- const { join } = require('path')
4
-
5
- /**
6
- * @param {Discord.Message} message
7
- * @param {string} userID
8
- * @param {string} guildID
9
- * @param {import('../index').rankOptions} options
10
- */
11
-
12
- async function rank(message, userID, guildID, options = []) {
13
- if (!userID) throw new Error('[XP] User ID was not provided.')
14
-
15
- if (!guildID) throw new Error('[XP] Guild ID was not provided.')
16
-
17
- const user = await levels.findOne({
18
- user: userID,
19
- guild: guildID
20
- })
21
- if (!user) throw new Error('[XP] NO_DATA | User has no XP data.')
22
-
23
- const leaderboard = await levels
24
- .find({
25
- guild: guildID
26
- })
27
- .sort([['xp', 'descending']])
28
- .exec()
29
-
30
- user.position = leaderboard.findIndex((i) => i.user === userID) + 1
31
-
32
- let targetxp = user.level + 1
33
-
34
- let target = targetxp * targetxp * 100
35
-
36
- return rankCard(message, {
37
- level: user.level,
38
- currentXP: user.xp,
39
- neededXP: target,
40
- rank: user.position,
41
- background: options.background,
42
- color: options.color,
43
- lvlbar: options.lvlbar,
44
- lvlbarBg: options.lvlbarBg,
45
- member: message.guild.members.cache.get(userID)?.user
46
- })
47
-
48
- async function rankCard(message, options = []) {
49
- try {
50
- const Canvas = require('canvas')
51
- const { registerFont } = require('canvas')
52
- registerFont(join(__dirname, 'Fonts', 'Baloo-Regular.ttf'), { family: 'Sans Serif' })
53
-
54
- function shortener(count) {
55
- const COUNT_ABBRS = ['', 'k', 'M', 'B', 'T', 'Q', 'Q+', 'S', 'S+', 'O', 'N', 'D', 'U']
56
-
57
- const i =
58
- 0 === count ? count : Math.floor(Math.log(count) / Math.log(1000))
59
- let result = parseFloat((count / Math.pow(1000, i)).toFixed(2))
60
- result += `${COUNT_ABBRS[i]}`
61
- return result
62
- }
63
-
64
- const member = options.member
65
-
66
- const canvas = Canvas.createCanvas(1080, 400),
67
- ctx = canvas.getContext('2d')
68
-
69
- const name = member.tag
70
- const noSymbols = (string) => string.replace(/[\u007f-\uffff]/g, '')
71
-
72
- let fsiz = '45px'
73
- if (message.guild.name.length >= 23) {
74
- fsiz = '38px'
75
- }
76
- if (message.guild.name.length >= 40) {
77
- fsiz = '28px'
78
- }
79
- if (message.guild.name.length >= 63) {
80
- fsiz = '22px'
81
- }
82
-
83
- let BackgroundRadius = '20',
84
- BackGroundImg =
85
- options.background ||
86
- 'https://pinebanana.files.wordpress.com/2011/04/rainbow.jpg',
87
- AttachmentName = 'rank.png',
88
- Username = noSymbols(name),
89
- AvatarRoundRadius = '50',
90
- DrawLayerColor = '#000000',
91
- DrawLayerOpacity = '0.4',
92
- BoxColor = options.color || '#096DD1',
93
- LevelBarFill = options.lvlbar || '#ffffff',
94
- LevelBarBackground = options.lvlbarBg || '#ffffff',
95
- Rank = options.rank,
96
- TextEXP = shortener(options.currentXP) + ' XP',
97
- LvlText = `Level ${shortener(options.level)}`,
98
- BarRadius = '20',
99
- TextXpNeded = '{current}/{needed}',
100
- CurrentXP = options.currentXP,
101
- NeededXP = options.neededXP
102
-
103
- ctx.beginPath()
104
- ctx.moveTo(0 + Number(BackgroundRadius), 0)
105
- ctx.lineTo(0 + 1080 - Number(BackgroundRadius), 0)
106
- ctx.quadraticCurveTo(0 + 1080, 0, 0 + 1080, 0 + Number(BackgroundRadius))
107
- ctx.lineTo(0 + 1080, 0 + 400 - Number(BackgroundRadius))
108
- ctx.quadraticCurveTo(
109
- 0 + 1080,
110
- 0 + 400,
111
- 0 + 1080 - Number(BackgroundRadius),
112
- 0 + 400
113
- )
114
-
115
- ctx.lineTo(0 + Number(BackgroundRadius), 0 + 400)
116
- ctx.quadraticCurveTo(0, 0 + 400, 0, 0 + 400 - Number(BackgroundRadius))
117
- ctx.lineTo(0, 0 + Number(BackgroundRadius))
118
- ctx.quadraticCurveTo(0, 0, 0 + Number(BackgroundRadius), 0)
119
- ctx.closePath()
120
- ctx.clip()
121
- ctx.fillStyle = '#000000'
122
- ctx.fillRect(0, 0, 1080, 400)
123
- let background = await Canvas.loadImage(BackGroundImg)
124
- ctx.globalAlpha = 0.7
125
- ctx.drawImage(background, 0, 0, 1080, 400)
126
- ctx.restore()
127
-
128
- ctx.fillStyle = DrawLayerColor
129
- ctx.globalAlpha = DrawLayerOpacity
130
- ctx.fillRect(40, 0, 240, canvas.height)
131
- ctx.globalAlpha = 1
132
-
133
- function RoundedBox(ctx, x, y, width, height, radius) {
134
- ctx.beginPath()
135
- ctx.moveTo(x + radius, y)
136
- ctx.lineTo(x + width - radius, y)
137
- ctx.quadraticCurveTo(x + width, y, x + width, y + radius)
138
- ctx.lineTo(x + width, y + height - radius)
139
- ctx.quadraticCurveTo(
140
- x + width,
141
- y + height,
142
- x + width - radius,
143
- y + height
144
- )
145
- ctx.lineTo(x + radius, y + height)
146
- ctx.quadraticCurveTo(x, y + height, x, y + height - radius)
147
- ctx.lineTo(x, y + radius)
148
- ctx.quadraticCurveTo(x, y, x + radius, y)
149
- ctx.closePath()
150
- }
151
-
152
- let avatar = await Canvas.loadImage(
153
- member.displayAvatarURL({ dynamic: true, format: 'png' })
154
- )
155
- ctx.save()
156
- RoundedBox(ctx, 40 + 30, 30, 180, 180, Number(AvatarRoundRadius))
157
- ctx.strokeStyle = BoxColor
158
- ctx.lineWidth = '10'
159
- ctx.stroke()
160
- ctx.clip()
161
- ctx.drawImage(avatar, 40 + 30, 30, 180, 180)
162
- ctx.restore()
163
-
164
- ctx.save()
165
- RoundedBox(ctx, 40 + 30, 30 + 180 + 30 + 50 + 30, 180, 50, 20)
166
- ctx.strokeStyle = '#BFC85A22'
167
- ctx.stroke()
168
- ctx.clip()
169
- ctx.fillStyle = BoxColor
170
- ctx.globalAlpha = '1'
171
- ctx.fillRect(40 + 30, 30 + 180 + 30 + 50 + 30, 180, 50)
172
- ctx.globalAlpha = 1
173
- ctx.fillStyle = '#ffffff'
174
- ctx.font = '32px "Sans Serif"'
175
- ctx.textAlign = 'center'
176
- ctx.fillText(TextEXP, 40 + 30 + 180 / 2, 30 + 180 + 30 + 30 + 50 + 38)
177
- ctx.restore()
178
-
179
- ctx.save()
180
- RoundedBox(ctx, 40 + 30, 30 + 180 + 30, 180, 50, 20)
181
- ctx.strokeStyle = '#BFC85A22'
182
- ctx.stroke()
183
- ctx.clip()
184
- ctx.fillStyle = BoxColor
185
- ctx.globalAlpha = '1'
186
- ctx.fillRect(40 + 30, 30 + 180 + 30, 180, 50, 50)
187
- ctx.globalAlpha = 1
188
- ctx.fillStyle = '#ffffff'
189
- ctx.font = '32px "Sans Serif"'
190
- ctx.textAlign = 'center'
191
- ctx.fillText(LvlText, 40 + 30 + 180 / 2, 30 + 180 + 30 + 38)
192
- ctx.restore()
193
-
194
- ctx.save()
195
- ctx.textAlign = 'left'
196
- ctx.fillStyle = '#ffffff'
197
- ctx.shadowColor = '#000000'
198
- ctx.shadowBlur = 15
199
- ctx.shadowOffsetX = 1
200
- ctx.shadowOffsetY = 1
201
- ctx.font = '39px "Sans Serif"'
202
- ctx.fillText(Username, 390, 80)
203
- ctx.restore()
204
-
205
- ctx.save()
206
- ctx.textAlign = 'right'
207
- ctx.fillStyle = '#ffffff'
208
- ctx.shadowColor = '#000000'
209
- ctx.shadowBlur = 15
210
- ctx.shadowOffsetX = 1
211
- ctx.shadowOffsetY = 1
212
- ctx.font = '55px "Sans Serif"'
213
- ctx.fillText('#' + Rank, canvas.width - 50 - 5, 80)
214
- ctx.restore()
215
-
216
- ctx.save()
217
- RoundedBox(ctx, 390, 305, 660, 70, Number(20))
218
- ctx.strokeStyle = '#BFC85A22'
219
- ctx.stroke()
220
- ctx.clip()
221
- ctx.fillStyle = '#ffffff'
222
- ctx.font = `${fsiz} "Sans Serif"`
223
- ctx.textAlign = 'center'
224
- ctx.fillText(message.guild.name, 60 + 660, 355)
225
- ctx.globalAlpha = '0.2'
226
- ctx.fillRect(390, 305, 660, 70)
227
- ctx.restore()
228
-
229
- ctx.save()
230
- RoundedBox(ctx, 390, 145, 660, 50, Number(BarRadius))
231
- ctx.strokeStyle = '#BFC85A22'
232
- ctx.stroke()
233
- ctx.clip()
234
- ctx.fillStyle = LevelBarBackground
235
- ctx.globalAlpha = '0.2'
236
- ctx.fillRect(390, 145, 660, 50, 50)
237
- ctx.restore()
238
-
239
- const percent = (100 * CurrentXP) / NeededXP
240
- const progress = (percent * 660) / 100
241
-
242
- ctx.save()
243
- RoundedBox(ctx, 390, 145, progress, 50, Number(BarRadius))
244
- ctx.strokeStyle = '#BFC85A22'
245
- ctx.stroke()
246
- ctx.clip()
247
- ctx.fillStyle = LevelBarFill
248
- ctx.globalAlpha = '0.5'
249
- ctx.fillRect(390, 145, progress, 50, 50)
250
- ctx.restore()
251
-
252
- ctx.save()
253
- ctx.textAlign = 'left'
254
- ctx.fillStyle = '#ffffff'
255
- ctx.globalAlpha = '0.8'
256
- ctx.font = '30px "Sans Serif"'
257
- ctx.fillText('Next Level: ' + shortener(NeededXP) + ' XP', 390, 230)
258
- ctx.restore()
259
-
260
- const latestXP = Number(CurrentXP) - Number(NeededXP)
261
- const textXPEdited = TextXpNeded.replace(/{needed}/g, shortener(NeededXP))
262
- .replace(/{current}/g, shortener(CurrentXP))
263
- .replace(/{latest}/g, latestXP)
264
- ctx.textAlign = 'center'
265
- ctx.fillStyle = '#474747'
266
- ctx.globalAlpha = 1
267
- ctx.font = '30px "Sans Serif"'
268
- ctx.fillText(textXPEdited, 730, 180)
269
-
270
- const attachment = new Discord.MessageAttachment(
271
- canvas.toBuffer(),
272
- AttachmentName
273
- )
274
-
275
- return attachment
276
- } catch (err) {
277
- console.log(`[XP] Error Occured. | rankCard | Error: ${err.stack}`)
278
- }
279
- }
280
- }
281
-
282
- module.exports = rank
1
+ const levels = require('../src/models/level.js')
2
+ const { join } = require('path')
3
+
4
+ /**
5
+ * @param {Discord.Message} message
6
+ * @param {string} userID
7
+ * @param {string} guildID
8
+ * @param {import('../index').rankOptions} options
9
+ */
10
+
11
+ async function rank(message, userID, guildID, options = []) {
12
+ if (!userID) throw new Error('[XP] User ID was not provided.')
13
+
14
+ if (!guildID) throw new Error('[XP] Guild ID was not provided.')
15
+
16
+ const user = await levels.findOne({
17
+ user: userID,
18
+ guild: guildID
19
+ })
20
+ if (!user) throw new Error('[XP] NO_DATA | User has no XP data.')
21
+
22
+ const leaderboard = await levels
23
+ .find({
24
+ guild: guildID
25
+ })
26
+ .sort([['xp', 'descending']])
27
+ .exec()
28
+
29
+ user.position = leaderboard.findIndex((i) => i.user === userID) + 1
30
+
31
+ let targetxp = user.level + 1
32
+
33
+ let target = targetxp * targetxp * 100
34
+
35
+ return rankCard(message, {
36
+ level: user.level,
37
+ currentXP: user.xp,
38
+ neededXP: target,
39
+ rank: user.position,
40
+ background: options.background,
41
+ color: options.color,
42
+ lvlbar: options.lvlbar,
43
+ lvlbarBg: options.lvlbarBg,
44
+ member: message.guild.members.cache.get(userID)?.user
45
+ })
46
+
47
+ async function rankCard(message, options = []) {
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
+ })
54
+
55
+ function shortener(count) {
56
+ const COUNT_ABBRS = [
57
+ '',
58
+ 'k',
59
+ 'M',
60
+ 'B',
61
+ 'T',
62
+ 'Q',
63
+ 'Q+',
64
+ 'S',
65
+ 'S+',
66
+ 'O',
67
+ 'N',
68
+ 'D',
69
+ 'U'
70
+ ]
71
+
72
+ const i =
73
+ 0 === count ? count : Math.floor(Math.log(count) / Math.log(1000))
74
+ let result = parseFloat((count / Math.pow(1000, i)).toFixed(2))
75
+ result += `${COUNT_ABBRS[i]}`
76
+ return result
77
+ }
78
+
79
+ const member = options.member
80
+
81
+ const canvas = Canvas.createCanvas(1080, 400),
82
+ ctx = canvas.getContext('2d')
83
+
84
+ const name = member.tag
85
+ const noSymbols = (string) => string.replace(/[\u007f-\uffff]/g, '')
86
+
87
+ let fsiz = '45px'
88
+ if (message.guild.name.length >= 23) {
89
+ fsiz = '38px'
90
+ }
91
+ if (message.guild.name.length >= 40) {
92
+ fsiz = '28px'
93
+ }
94
+ if (message.guild.name.length >= 63) {
95
+ fsiz = '22px'
96
+ }
97
+
98
+ let BackgroundRadius = '20',
99
+ BackGroundImg =
100
+ options.background ||
101
+ 'https://pinebanana.files.wordpress.com/2011/04/rainbow.jpg',
102
+ AttachmentName = 'rank.png',
103
+ Username = noSymbols(name),
104
+ AvatarRoundRadius = '50',
105
+ DrawLayerColor = '#000000',
106
+ DrawLayerOpacity = '0.4',
107
+ BoxColor = options.color || '#096DD1',
108
+ LevelBarFill = options.lvlbar || '#ffffff',
109
+ LevelBarBackground = options.lvlbarBg || '#ffffff',
110
+ Rank = options.rank,
111
+ TextEXP = shortener(options.currentXP) + ' XP',
112
+ LvlText = `Level ${shortener(options.level)}`,
113
+ BarRadius = '20',
114
+ TextXpNeded = '{current}/{needed}',
115
+ CurrentXP = options.currentXP,
116
+ NeededXP = options.neededXP
117
+
118
+ ctx.beginPath()
119
+ ctx.moveTo(0 + Number(BackgroundRadius), 0)
120
+ ctx.lineTo(0 + 1080 - Number(BackgroundRadius), 0)
121
+ ctx.quadraticCurveTo(0 + 1080, 0, 0 + 1080, 0 + Number(BackgroundRadius))
122
+ ctx.lineTo(0 + 1080, 0 + 400 - Number(BackgroundRadius))
123
+ ctx.quadraticCurveTo(
124
+ 0 + 1080,
125
+ 0 + 400,
126
+ 0 + 1080 - Number(BackgroundRadius),
127
+ 0 + 400
128
+ )
129
+
130
+ ctx.lineTo(0 + Number(BackgroundRadius), 0 + 400)
131
+ ctx.quadraticCurveTo(0, 0 + 400, 0, 0 + 400 - Number(BackgroundRadius))
132
+ ctx.lineTo(0, 0 + Number(BackgroundRadius))
133
+ ctx.quadraticCurveTo(0, 0, 0 + Number(BackgroundRadius), 0)
134
+ ctx.closePath()
135
+ ctx.clip()
136
+ ctx.fillStyle = '#000000'
137
+ ctx.fillRect(0, 0, 1080, 400)
138
+ let background = await Canvas.loadImage(BackGroundImg)
139
+ ctx.globalAlpha = 0.7
140
+ ctx.drawImage(background, 0, 0, 1080, 400)
141
+ ctx.restore()
142
+
143
+ ctx.fillStyle = DrawLayerColor
144
+ ctx.globalAlpha = DrawLayerOpacity
145
+ ctx.fillRect(40, 0, 240, canvas.height)
146
+ ctx.globalAlpha = 1
147
+
148
+ function RoundedBox(ctx, x, y, width, height, radius) {
149
+ ctx.beginPath()
150
+ ctx.moveTo(x + radius, y)
151
+ ctx.lineTo(x + width - radius, y)
152
+ ctx.quadraticCurveTo(x + width, y, x + width, y + radius)
153
+ ctx.lineTo(x + width, y + height - radius)
154
+ ctx.quadraticCurveTo(
155
+ x + width,
156
+ y + height,
157
+ x + width - radius,
158
+ y + height
159
+ )
160
+ ctx.lineTo(x + radius, y + height)
161
+ ctx.quadraticCurveTo(x, y + height, x, y + height - radius)
162
+ ctx.lineTo(x, y + radius)
163
+ ctx.quadraticCurveTo(x, y, x + radius, y)
164
+ ctx.closePath()
165
+ }
166
+
167
+ let avatar = await Canvas.loadImage(
168
+ member.displayAvatarURL({ dynamic: true, format: 'png' })
169
+ )
170
+ ctx.save()
171
+ RoundedBox(ctx, 40 + 30, 30, 180, 180, Number(AvatarRoundRadius))
172
+ ctx.strokeStyle = BoxColor
173
+ ctx.lineWidth = '10'
174
+ ctx.stroke()
175
+ ctx.clip()
176
+ ctx.drawImage(avatar, 40 + 30, 30, 180, 180)
177
+ ctx.restore()
178
+
179
+ ctx.save()
180
+ RoundedBox(ctx, 40 + 30, 30 + 180 + 30 + 50 + 30, 180, 50, 20)
181
+ ctx.strokeStyle = '#BFC85A22'
182
+ ctx.stroke()
183
+ ctx.clip()
184
+ ctx.fillStyle = BoxColor
185
+ ctx.globalAlpha = '1'
186
+ ctx.fillRect(40 + 30, 30 + 180 + 30 + 50 + 30, 180, 50)
187
+ ctx.globalAlpha = 1
188
+ ctx.fillStyle = '#ffffff'
189
+ ctx.font = '32px "Sans Serif"'
190
+ ctx.textAlign = 'center'
191
+ ctx.fillText(TextEXP, 40 + 30 + 180 / 2, 30 + 180 + 30 + 30 + 50 + 38)
192
+ ctx.restore()
193
+
194
+ ctx.save()
195
+ RoundedBox(ctx, 40 + 30, 30 + 180 + 30, 180, 50, 20)
196
+ ctx.strokeStyle = '#BFC85A22'
197
+ ctx.stroke()
198
+ ctx.clip()
199
+ ctx.fillStyle = BoxColor
200
+ ctx.globalAlpha = '1'
201
+ ctx.fillRect(40 + 30, 30 + 180 + 30, 180, 50, 50)
202
+ ctx.globalAlpha = 1
203
+ ctx.fillStyle = '#ffffff'
204
+ ctx.font = '32px "Sans Serif"'
205
+ ctx.textAlign = 'center'
206
+ ctx.fillText(LvlText, 40 + 30 + 180 / 2, 30 + 180 + 30 + 38)
207
+ ctx.restore()
208
+
209
+ ctx.save()
210
+ ctx.textAlign = 'left'
211
+ ctx.fillStyle = '#ffffff'
212
+ ctx.shadowColor = '#000000'
213
+ ctx.shadowBlur = 15
214
+ ctx.shadowOffsetX = 1
215
+ ctx.shadowOffsetY = 1
216
+ ctx.font = '39px "Sans Serif"'
217
+ ctx.fillText(Username, 390, 80)
218
+ ctx.restore()
219
+
220
+ ctx.save()
221
+ ctx.textAlign = 'right'
222
+ ctx.fillStyle = '#ffffff'
223
+ ctx.shadowColor = '#000000'
224
+ ctx.shadowBlur = 15
225
+ ctx.shadowOffsetX = 1
226
+ ctx.shadowOffsetY = 1
227
+ ctx.font = '55px "Sans Serif"'
228
+ ctx.fillText('#' + Rank, canvas.width - 50 - 5, 80)
229
+ ctx.restore()
230
+
231
+ ctx.save()
232
+ RoundedBox(ctx, 390, 305, 660, 70, Number(20))
233
+ ctx.strokeStyle = '#BFC85A22'
234
+ ctx.stroke()
235
+ ctx.clip()
236
+ ctx.fillStyle = '#ffffff'
237
+ ctx.font = `${fsiz} "Sans Serif"`
238
+ ctx.textAlign = 'center'
239
+ ctx.fillText(message.guild.name, 60 + 660, 355)
240
+ ctx.globalAlpha = '0.2'
241
+ ctx.fillRect(390, 305, 660, 70)
242
+ ctx.restore()
243
+
244
+ ctx.save()
245
+ RoundedBox(ctx, 390, 145, 660, 50, Number(BarRadius))
246
+ ctx.strokeStyle = '#BFC85A22'
247
+ ctx.stroke()
248
+ ctx.clip()
249
+ ctx.fillStyle = LevelBarBackground
250
+ ctx.globalAlpha = '0.2'
251
+ ctx.fillRect(390, 145, 660, 50, 50)
252
+ ctx.restore()
253
+
254
+ const percent = (100 * CurrentXP) / NeededXP
255
+ const progress = (percent * 660) / 100
256
+
257
+ ctx.save()
258
+ RoundedBox(ctx, 390, 145, progress, 50, Number(BarRadius))
259
+ ctx.strokeStyle = '#BFC85A22'
260
+ ctx.stroke()
261
+ ctx.clip()
262
+ ctx.fillStyle = LevelBarFill
263
+ ctx.globalAlpha = '0.5'
264
+ ctx.fillRect(390, 145, progress, 50, 50)
265
+ ctx.restore()
266
+
267
+ ctx.save()
268
+ ctx.textAlign = 'left'
269
+ ctx.fillStyle = '#ffffff'
270
+ ctx.globalAlpha = '0.8'
271
+ ctx.font = '30px "Sans Serif"'
272
+ ctx.fillText('Next Level: ' + shortener(NeededXP) + ' XP', 390, 230)
273
+ ctx.restore()
274
+
275
+ const latestXP = Number(CurrentXP) - Number(NeededXP)
276
+ const textXPEdited = TextXpNeded.replace(/{needed}/g, shortener(NeededXP))
277
+ .replace(/{current}/g, shortener(CurrentXP))
278
+ .replace(/{latest}/g, latestXP)
279
+ ctx.textAlign = 'center'
280
+ ctx.fillStyle = '#474747'
281
+ ctx.globalAlpha = 1
282
+ ctx.font = '30px "Sans Serif"'
283
+ ctx.fillText(textXPEdited, 730, 180)
284
+
285
+ const attachment = {
286
+ attachment: canvas.toBuffer(),
287
+ name: AttachmentName
288
+ }
289
+ return attachment
290
+ } catch (err) {
291
+ console.log(`[XP] Error Occured. | rankCard | Error: ${err.stack}`)
292
+ }
293
+ }
294
+ }
295
+
296
+ module.exports = rank
package/src/reset.js CHANGED
@@ -1,22 +1,22 @@
1
- const levels = require('../src/models/level.js')
2
-
3
- /**
4
- * @param {string} userID
5
- * @param {string} guildID
6
- */
7
-
8
- async function reset(userID, guildID) {
9
- if (!userID) throw new Error('[XP] User ID was not provided.')
10
-
11
- if (!guildID) throw new Error('[XP] User ID was not provided.')
12
-
13
- await levels
14
- .findOneAndUpdate({ user: userID, guild: guildID }, { xp: 0, level: 0 })
15
- .catch((err) => {
16
- throw new Error(err)
17
- })
18
-
19
- return { user: userID, guild: guildID, xp: 0, level: 0 }
20
- }
21
-
22
- module.exports = reset
1
+ const levels = require('../src/models/level.js')
2
+
3
+ /**
4
+ * @param {string} userID
5
+ * @param {string} guildID
6
+ */
7
+
8
+ async function reset(userID, guildID) {
9
+ if (!userID) throw new Error('[XP] User ID was not provided.')
10
+
11
+ if (!guildID) throw new Error('[XP] User ID was not provided.')
12
+
13
+ await levels
14
+ .findOneAndUpdate({ user: userID, guild: guildID }, { xp: 0, level: 0 })
15
+ .catch((err) => {
16
+ throw new Error(err)
17
+ })
18
+
19
+ return { user: userID, guild: guildID, xp: 0, level: 0 }
20
+ }
21
+
22
+ module.exports = reset