simply-xp 1.1.5-beta → 1.1.7
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/.github/ISSUE_TEMPLATE/bug_report.md +31 -31
- package/.prettierrc.json +8 -8
- package/README.md +62 -62
- package/index.d.ts +107 -107
- package/package.json +52 -52
- package/src/Fonts/Baloo-Regular.ttf +0 -0
- package/src/addLevel.js +71 -71
- package/src/addXP.js +112 -112
- package/src/charts.js +83 -83
- package/src/connect.js +20 -20
- package/src/create.js +28 -28
- package/src/fetch.js +74 -74
- package/src/leaderboard.js +70 -70
- package/src/lvlRole.js +54 -54
- package/src/models/level.js +10 -10
- package/src/models/lvlrole.js +8 -8
- package/src/rank.js +282 -285
- package/src/reset.js +28 -28
- package/src/roleSetup.js +122 -124
- package/src/setLevel.js +71 -71
- package/src/setXP.js +51 -51
- package/src/Fonts/Poppins-Regular.ttf +0 -0
- package/src/Fonts/Poppins-SemiBold.ttf +0 -0
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Bug report
|
|
3
|
-
about: Create a report to help us improve
|
|
4
|
-
title: ''
|
|
5
|
-
labels: 'bug'
|
|
6
|
-
assignees: ''
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
**Describe the bug**
|
|
10
|
-
A clear and concise description of what the bug is.
|
|
11
|
-
|
|
12
|
-
**To Reproduce**
|
|
13
|
-
Steps to reproduce the behavior:
|
|
14
|
-
|
|
15
|
-
1. Run the bot
|
|
16
|
-
2. Try the function
|
|
17
|
-
3. See error
|
|
18
|
-
|
|
19
|
-
**Expected behavior**
|
|
20
|
-
A clear and concise description of what you expected to happen.
|
|
21
|
-
|
|
22
|
-
**Screenshots**
|
|
23
|
-
If applicable, add screenshots to help explain your problem.
|
|
24
|
-
|
|
25
|
-
**Versions (please complete the following information):**
|
|
26
|
-
|
|
27
|
-
- Discord.js Version [e.g. v13]
|
|
28
|
-
- simply-xp Version [e.g. v2.0.0]
|
|
29
|
-
|
|
30
|
-
**Additional context**
|
|
31
|
-
Add any other context about the problem here.
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Create a report to help us improve
|
|
4
|
+
title: ''
|
|
5
|
+
labels: 'bug'
|
|
6
|
+
assignees: ''
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
**Describe the bug**
|
|
10
|
+
A clear and concise description of what the bug is.
|
|
11
|
+
|
|
12
|
+
**To Reproduce**
|
|
13
|
+
Steps to reproduce the behavior:
|
|
14
|
+
|
|
15
|
+
1. Run the bot
|
|
16
|
+
2. Try the function
|
|
17
|
+
3. See error
|
|
18
|
+
|
|
19
|
+
**Expected behavior**
|
|
20
|
+
A clear and concise description of what you expected to happen.
|
|
21
|
+
|
|
22
|
+
**Screenshots**
|
|
23
|
+
If applicable, add screenshots to help explain your problem.
|
|
24
|
+
|
|
25
|
+
**Versions (please complete the following information):**
|
|
26
|
+
|
|
27
|
+
- Discord.js Version [e.g. v13]
|
|
28
|
+
- simply-xp Version [e.g. v2.0.0]
|
|
29
|
+
|
|
30
|
+
**Additional context**
|
|
31
|
+
Add any other context about the problem here.
|
package/.prettierrc.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
{
|
|
2
|
-
"trailingComma": "none",
|
|
3
|
-
"tabWidth": 2,
|
|
4
|
-
"semi": false,
|
|
5
|
-
"singleQuote": true,
|
|
6
|
-
"useTabs": false,
|
|
7
|
-
"bracketSpacing": true
|
|
8
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"trailingComma": "none",
|
|
3
|
+
"tabWidth": 2,
|
|
4
|
+
"semi": false,
|
|
5
|
+
"singleQuote": true,
|
|
6
|
+
"useTabs": false,
|
|
7
|
+
"bracketSpacing": true
|
|
8
|
+
}
|
package/README.md
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
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</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
|
-
- Fixed bugs
|
|
34
|
-
- New `addLevel(), setLevel(), reset()`
|
|
35
|
-
- roleSetup redefined.. Redid whole system.
|
|
36
|
-
- New everything.. Everything is now tidy and compact.
|
|
37
|
-
- levelUp event returns role id too !
|
|
38
|
-
- Re-coded to squeeze bugs
|
|
39
|
-
- Bug Fixes
|
|
40
|
-
|
|
41
|
-
# But Why ?
|
|
42
|
-
|
|
43
|
-
- Easiest XP System in Discord.js
|
|
44
|
-
- Fastest Support ever
|
|
45
|
-
- Rank Card Maker
|
|
46
|
-
- Beginner Friendly
|
|
47
|
-
- Easier than other XP Systems
|
|
48
|
-
- Inbuilt Auto Roles system
|
|
49
|
-
- Flexible and simple at the same time
|
|
50
|
-
|
|
51
|
-
`Reconstructed discord-xp to give you things simpler ;)`
|
|
52
|
-
|
|
53
|
-
<br>
|
|
54
|
-
|
|
55
|
-
## **Need Help ? Join the [Discord Server](https://discord.gg/3JzDV9T5Fn)**
|
|
56
|
-
|
|
57
|
-
<br>
|
|
58
|
-
|
|
59
|
-
<h1>👥 Contact us | Support</h1>
|
|
60
|
-
<p>
|
|
61
|
-
<a href="https://discord.gg/3JzDV9T5Fn"><img src="https://invidget.switchblade.xyz/3JzDV9T5Fn" /></a>
|
|
62
|
-
</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</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
|
+
- Fixed bugs
|
|
34
|
+
- New `addLevel(), setLevel(), reset()`
|
|
35
|
+
- roleSetup redefined.. Redid whole system.
|
|
36
|
+
- New everything.. Everything is now tidy and compact.
|
|
37
|
+
- levelUp event returns role id too !
|
|
38
|
+
- Re-coded to squeeze bugs
|
|
39
|
+
- Bug Fixes
|
|
40
|
+
|
|
41
|
+
# But Why ?
|
|
42
|
+
|
|
43
|
+
- Easiest XP System in Discord.js
|
|
44
|
+
- Fastest Support ever
|
|
45
|
+
- Rank Card Maker
|
|
46
|
+
- Beginner Friendly
|
|
47
|
+
- Easier than other XP Systems
|
|
48
|
+
- Inbuilt Auto Roles system
|
|
49
|
+
- Flexible and simple at the same time
|
|
50
|
+
|
|
51
|
+
`Reconstructed discord-xp to give you things simpler ;)`
|
|
52
|
+
|
|
53
|
+
<br>
|
|
54
|
+
|
|
55
|
+
## **Need Help ? Join the [Discord Server](https://discord.gg/3JzDV9T5Fn)**
|
|
56
|
+
|
|
57
|
+
<br>
|
|
58
|
+
|
|
59
|
+
<h1>👥 Contact us | Support</h1>
|
|
60
|
+
<p>
|
|
61
|
+
<a href="https://discord.gg/3JzDV9T5Fn"><img src="https://invidget.switchblade.xyz/3JzDV9T5Fn" /></a>
|
|
62
|
+
</p>
|
package/index.d.ts
CHANGED
|
@@ -1,107 +1,107 @@
|
|
|
1
|
-
import { Message, Client } from 'discord.js'
|
|
2
|
-
|
|
3
|
-
type HexColorString = `#${string}` | string
|
|
4
|
-
|
|
5
|
-
export type connectOptions = {
|
|
6
|
-
notify?: boolean
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export declare function connect(
|
|
10
|
-
db: string,
|
|
11
|
-
options?: connectOptions
|
|
12
|
-
): Promise<any>
|
|
13
|
-
|
|
14
|
-
export declare function addLevel(
|
|
15
|
-
message: Message,
|
|
16
|
-
userID: string,
|
|
17
|
-
guildID: string,
|
|
18
|
-
level: number
|
|
19
|
-
): Promise<any>
|
|
20
|
-
|
|
21
|
-
export declare function addXP(
|
|
22
|
-
message: Message,
|
|
23
|
-
userID: string,
|
|
24
|
-
guildID: string,
|
|
25
|
-
xp: number
|
|
26
|
-
): Promise<any>
|
|
27
|
-
|
|
28
|
-
export type chartsOptions = {
|
|
29
|
-
position?: string
|
|
30
|
-
background?: HexColorString
|
|
31
|
-
type?: 'bar' | 'line' | 'radar' | 'doughnut' | 'polarArea'
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export declare function charts(
|
|
35
|
-
message: Message,
|
|
36
|
-
options?: chartsOptions
|
|
37
|
-
): Promise<any>
|
|
38
|
-
|
|
39
|
-
export declare function create(userID: string, guildID: string): Promise<any>
|
|
40
|
-
|
|
41
|
-
export declare function fetch(userID: string, guildID: string): Promise<any>
|
|
42
|
-
|
|
43
|
-
export declare function leaderboard(
|
|
44
|
-
userID: string,
|
|
45
|
-
guildID: string,
|
|
46
|
-
limit: number
|
|
47
|
-
): Promise<any>
|
|
48
|
-
|
|
49
|
-
export declare function lvlRole(
|
|
50
|
-
message: Message,
|
|
51
|
-
userID: string,
|
|
52
|
-
guildID: string
|
|
53
|
-
): Promise<any>
|
|
54
|
-
|
|
55
|
-
export type rankOptions = {
|
|
56
|
-
slash?: boolean
|
|
57
|
-
background?: string
|
|
58
|
-
color?: HexColorString
|
|
59
|
-
}
|
|
60
|
-
export declare function rank(
|
|
61
|
-
message: Message,
|
|
62
|
-
userID: string,
|
|
63
|
-
guildID: string,
|
|
64
|
-
options?: rankOptions
|
|
65
|
-
): Promise<any>
|
|
66
|
-
|
|
67
|
-
export declare function reset(userID: string, guildID: string): Promise<any>
|
|
68
|
-
|
|
69
|
-
export type lvladdOptions = {
|
|
70
|
-
level: string
|
|
71
|
-
role: string
|
|
72
|
-
}
|
|
73
|
-
export type lvlremoveOptions = {
|
|
74
|
-
level: string
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export declare function setLevel(
|
|
78
|
-
message: Message,
|
|
79
|
-
userID: string,
|
|
80
|
-
guildID: string,
|
|
81
|
-
level: number
|
|
82
|
-
): Promise<any>
|
|
83
|
-
|
|
84
|
-
export declare function setXP(
|
|
85
|
-
userID: string,
|
|
86
|
-
guildID: string,
|
|
87
|
-
xp: number
|
|
88
|
-
): Promise<any>
|
|
89
|
-
|
|
90
|
-
/** For levelUp event */
|
|
91
|
-
export type Data = {
|
|
92
|
-
xp: string
|
|
93
|
-
level: number
|
|
94
|
-
userID: string
|
|
95
|
-
guildID: string
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export type Role = {
|
|
99
|
-
lvl: string
|
|
100
|
-
role: string
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
declare module 'discord.js' {
|
|
104
|
-
export interface ClientEvents {
|
|
105
|
-
levelUp: [Message, Data, Role]
|
|
106
|
-
}
|
|
107
|
-
}
|
|
1
|
+
import { Message, Client } from 'discord.js'
|
|
2
|
+
|
|
3
|
+
type HexColorString = `#${string}` | string
|
|
4
|
+
|
|
5
|
+
export type connectOptions = {
|
|
6
|
+
notify?: boolean
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export declare function connect(
|
|
10
|
+
db: string,
|
|
11
|
+
options?: connectOptions
|
|
12
|
+
): Promise<any>
|
|
13
|
+
|
|
14
|
+
export declare function addLevel(
|
|
15
|
+
message: Message,
|
|
16
|
+
userID: string,
|
|
17
|
+
guildID: string,
|
|
18
|
+
level: number
|
|
19
|
+
): Promise<any>
|
|
20
|
+
|
|
21
|
+
export declare function addXP(
|
|
22
|
+
message: Message,
|
|
23
|
+
userID: string,
|
|
24
|
+
guildID: string,
|
|
25
|
+
xp: number
|
|
26
|
+
): Promise<any>
|
|
27
|
+
|
|
28
|
+
export type chartsOptions = {
|
|
29
|
+
position?: string
|
|
30
|
+
background?: HexColorString
|
|
31
|
+
type?: 'bar' | 'line' | 'radar' | 'doughnut' | 'polarArea'
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export declare function charts(
|
|
35
|
+
message: Message,
|
|
36
|
+
options?: chartsOptions
|
|
37
|
+
): Promise<any>
|
|
38
|
+
|
|
39
|
+
export declare function create(userID: string, guildID: string): Promise<any>
|
|
40
|
+
|
|
41
|
+
export declare function fetch(userID: string, guildID: string): Promise<any>
|
|
42
|
+
|
|
43
|
+
export declare function leaderboard(
|
|
44
|
+
userID: string,
|
|
45
|
+
guildID: string,
|
|
46
|
+
limit: number
|
|
47
|
+
): Promise<any>
|
|
48
|
+
|
|
49
|
+
export declare function lvlRole(
|
|
50
|
+
message: Message,
|
|
51
|
+
userID: string,
|
|
52
|
+
guildID: string
|
|
53
|
+
): Promise<any>
|
|
54
|
+
|
|
55
|
+
export type rankOptions = {
|
|
56
|
+
slash?: boolean
|
|
57
|
+
background?: string
|
|
58
|
+
color?: HexColorString
|
|
59
|
+
}
|
|
60
|
+
export declare function rank(
|
|
61
|
+
message: Message,
|
|
62
|
+
userID: string,
|
|
63
|
+
guildID: string,
|
|
64
|
+
options?: rankOptions
|
|
65
|
+
): Promise<any>
|
|
66
|
+
|
|
67
|
+
export declare function reset(userID: string, guildID: string): Promise<any>
|
|
68
|
+
|
|
69
|
+
export type lvladdOptions = {
|
|
70
|
+
level: string
|
|
71
|
+
role: string
|
|
72
|
+
}
|
|
73
|
+
export type lvlremoveOptions = {
|
|
74
|
+
level: string
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export declare function setLevel(
|
|
78
|
+
message: Message,
|
|
79
|
+
userID: string,
|
|
80
|
+
guildID: string,
|
|
81
|
+
level: number
|
|
82
|
+
): Promise<any>
|
|
83
|
+
|
|
84
|
+
export declare function setXP(
|
|
85
|
+
userID: string,
|
|
86
|
+
guildID: string,
|
|
87
|
+
xp: number
|
|
88
|
+
): Promise<any>
|
|
89
|
+
|
|
90
|
+
/** For levelUp event */
|
|
91
|
+
export type Data = {
|
|
92
|
+
xp: string
|
|
93
|
+
level: number
|
|
94
|
+
userID: string
|
|
95
|
+
guildID: string
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export type Role = {
|
|
99
|
+
lvl: string
|
|
100
|
+
role: string
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
declare module 'discord.js' {
|
|
104
|
+
export interface ClientEvents {
|
|
105
|
+
levelUp: [Message, Data, Role]
|
|
106
|
+
}
|
|
107
|
+
}
|
package/package.json
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "simply-xp",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"description": "A Simple, Easy and Beginner Friendly XP System",
|
|
5
|
-
"main": "simplyxp.js",
|
|
6
|
-
"typings": "index.d.ts",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
9
|
-
"prepare": "husky install"
|
|
10
|
-
},
|
|
11
|
-
"author": "Rahuletto",
|
|
12
|
-
"keywords": [
|
|
13
|
-
"xp",
|
|
14
|
-
"simply",
|
|
15
|
-
"easy",
|
|
16
|
-
"xp-system",
|
|
17
|
-
"system",
|
|
18
|
-
"mongoose",
|
|
19
|
-
"discord",
|
|
20
|
-
"discord xp",
|
|
21
|
-
"discord-xp",
|
|
22
|
-
"simply-djs",
|
|
23
|
-
"discord.js",
|
|
24
|
-
"simplydjs",
|
|
25
|
-
"weky",
|
|
26
|
-
"nuggies",
|
|
27
|
-
"experience",
|
|
28
|
-
"level role",
|
|
29
|
-
"amari",
|
|
30
|
-
"package",
|
|
31
|
-
"leaderboard",
|
|
32
|
-
"mee6",
|
|
33
|
-
"charts",
|
|
34
|
-
"ChartJS",
|
|
35
|
-
"level up"
|
|
36
|
-
],
|
|
37
|
-
"license": "Apache-2.0",
|
|
38
|
-
"repository": {
|
|
39
|
-
"type": "git",
|
|
40
|
-
"url": "https://github.com/Rahuletto/simply-xp"
|
|
41
|
-
},
|
|
42
|
-
"dependencies": {
|
|
43
|
-
"canvas": "^2.8.0",
|
|
44
|
-
"chart.js-image": "^5.6.3",
|
|
45
|
-
"mongoose": "^6.0.
|
|
46
|
-
},
|
|
47
|
-
"devDependencies": {
|
|
48
|
-
"discord.js": "^13.
|
|
49
|
-
"husky": "^7.0.0",
|
|
50
|
-
"pretty-quick": "^3.1.1"
|
|
51
|
-
}
|
|
52
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "simply-xp",
|
|
3
|
+
"version": "1.1.7",
|
|
4
|
+
"description": "A Simple, Easy and Beginner Friendly XP System",
|
|
5
|
+
"main": "simplyxp.js",
|
|
6
|
+
"typings": "index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
9
|
+
"prepare": "husky install"
|
|
10
|
+
},
|
|
11
|
+
"author": "Rahuletto",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"xp",
|
|
14
|
+
"simply",
|
|
15
|
+
"easy",
|
|
16
|
+
"xp-system",
|
|
17
|
+
"system",
|
|
18
|
+
"mongoose",
|
|
19
|
+
"discord",
|
|
20
|
+
"discord xp",
|
|
21
|
+
"discord-xp",
|
|
22
|
+
"simply-djs",
|
|
23
|
+
"discord.js",
|
|
24
|
+
"simplydjs",
|
|
25
|
+
"weky",
|
|
26
|
+
"nuggies",
|
|
27
|
+
"experience",
|
|
28
|
+
"level role",
|
|
29
|
+
"amari",
|
|
30
|
+
"package",
|
|
31
|
+
"leaderboard",
|
|
32
|
+
"mee6",
|
|
33
|
+
"charts",
|
|
34
|
+
"ChartJS",
|
|
35
|
+
"level up"
|
|
36
|
+
],
|
|
37
|
+
"license": "Apache-2.0",
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "https://github.com/Rahuletto/simply-xp"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"canvas": "^2.8.0",
|
|
44
|
+
"chart.js-image": "^5.6.3",
|
|
45
|
+
"mongoose": "^6.0.15"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"discord.js": "^13.8.0",
|
|
49
|
+
"husky": "^7.0.0",
|
|
50
|
+
"pretty-quick": "^3.1.1"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
Binary file
|
package/src/addLevel.js
CHANGED
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
let Discord = require('discord.js')
|
|
2
|
-
const levels = require('../src/models/level.js')
|
|
3
|
-
let { roleSetup } = require('../simplyxp')
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @param {Discord.Message} message
|
|
7
|
-
* @param {string} userID
|
|
8
|
-
* @param {string} guildID
|
|
9
|
-
* @param {number} level
|
|
10
|
-
*/
|
|
11
|
-
async function addLevel(message, userID, guildID, level) {
|
|
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
|
-
if (!level) throw new Error('[XP] Level amount is not provided.')
|
|
17
|
-
|
|
18
|
-
let { client } = message
|
|
19
|
-
|
|
20
|
-
const user = await levels.findOne({ user: userID, guild: guildID })
|
|
21
|
-
|
|
22
|
-
if (!user) {
|
|
23
|
-
const newUser = new levels({
|
|
24
|
-
user: userID,
|
|
25
|
-
guild: guildID,
|
|
26
|
-
xp: 0,
|
|
27
|
-
level: 0
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
await newUser
|
|
31
|
-
.save()
|
|
32
|
-
.catch((e) => console.log(`[XP] Failed to save new user to database`))
|
|
33
|
-
|
|
34
|
-
let xp = (level * 10) ** 2
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
level: level,
|
|
38
|
-
exp: xp
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
let level1 = user.level
|
|
42
|
-
|
|
43
|
-
user.xp += (level * 10) ** 2
|
|
44
|
-
user.level += Math.floor(0.1 * Math.sqrt(user.xp))
|
|
45
|
-
|
|
46
|
-
await user
|
|
47
|
-
.save()
|
|
48
|
-
.catch((e) =>
|
|
49
|
-
console.log(`[XP] Failed to add Level | User: ${userID} | Err: ${e}`)
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
if (level1 !== level) {
|
|
53
|
-
let data = {
|
|
54
|
-
xp: user.xp,
|
|
55
|
-
level: user.level,
|
|
56
|
-
userID,
|
|
57
|
-
guildID
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
let role = await roleSetup.find(client, guildID, level)
|
|
61
|
-
|
|
62
|
-
client.emit('levelUp', message, data, role)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return {
|
|
66
|
-
level: user.level,
|
|
67
|
-
xp: user.xp
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
module.exports = addLevel
|
|
1
|
+
let Discord = require('discord.js')
|
|
2
|
+
const levels = require('../src/models/level.js')
|
|
3
|
+
let { roleSetup } = require('../simplyxp')
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @param {Discord.Message} message
|
|
7
|
+
* @param {string} userID
|
|
8
|
+
* @param {string} guildID
|
|
9
|
+
* @param {number} level
|
|
10
|
+
*/
|
|
11
|
+
async function addLevel(message, userID, guildID, level) {
|
|
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
|
+
if (!level) throw new Error('[XP] Level amount is not provided.')
|
|
17
|
+
|
|
18
|
+
let { client } = message
|
|
19
|
+
|
|
20
|
+
const user = await levels.findOne({ user: userID, guild: guildID })
|
|
21
|
+
|
|
22
|
+
if (!user) {
|
|
23
|
+
const newUser = new levels({
|
|
24
|
+
user: userID,
|
|
25
|
+
guild: guildID,
|
|
26
|
+
xp: 0,
|
|
27
|
+
level: 0
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
await newUser
|
|
31
|
+
.save()
|
|
32
|
+
.catch((e) => console.log(`[XP] Failed to save new user to database`))
|
|
33
|
+
|
|
34
|
+
let xp = (level * 10) ** 2
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
level: level,
|
|
38
|
+
exp: xp
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
let level1 = user.level
|
|
42
|
+
|
|
43
|
+
user.xp += (level * 10) ** 2
|
|
44
|
+
user.level += Math.floor(0.1 * Math.sqrt(user.xp))
|
|
45
|
+
|
|
46
|
+
await user
|
|
47
|
+
.save()
|
|
48
|
+
.catch((e) =>
|
|
49
|
+
console.log(`[XP] Failed to add Level | User: ${userID} | Err: ${e}`)
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
if (level1 !== level) {
|
|
53
|
+
let data = {
|
|
54
|
+
xp: user.xp,
|
|
55
|
+
level: user.level,
|
|
56
|
+
userID,
|
|
57
|
+
guildID
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
let role = await roleSetup.find(client, guildID, level)
|
|
61
|
+
|
|
62
|
+
client.emit('levelUp', message, data, role)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
level: user.level,
|
|
67
|
+
xp: user.xp
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
module.exports = addLevel
|