simply-xp 2.0.0-dev.3-fix.2 → 2.0.0-dev.4
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/lib/src/Fonts/BalooBhaijaan-Regular.otf +0 -0
- package/lib/src/add.js +2 -4
- package/lib/src/cards.d.ts +14 -0
- package/lib/src/cards.js +2 -2
- package/lib/src/charts.d.ts +18 -8
- package/lib/src/charts.js +3 -4
- package/lib/src/connect.js +3 -5
- package/lib/src/create.js +1 -2
- package/lib/src/fetch.js +1 -2
- package/lib/src/functions/database.js +2 -3
- package/lib/src/functions/utilities.js +2 -4
- package/lib/src/leaderboard.d.ts +1 -1
- package/lib/src/leaderboard.js +1 -2
- package/lib/src/migrate.js +2 -2
- package/lib/src/reset.js +1 -2
- package/lib/src/set.js +2 -4
- package/package.json +8 -8
- package/lib/src/Fonts/Baloo-Regular.eot +0 -0
|
Binary file
|
package/lib/src/add.js
CHANGED
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
* @link `Documentation:` https://simplyxp.js.org/docs/addlevel
|
|
10
10
|
* @returns {Promise<UserResult>} - Object of user data on success
|
|
11
11
|
* @throws {XpFatal} - If parameters are not provided correctly
|
|
12
|
-
*/
|
|
13
|
-
async function addLevel(userId,guildId,level,username){if(!userId)throw new xplogs_1.XpFatal({function:"addLevel()",message:"User ID was not provided"});if(!guildId)throw new xplogs_1.XpFatal({function:"addLevel()",message:"Guild ID was not provided"});if(isNaN(level))throw new xplogs_1.XpFatal({function:"addLevel()",message:"Level was not provided"});var e=await database_1.db.findOne({collection:"simply-xps",data:{user:userId,guild:guildId}});if(e)return database_1.db.updateOne({collection:"simply-xps",data:{user:userId,guild:guildId}},{collection:"simply-xps",data:{user:userId,guild:guildId,level:e.level+level,xp:(0,utilities_1.convertFrom)(level+e.level)}});if(xp_1.xp.auto_create&&username)return database_1.db.createOne({collection:"simply-xps",data:{guild:guildId,user:userId,name:username,level:level,xp:(0,utilities_1.convertFrom)(level)}});throw new xplogs_1.XpFatal({function:"addLevel()",message:"User does not exist"})}
|
|
12
|
+
*/async function addLevel(userId,guildId,level,username){if(!userId)throw new xplogs_1.XpFatal({function:"addLevel()",message:"User ID was not provided"});if(!guildId)throw new xplogs_1.XpFatal({function:"addLevel()",message:"Guild ID was not provided"});if(isNaN(level))throw new xplogs_1.XpFatal({function:"addLevel()",message:"Level was not provided"});var e=await database_1.db.findOne({collection:"simply-xps",data:{user:userId,guild:guildId}});if(e)return database_1.db.updateOne({collection:"simply-xps",data:{user:userId,guild:guildId}},{collection:"simply-xps",data:{user:userId,guild:guildId,level:e.level+level,xp:(0,utilities_1.convertFrom)(level+e.level)}});if(xp_1.xp.auto_create&&username)return database_1.db.createOne({collection:"simply-xps",data:{guild:guildId,user:userId,name:username,level:level,xp:(0,utilities_1.convertFrom)(level)}});throw new xplogs_1.XpFatal({function:"addLevel()",message:"User does not exist"})}
|
|
14
13
|
/**
|
|
15
14
|
* Add XP to a user.
|
|
16
15
|
* @async
|
|
@@ -21,5 +20,4 @@ async function addLevel(userId,guildId,level,username){if(!userId)throw new xplo
|
|
|
21
20
|
* @link `Documentation:` https://simplyxp.js.org/docs/addxp
|
|
22
21
|
* @returns {Promise<XPResult>} - Object of user data on success.
|
|
23
22
|
* @throws {XpFatal} - If parameters are not provided correctly.
|
|
24
|
-
*/
|
|
25
|
-
async function addXP(userId,guildId,xpData,username){if(!("number"==typeof xpData||"object"==typeof xp_1.xp&&xpData.min&&xpData.max))throw new xplogs_1.XpFatal({function:"addXP()",message:"XP is not a number or object, make sure you are using the correct syntax"});if("object"==typeof xpData&&(xpData=Math.floor(Math.random()*(xpData.max-xpData.min)+xpData.min)),!userId)throw new xplogs_1.XpFatal({function:"addXP()",message:"User ID was not provided"});if(!guildId)throw new xplogs_1.XpFatal({function:"addXP()",message:"Guild ID was not provided"});var e=await database_1.db.findOne({collection:"simply-xps",data:{user:userId,guild:guildId}});let a;if(e)a=await database_1.db.updateOne({collection:"simply-xps",data:{user:userId,guild:guildId}},{collection:"simply-xps",data:{user:userId,guild:guildId,level:(0,utilities_1.convertFrom)(e.xp+xpData,"xp"),xp:e.xp+xpData}}).catch(err=>{throw new xplogs_1.XpFatal({function:"addXP()",message:err.stack})});else{if(!xp_1.xp.auto_create||!username)throw new xplogs_1.XpFatal({function:"addXP()",message:"User does not exist"});a=await database_1.db.createOne({collection:"simply-xps",data:{guild:guildId,user:userId,name:username,level:(0,utilities_1.convertFrom)(xpData,"xp"),xp:xpData}}).catch(err=>{throw new xplogs_1.XpFatal({function:"addXP()",message:err.stack})})}return{...a,hasLevelledUp:a.level>e.level}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.addXP=exports.addLevel=void 0;const utilities_1=require("./functions/utilities"),xplogs_1=require("./functions/xplogs"),database_1=require("./functions/database"),xp_1=require("../xp");exports.addLevel=addLevel,exports.addXP=addXP;
|
|
23
|
+
*/async function addXP(userId,guildId,xpData,username){if(!("number"==typeof xpData||"object"==typeof xp_1.xp&&xpData.min&&xpData.max))throw new xplogs_1.XpFatal({function:"addXP()",message:"XP is not a number or object, make sure you are using the correct syntax"});if("object"==typeof xpData&&(xpData=Math.floor(Math.random()*(xpData.max-xpData.min)+xpData.min)),!userId)throw new xplogs_1.XpFatal({function:"addXP()",message:"User ID was not provided"});if(!guildId)throw new xplogs_1.XpFatal({function:"addXP()",message:"Guild ID was not provided"});var e=await database_1.db.findOne({collection:"simply-xps",data:{user:userId,guild:guildId}});let a;if(e)a=await database_1.db.updateOne({collection:"simply-xps",data:{user:userId,guild:guildId}},{collection:"simply-xps",data:{user:userId,guild:guildId,level:(0,utilities_1.convertFrom)(e.xp+xpData,"xp"),xp:e.xp+xpData}}).catch(err=>{throw new xplogs_1.XpFatal({function:"addXP()",message:err.stack})});else{if(!xp_1.xp.auto_create||!username)throw new xplogs_1.XpFatal({function:"addXP()",message:"User does not exist"});a=await database_1.db.createOne({collection:"simply-xps",data:{guild:guildId,user:userId,name:username,level:(0,utilities_1.convertFrom)(xpData,"xp"),xp:xpData}}).catch(err=>{throw new xplogs_1.XpFatal({function:"addXP()",message:err.stack})})}return{...a,hasLevelledUp:!e||a.level>e.level}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.addXP=exports.addLevel=void 0;const utilities_1=require("./functions/utilities"),xplogs_1=require("./functions/xplogs"),database_1=require("./functions/database"),xp_1=require("../xp");exports.addLevel=addLevel,exports.addXP=addXP;
|
package/lib/src/cards.d.ts
CHANGED
|
@@ -88,4 +88,18 @@ export declare function leaderboardCard(data: Array<User>, options?: Leaderboard
|
|
|
88
88
|
description: string;
|
|
89
89
|
name: string;
|
|
90
90
|
}>;
|
|
91
|
+
/**
|
|
92
|
+
* @constructor
|
|
93
|
+
* @private
|
|
94
|
+
*/
|
|
95
|
+
export declare function RoundedBox(ctx: {
|
|
96
|
+
beginPath: () => void;
|
|
97
|
+
moveTo: (arg0: number, arg1: number) => void;
|
|
98
|
+
lineTo: (arg0: number, arg1: number) => void;
|
|
99
|
+
quadraticCurveTo: (arg0: number, arg1: number, arg2: number, arg3: number) => void;
|
|
100
|
+
closePath: () => void;
|
|
101
|
+
}, x: number, y: number, width: number, height: number, radius: number, roundCorners?: {
|
|
102
|
+
top?: boolean;
|
|
103
|
+
bottom?: boolean;
|
|
104
|
+
}): void;
|
|
91
105
|
export {};
|
package/lib/src/cards.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @link [Documentation](https://simplyxp.js.org/docs/rankCard)
|
|
10
10
|
* @returns {Promise<{attachment: Buffer, description: string, name: string}>}
|
|
11
11
|
* @throws {XpFatal} - If parameters are not provided correctly
|
|
12
|
-
*/async function rankCard(guild,user,options={},locales={}){if(!guild)throw new xplogs_1.XpFatal({function:"rankCard()",message:"No Guild Provided"});if(!user)throw new xplogs_1.XpFatal({function:"rankCard()",message:"No User Provided"});options.legacy=!0;let
|
|
12
|
+
*/async function rankCard(guild,user,options={},locales={}){var e,a,o,t,r,l,n,d;if(!guild)throw new xplogs_1.XpFatal({function:"rankCard()",message:"No Guild Provided"});if(!user)throw new xplogs_1.XpFatal({function:"rankCard()",message:"No User Provided"});options.legacy=!0;let i,s;if(locales?.level||(locales.level="Level"),locales?.next_level||(locales.next_level="Next Level"),locales?.xp||(locales.xp="XP"),xplogs_1.XpLog.debug("rankCard()","LEGACY MODE ENABLED"),xplogs_1.XpLog.info("rankCard()","Modern RankCard is coming in dev.5"),!user?.avatarURL.endsWith(".png")&&!user.avatarURL.endsWith(".jpg")&&!user.avatarURL.endsWith(".webp"))throw new xplogs_1.XpFatal({function:"rankCard()",message:"Invalid avatar image, avatar image must be a png, jpg, or webp"});if(!user||!user.id||!user.username)throw new xplogs_1.XpFatal({function:"rankCard()",message:"Invalid User Provided, user must contain id, username, and avatarURL."});canvas_1.GlobalFonts.registerFromPath(options?.font||(0,path_1.join)(__dirname,"Fonts","BalooBhaijaan-Regular.otf"),"Sans Serif"),cachedRankImage=cachedRankImage||await(0,canvas_1.loadImage)(options?.background||"https://i.ibb.co/dck2Tnt/rank-card.webp").catch(()=>{throw new xplogs_1.XpFatal({function:"rankCard()",message:"Unable to load background image, is it valid?"})}),n=await(0,canvas_1.loadImage)(user.avatarURL).catch(()=>{throw new xplogs_1.XpFatal({function:"rankCard()",message:"Unable to load user's AvatarURL, is it reachable?"})});let c=await database_1.db.findOne({collection:"simply-xps",data:{guild:guild.id,user:user.id}});if(!c){if(!xp_1.xp.auto_create)throw new xplogs_1.XpFatal({function:"rankCard()",message:"User not found in database"});c=await(0,xp_1.create)(user.id,guild.id,user.username)}return d=await database_1.db.find({collection:"simply-xps",data:{guild:guild.id}}),c.position=d.sort((a,b)=>b.xp-a.xp).findIndex(u=>u.user===user.id)+1,options?.legacy?(d=user.username.replace(/[\u007f-\uffff]/g,""),e=options?.color||"#9900ff",a=options?.lvlbar||"#ffffff",options=options?.lvlbarBg||"#ffffff",o=shortener(c.xp)+(" "+locales.xp),t=locales.level+(" "+shortener(c.level)),r=(0,utilities_1.convertFrom)(c.level+1),l=(0,utilities_1.convertFrom)(c.level),l=100*(c.xp-l)/(r-l)*660/100,cachedRankContext&&cachedRankCanvas?(i=cachedRankCanvas,s=cachedRankContext):(i=(0,canvas_1.createCanvas)(1080,400),RoundedBox(s=i.getContext("2d"),0,0,i.width,i.height,50),s.clip(),s.fillStyle="#000000",s.fillRect(0,0,1080,400),s.globalAlpha=.7,s.drawImage(cachedRankImage,-5,0,1090,400),s.restore(),s.fillStyle="#000000",s.globalAlpha=.4,s.fillRect(40,0,240,i.height),s.globalAlpha=1),s.save(),RoundedBox(s,70,30,180,180,50),s.strokeStyle=e,s.lineWidth=15,s.stroke(),s.clip(),s.drawImage(n,70,30,180,180),s.restore(),s.save(),RoundedBox(s,70,320,180,50,20),s.strokeStyle="#BFC85A22",s.stroke(),s.clip(),s.fillStyle=e,s.globalAlpha=1,s.fillRect(70,320,180,50),s.globalAlpha=1,s.fillStyle="#ffffff",s.textAlign="center",dynamicFont(s,o,160,358,160,32),s.restore(),s.save(),RoundedBox(s,70,240,180,50,20),s.strokeStyle="#BFC85A22",s.stroke(),s.clip(),s.fillStyle=e,s.globalAlpha=1,s.fillRect(70,240,180,50),s.globalAlpha=1,s.fillStyle="#ffffff",s.textAlign="center",dynamicFont(s,t,160,278,160,32),s.restore(),s.save(),s.textAlign="left",s.fillStyle="#ffffff",s.shadowColor="#000000",s.shadowBlur=15,s.shadowOffsetX=1,s.shadowOffsetY=1,s.font='39px "Sans Serif"',s.fillText(d,390,80),s.restore(),s.save(),s.textAlign="right",s.fillStyle="#ffffff",s.shadowColor="#000000",s.shadowBlur=15,s.shadowOffsetX=1,s.shadowOffsetY=1,s.font='55px "Sans Serif"',s.fillText("#"+c.position,i.width-55,80),s.restore(),s.save(),RoundedBox(s,390,305,660,70,Number(20)),s.strokeStyle="#BFC85A22",s.stroke(),s.clip(),s.fillStyle="#ffffff",s.textAlign="center",dynamicFont(s,guild.name,720,355,700,45),s.globalAlpha=.2,s.fillRect(390,305,660,70),s.restore(),s.save(),RoundedBox(s,390,145,660,50,20),s.strokeStyle="#BFC85A22",s.stroke(),s.clip(),s.fillStyle=options,s.globalAlpha=.2,s.fillRect(390,145,660,50),s.restore(),s.save(),RoundedBox(s,390,145,l,50,20),s.strokeStyle="#BFC85A22",s.stroke(),s.clip(),s.fillStyle=a,s.globalAlpha=.5,s.fillRect(390,145,l,50),s.restore(),s.save(),s.textAlign="left",s.fillStyle="#ffffff",s.globalAlpha=.8,s.font='30px "Sans Serif"',s.fillText(locales.next_level+": "+shortener(r)+" "+locales.xp,390,230),s.restore(),n="{current} / {needed}".replace(/{needed}/g,shortener(r)).replace(/{current}/g,shortener(c.xp)),s.textAlign="center",s.fillStyle="#474747",s.globalAlpha=1,s.font='30px "Sans Serif"',s.fillText(n,730,180)):i=(0,canvas_1.createCanvas)(1080,360),{attachment:i.toBuffer("image/png"),description:"Simply-XP Rank Card",name:"rank.png"}}
|
|
13
13
|
/**
|
|
14
14
|
* Generate a simple leaderboard card
|
|
15
15
|
* @async
|
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
* @link [Documentation](https://simplyxp.js.org/docs/leaderboard)
|
|
21
21
|
* @returns {Promise<{attachment: Buffer, description: string, name: string}>}
|
|
22
22
|
* @throws {XpFatal} - If parameters are not provided correctly
|
|
23
|
-
*/async function leaderboardCard(data,options={},guildInfo,locales={}){var e,a;if(!data||data.length<1)throw new xplogs_1.XpFatal({function:"leaderboardCard()",message:"There must be at least 1 user in the data array"});!cachedLeaderboardArtwork&&options?.artworkImage&&(cachedLeaderboardArtwork=await(0,canvas_1.loadImage)(options.artworkImage)),!cachedLeaderboardImage&&options?.backgroundImage&&(cachedLeaderboardImage=await(0,canvas_1.loadImage)(options.backgroundImage)),canvas_1.GlobalFonts.registerFromPath(options?.font||(0,path_1.join)(__dirname,"Fonts","
|
|
23
|
+
*/async function leaderboardCard(data,options={},guildInfo,locales={}){var e,a;if(!data||data.length<1)throw new xplogs_1.XpFatal({function:"leaderboardCard()",message:"There must be at least 1 user in the data array"});!cachedLeaderboardArtwork&&options?.artworkImage&&(cachedLeaderboardArtwork=await(0,canvas_1.loadImage)(options.artworkImage).catch(()=>{throw new xplogs_1.XpFatal({function:"leaderboardCard()",message:"Unable to load artwork image, is it valid?"})})),!cachedLeaderboardImage&&options?.backgroundImage&&(cachedLeaderboardImage=await(0,canvas_1.loadImage)(options.backgroundImage).catch(()=>{throw new xplogs_1.XpFatal({function:"leaderboardCard()",message:"Unable to load background image, is it valid?"})})),canvas_1.GlobalFonts.registerFromPath(options?.font||(0,path_1.join)(__dirname,"Fonts","BalooBhaijaan-Regular.otf"),"Sans Serif"),locales.level||(locales.level="LEVEL"),locales.members||(locales.members="Members"),data=data.slice(0,8);let o,t,r,l=(r=options?.light?{artworkColors:options?.artworkColors||["#374bff","#5f69ff"],backgroundColor:"#f0f0eb",borderColors:options?.borderColors||["#ffa237","#ffcc6b"],evenColor:"#dcdcdc",oddColor:"#c8c8c8",primaryTextColor:"#000000",secondaryTextColor:"rgba(0,0,0,0.5)"}:{artworkColors:options?.artworkColors||["#374bff","#333793"],backgroundColor:"#141414",borderColors:options?.borderColors||["#ffa237","#b67125"],evenColor:"#1e1e1e",oddColor:"#282828",primaryTextColor:"#ffffff",secondaryTextColor:"rgba(255,255,255,0.5)"},cachedLeaderboardCanvas&&cachedLeaderboardContext?(o=cachedLeaderboardCanvas,t=cachedLeaderboardContext):(o=(0,canvas_1.createCanvas)(1350,1080),RoundedBox(t=o.getContext("2d"),0,0,o.width,o.height,20),t.clip(),(e=t.createLinearGradient(0,0,o.width,0)).addColorStop(0,r.artworkColors[0]),e.addColorStop(1,r.artworkColors[1]),t.fillStyle=e,t.fillRect(0,0,o.width,220),cachedLeaderboardArtwork&&(t.fillStyle="#000000",t.fillRect(0,0,o.width,220),t.globalAlpha=.5,t.drawImage(cachedLeaderboardArtwork,0,0,o.width,220),t.globalAlpha=1),t.fillStyle=options.backgroundColor||r.backgroundColor,t.fillRect(0,220,o.width,1080),cachedLeaderboardImage&&(t.globalAlpha=.9,t.drawImage(cachedLeaderboardImage,0,220,o.width,1080),t.globalAlpha=1)),guildInfo&&guildInfo?.imageURL&&guildInfo?.name&&guildInfo?.memberCount&&(e=await(0,canvas_1.loadImage)(guildInfo.imageURL),t.save(),t.beginPath(),t.arc(150,110,90,0,2*Math.PI,!0),t.closePath(),t.clip(),t.drawImage(e,60,20,180,180),t.restore(),(options=t.createLinearGradient(0,0,0,220)).addColorStop(0,r.borderColors[0]),options.addColorStop(1,r.borderColors[1]),t.strokeStyle=options,t.lineWidth=10,t.beginPath(),t.arc(150,110,90,0,2*Math.PI,!0),t.stroke(),t.fillStyle=r.primaryTextColor,t.font='60px "Sans Serif"',t.fillText(guildInfo.name,270,110),t.fillStyle=r.secondaryTextColor,t.font='40px "Sans Serif"',t.fillText(guildInfo.memberCount+" "+locales.members,270,160)),r.evenColor);for(let e=0;e<data.length;e++)a=300+90*e,1===data.length?RoundedBox(t,30,a,1290,90,20):0===e?RoundedBox(t,30,a,1290,90,20,{top:!0,bottom:!1}):e===data.length-1?RoundedBox(t,30,a,1290,90,20,{top:!1,bottom:!0}):RoundedBox(t,30,a,1290,90,0),t.fillStyle=l,t.globalAlpha=cachedLeaderboardImage?.5:1,t.fill(),t.globalAlpha=1,t.textAlign="left",t.font='30px "Sans Serif"',t.fillStyle=r.secondaryTextColor,t.fillText(e+1+".",60,55+a),t.textAlign="left",t.font='40px "Sans Serif"',t.fillStyle=r.primaryTextColor,t.fillText(data[e]?.name||data[e]?.user||"???",120,60+a),t.textAlign="right",t.font='30px "Sans Serif"',t.fillStyle=r.primaryTextColor,t.fillText(shortener(data[e]?.level)||"???",1270,55+a),t.fillStyle=r.secondaryTextColor,t.fillText(locales.level,1270-t.measureText(shortener(data[e]?.level)||"???").width-15,55+a),l=l===r.evenColor?r.oddColor:r.evenColor;return{attachment:o.toBuffer("image/png"),description:"Simply-XP Leaderboard Card",name:"leaderboard.png"}}function RoundedBox(ctx,x,y,width,height,radius,roundCorners={top:!0,bottom:!0}){ctx.beginPath(),ctx.moveTo(x+(roundCorners.top?radius:0),y),ctx.lineTo(x+width-(roundCorners.top?radius:0),y),roundCorners.top&&ctx.quadraticCurveTo(x+width,y,x+width,y+radius),ctx.lineTo(x+width,y+height-(roundCorners.bottom?radius:0)),roundCorners.bottom&&ctx.quadraticCurveTo(x+width,y+height,x+width-radius,y+height),ctx.lineTo(x+(roundCorners.bottom?radius:0),y+height),roundCorners.bottom&&ctx.quadraticCurveTo(x,y+height,x,y+height-radius),ctx.lineTo(x,y+(roundCorners.top?radius:0)),roundCorners.top&&ctx.quadraticCurveTo(x,y,x+radius,y),ctx.closePath()}function shortener(count){var e,a=["","k","M","B","T","Qa","Qi","Sx","Sp"];return count&&0!==count?count===1/0?"∞":(e=Math.floor(Math.log(count)/Math.log(1e3)),a.length<=e?count.toFixed(0)+a[a.length-1]:(count/Math.pow(1e3,e)).toFixed(0===e?0:2)+a[e]):"0"}function dynamicFont(context,text,x,y,maxWidth,maxSize){let e=maxSize;for(;0<e&&(context.font=e+'px "Sans Serif"',!(context.measureText(text).width<maxWidth));)e--;context.textAlign="center",context.fillText(text,x,y)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.RoundedBox=exports.leaderboardCard=exports.rankCard=void 0;const canvas_1=require("@napi-rs/canvas"),xplogs_1=require("./functions/xplogs"),database_1=require("./functions/database"),utilities_1=require("./functions/utilities"),path_1=require("path"),xp_1=require("../xp");let cachedRankImage,cachedRankCanvas,cachedRankContext,cachedLeaderboardArtwork,cachedLeaderboardCanvas,cachedLeaderboardContext,cachedLeaderboardImage;exports.rankCard=rankCard,exports.leaderboardCard=leaderboardCard,exports.RoundedBox=RoundedBox;
|
package/lib/src/charts.d.ts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/**
|
|
3
|
+
* Chart options
|
|
4
|
+
* @property {string} font - Font of the chart
|
|
5
|
+
* @property {"blue" | "dark" | "discord" | "green" | "orange" | "red" | "space" | "yellow"} theme - Theme of the chart
|
|
6
|
+
* @property {number} limit - Limit of users to return (2-10)
|
|
7
|
+
*/
|
|
2
8
|
export interface ChartOptions {
|
|
3
|
-
|
|
4
|
-
limit?:
|
|
5
|
-
|
|
9
|
+
font?: string;
|
|
10
|
+
limit?: 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
|
|
11
|
+
theme?: "blue" | "dark" | "discord" | "green" | "orange" | "red" | "space" | "yellow";
|
|
12
|
+
type?: "bar" | "doughnut" | "pie";
|
|
6
13
|
}
|
|
7
14
|
/**
|
|
8
15
|
* Creates a chart
|
|
@@ -10,8 +17,11 @@ export interface ChartOptions {
|
|
|
10
17
|
* @param {string} guildId
|
|
11
18
|
* @param {ChartOptions?} options
|
|
12
19
|
* @link `Documentation:` https://simplyxp.js.org/docs/charts
|
|
13
|
-
* @returns {Promise<
|
|
14
|
-
* @throws {XpFatal} If invalid parameters are provided
|
|
20
|
+
* @returns {Promise<{attachment: Buffer, description: string, name: string}>} Chart attachment
|
|
21
|
+
* @throws {XpFatal} If invalid parameters are provided, or if there are not enough users to create a chart
|
|
15
22
|
*/
|
|
16
|
-
export declare function charts(guildId: string, options?: ChartOptions): Promise<
|
|
17
|
-
|
|
23
|
+
export declare function charts(guildId: string, options?: ChartOptions): Promise<{
|
|
24
|
+
attachment: Buffer;
|
|
25
|
+
description: string;
|
|
26
|
+
name: string;
|
|
27
|
+
}>;
|
package/lib/src/charts.js
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* @param {string} guildId
|
|
6
6
|
* @param {ChartOptions?} options
|
|
7
7
|
* @link `Documentation:` https://simplyxp.js.org/docs/charts
|
|
8
|
-
* @returns {Promise<
|
|
9
|
-
* @throws {XpFatal} If invalid parameters are provided
|
|
10
|
-
*/
|
|
11
|
-
async function charts(guildId,options={}){if(!guildId)throw new xplogs_1.XpFatal({function:"charts()",message:"No Guild ID Provided"});if(options)throw options.limit&&10<options.limit&&(options.limit=10),options.type||(options.type="bar"),new xplogs_1.XpFatal({function:"charts()",message:"[V2] Under Development | Should be here within 2-3 dev releases."});throw new xplogs_1.XpFatal({function:"charts()",message:"No Options Provided"})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.charts=void 0;const xplogs_1=require("./functions/xplogs");exports.charts=charts;
|
|
8
|
+
* @returns {Promise<{attachment: Buffer, description: string, name: string}>} Chart attachment
|
|
9
|
+
* @throws {XpFatal} If invalid parameters are provided, or if there are not enough users to create a chart
|
|
10
|
+
*/async function charts(guildId,options={}){var t,r,a,F,o,l,i,s,d,n;if(!guildId)throw new xplogs_1.XpFatal({function:"charts()",message:"No Guild ID Provided"});if(!options)throw new xplogs_1.XpFatal({function:"charts()",message:"No Options Provided"});options.theme||(options.theme="blue"),options.type||(options.type="bar");let f={background:"#FFFFFF",barColor:"#FFFFFF",pieColors:["#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF"],textColor:"#FFFFFF"};if((t=await(0,leaderboard_1.leaderboard)(guildId,Math.min(Math.max(options?.limit||10,2),10)).catch(XPError=>{throw new xplogs_1.XpFatal({function:"charts()",message:XPError.message})})).length<2)throw new xplogs_1.XpFatal({function:"charts()",message:"Not enough users to create a chart"});switch(t.sort((a,b)=>b.position-a.position),canvas_1.GlobalFonts.registerFromPath(options?.font||(0,path_1.join)(__dirname,"Fonts","BalooBhaijaan-Regular.otf"),"Sans Serif"),options.theme){case"blue":f={background:"#1e1e3c",barColor:"#747fff",pieColors:["#747fff","#55b9f3","#4dc7ec","#3ad5e5","#32e3dd","#2cf2d4","#26ffd2","#30edb4","#3cda96","#48c878"],textColor:"#FFFFFF"};break;case"dark":f={background:"#1e1e1e",barColor:"#747474",pieColors:["#747474","#8f8f8f","#a8a8a8","#c1c1c1","#dadada","#f4f4f4","#ffffff","#ffffff","#ffffff","#ffffff"],textColor:"#FFFFFF"};break;case"discord":f={background:"#36393f",barColor:"#5865F2",pieColors:["#5865F2","#57F287","#FEE75C","#ED4245","#F47FFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF"],textColor:"#FFFFFF"};break;case"green":f={background:"#1e321e",barColor:"#74ff7f",pieColors:["#74ff7f","#55f3a0","#4decb2","#3dd5c3","#32cdd5","#2cc6e6","#26bfee","#30a8e6","#3c91dd","#487ad4"],textColor:"#FFFFFF"};break;case"orange":f={background:"#321e1e",barColor:"#ff9f74",pieColors:["#ff9f74","#f3b055","#ecbe4d","#d5c63d","#cdd532","#c6e62c","#bfe626","#a8e630","#91dd3c","#7ad448"],textColor:"#FFFFFF"};break;case"red":f={background:"#321e1e",barColor:"#ff7474",pieColors:["#ff7474","#f35555","#ec4d4d","#d53d3d","#cd3232","#c62c2c","#bf2626","#a83030","#913c3c","#7a4848"],textColor:"#FFFFFF"};break;case"space":f={background:"#001F3F",barColor:"#192E5B",pieColors:["#192E5B","#1F3F7F","#264FA3","#2C5FC7","#337FEA","#3D8FFF","#4D9FFF","#5DAFFF","#6DBFFF","#7DCFFF"],textColor:"#FFFFFF"};break;case"yellow":f={background:"#32321e",barColor:"#ffff74",pieColors:["#ffff74","#f3f355","#ecf24d","#d5eb3d","#cde532","#c6e02c","#bfe626","#a8df30","#91d93c","#7ad448"],textColor:"#FFFFFF"}}const c=(0,canvas_1.createCanvas)(920,600),h=c.getContext("2d"),u=Math.max(...t.map(user=>user.level));if((0,cards_1.RoundedBox)(h,0,0,c.width,c.height,25),h.clip(),h.fillStyle=f.background,h.fillRect(0,0,c.width,c.height),"space"===options.theme){h.clearRect(0,0,c.width,c.height),(guildId=h.createRadialGradient(c.width/2,c.height/2,1,c.width/2,c.height/2,Math.max(c.width,c.height))).addColorStop(0,"#000000"),guildId.addColorStop(1,"#001F3F"),h.fillStyle=guildId,h.fillRect(0,0,c.width,c.height),(guildId=h.createRadialGradient(150,150,10,150,150,100)).addColorStop(0,"#F2F2F2"),guildId.addColorStop(.8,"#D3D3D3"),guildId.addColorStop(1,"#001F3F"),h.fillStyle=guildId,h.beginPath(),h.arc(150,150,100,0,2*Math.PI),h.fill(),r=["#6B6B6B","#AA8F00","#473E83","#456579"];for(let e=0;e<r.length;e++)a=Math.random()*c.width,F=Math.random()*c.height,o=50*Math.random()+30,h.beginPath(),h.arc(a,F,o,0,2*Math.PI),h.fillStyle=r[e]||"#FFFFFF",h.fill();h.filter="blur(5px)",h.drawImage(c,0,0),h.filter="none";for(let e=0;e<100;e++)l=Math.random()*c.width,i=Math.random()*c.height,s=2*Math.random(),h.beginPath(),h.arc(l,i,s,0,2*Math.PI),h.fillStyle="#FFFFFF",h.fill()}switch(options.type){case"bar":{n=h.measureText(u.toString()).width,d=c.width-n-60-40;const g=c.height-100-40,p=d/t.length-20,x=20+n+40,b=c.height-50-20;await Promise.all(t.map(async(user,index)=>{var e,t,r=user.level/u*g,index=x+index*(20+p),a=b-r,r=(h.fillStyle=f.barColor,h.strokeStyle=f.barColor,h.lineWidth=2,(0,cards_1.RoundedBox)(h,index,a,p,r,10),h.fill(),h.stroke(),index+p/2),index=(h.fillStyle=f.textColor,h.font="22px Sans Serif",user.level.toString()),F=h.measureText(index).width,a=a-10,index=(h.fillText(index,r-F/2,a),user?.name||user.user),F=h.measureText(index).width,a=(h.font=Math.min(Math.floor(p/F*16),18)+"px Sans Serif",F=h.measureText(index).width,30+b);"space"===options.theme&&(e=r-(user=F+10)/2,t=a-18,h.fillStyle="rgba(0, 0, 0, 0.5)",h.fillRect(e,t,user,22)),h.fillStyle=f.textColor,h.fillText(index,r-F/2,a)}))}break;case"doughnut":{d=c.width-40,n=c.height-40;const C=t.reduce((sum,user)=>sum+user.level,0),m=c.width/2,w=c.height/2,S=Math.min(d,n)/3,y=.6*S;let e=-Math.PI/2;await Promise.all(t.map(async(user,index)=>{user=user.level/C,user=e+2*Math.PI*user,h.fillStyle=f.pieColors[index%f.pieColors.length]||"#FFFFFF",h.beginPath(),h.moveTo(m+S*Math.cos(e),w+S*Math.sin(e)),h.arc(m,w,S,e,user),h.lineTo(m+y*Math.cos(user),w+y*Math.sin(user)),h.arc(m,w,y,user,e,!0),h.closePath(),h.fill(),e=user}));const M=c.height-20-20*t.length;h.fillStyle="rgba(0,0,0,0.25)",h.fillRect(15,M-5,200,20*t.length+5),h.font="12px Sans Serif",t.forEach((user,index)=>{var user=user?.name||user.user,e=f.pieColors[index%f.pieColors.length],index=M+20*index;h.fillStyle=e||"#FFFFFF",h.fillRect(20,index,15,15),h.fillStyle=f.textColor,h.fillText(user,40,11.5+index)})}break;case"pie":{d=c.width-40,n=c.height-40;const v=t.reduce((sum,user)=>sum+user.level,0),k=c.width/2,P=c.height/2,I=Math.min(d,n)/3;let e=-Math.PI/2;await Promise.all(t.map(async(user,index)=>{user=user.level/v,user=e+2*Math.PI*user,h.fillStyle=f.pieColors[index%f.pieColors.length]||"#FFFFFF",h.beginPath(),h.moveTo(k,P),h.arc(k,P,I,e,user),h.closePath(),h.fill(),e=user}));const _=c.height-20-20*t.length;h.fillStyle="rgba(0,0,0,0.25)",h.fillRect(15,_-5,200,20*t.length+5),h.font="12px Sans Serif",t.forEach((user,index)=>{var user=user?.name||user.user,e=f.pieColors[index%f.pieColors.length],index=_+20*index;h.fillStyle=e||"#FFFFFF",h.fillRect(20,index,15,15),h.fillStyle=f.textColor,h.fillText(user,40,11.5+index)})}break;default:throw new xplogs_1.XpFatal({function:"charts()",message:"Invalid chart type provided"})}return{attachment:c.toBuffer("image/png"),description:"Chart",name:"chart.png"}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.charts=void 0;const canvas_1=require("@napi-rs/canvas"),path_1=require("path"),leaderboard_1=require("./leaderboard"),cards_1=require("./cards"),xplogs_1=require("./functions/xplogs");exports.charts=charts;
|
package/lib/src/connect.js
CHANGED
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
* @link `Documentation:` https://simplyxp.js.org/docs/connect
|
|
9
9
|
* @returns {Promise<boolean>}
|
|
10
10
|
* @throws {XpFatal} If an invalid type is provided or if the value is not provided.
|
|
11
|
-
*/
|
|
12
|
-
async function connect(uri,options={type:void 0}){var o,{type:e,auto_create:t,auto_purge:r,notify:a,debug:n}=options;if(!uri)throw new xplogs_1.XpFatal({function:"connect()",message:"No URI Provided"});switch(!1===a&&(xp_1.xp.notify=!1),t&&(xp_1.xp.auto_create=!0),r&&(xp_1.xp.auto_purge=!0),n&&(xp_1.xp.debug=!0),e||(options.type="mongodb",xplogs_1.XpLog.warn("connect()","Database type not provided, defaulting to MongoDB")),e){case"mongodb":if(o=(await Promise.resolve().then(()=>__importStar(require("mongodb")))).MongoClient,!await checkPackageVersion("mongodb"))return xplogs_1.XpLog.err("connect()","MongoDB V4 or higher is required");o=await o.connect(uri).catch(error=>{throw new xplogs_1.XpFatal({function:"connect()",message:error.message})}),xp_1.xp.dbType="mongodb",xp_1.xp.database=o||void 0;break;case"sqlite":try{var[s,i]=await Promise.all([Promise.resolve().then(()=>__importStar(require("better-sqlite3"))),checkPackageVersion("sqlite")]);if(!i)return xplogs_1.XpLog.err("connect()","better-sqlite3 V7 or higher is required");xp_1.xp.database=new s.default(uri),xp_1.xp.dbType="sqlite",xp_1.xp.database.exec(`CREATE TABLE IF NOT EXISTS "simply-xps"
|
|
11
|
+
*/async function connect(uri,options={type:void 0}){var e,{type:o,auto_create:t,auto_purge:r,notify:a,debug:n}=options;if(!uri)throw new xplogs_1.XpFatal({function:"connect()",message:"No URI Provided"});switch(!1===a&&(xp_1.xp.notify=!1),t&&(xp_1.xp.auto_create=!0),r&&(xp_1.xp.auto_purge=!0),n&&(xp_1.xp.debug=!0),o||(options.type="mongodb",xplogs_1.XpLog.warn("connect()","Database type not provided, defaulting to MongoDB")),o){case"mongodb":if(e=(await Promise.resolve().then(()=>__importStar(require("mongodb")))).MongoClient,!await checkPackageVersion("mongodb"))return xplogs_1.XpLog.err("connect()","MongoDB V4 or higher is required");e=await e.connect(uri).catch(error=>{throw new xplogs_1.XpFatal({function:"connect()",message:error.message})}),xp_1.xp.dbType="mongodb",xp_1.xp.database=e||void 0;break;case"sqlite":try{var[s,i]=await Promise.all([Promise.resolve().then(()=>__importStar(require("better-sqlite3"))),checkPackageVersion("sqlite")]);if(!i)return xplogs_1.XpLog.err("connect()","better-sqlite3 V7 or higher is required");xp_1.xp.database=new s.default(uri),xp_1.xp.dbType="sqlite",xp_1.xp.database.exec(`CREATE TABLE IF NOT EXISTS "simply-xps"
|
|
13
12
|
(
|
|
14
13
|
user TEXT NOT NULL,
|
|
15
14
|
guild TEXT NOT NULL,
|
|
@@ -20,13 +19,12 @@ async function connect(uri,options={type:void 0}){var o,{type:e,auto_create:t,au
|
|
|
20
19
|
(
|
|
21
20
|
gid TEXT UNIQUE,
|
|
22
21
|
lvlrole TEXT NOT NULL
|
|
23
|
-
)`)}catch(
|
|
22
|
+
)`)}catch(o){if("object"==typeof o&&null!==o&&void 0!==(e=o).code&&"MODULE_NOT_FOUND"!==e.code)throw new xplogs_1.XpFatal({function:"connect()",message:e.message})}break;default:throw new xplogs_1.XpFatal({function:"connect()",message:"DATABASE TYPE NOT PROVIDED OR INVALID"})}return!!xp_1.xp.database&&(xplogs_1.XpLog.info("connect()","Connected to database!"),!0)}
|
|
24
23
|
/**
|
|
25
24
|
* Returns the package manager used
|
|
26
25
|
* @private
|
|
27
26
|
* @returns {Promise<"yarn" | "npm" | "pnpm">}
|
|
28
|
-
*/
|
|
29
|
-
async function getPackageManager(){const e=(await Promise.resolve().then(()=>__importStar(require("fs")))).existsSync;var o=["yarn.lock","pnpm-lock.yaml","pnpm-lock.json","package-lock.json"].filter(lockfile=>e(lockfile));if(1===o.length){if("yarn.lock"===o[0])return xplogs_1.XpLog.debug("getPackageManager()","Using Yarn"),"yarn";if("pnpm-lock.yaml"===o[0]||"pnpm-lock.json"===o[0])return xplogs_1.XpLog.debug("getPackageManager()","Using PNPM"),"pnpm"}return xplogs_1.XpLog.debug("getPackageManager()","Using NPM"),"npm"}
|
|
27
|
+
*/async function getPackageManager(){const e=(await Promise.resolve().then(()=>__importStar(require("fs")))).existsSync;var o=["yarn.lock","pnpm-lock.yaml","pnpm-lock.json","package-lock.json"].filter(lockfile=>e(lockfile));if(1===o.length){if("yarn.lock"===o[0])return xplogs_1.XpLog.debug("getPackageManager()","Using Yarn"),"yarn";if("pnpm-lock.yaml"===o[0]||"pnpm-lock.json"===o[0])return xplogs_1.XpLog.debug("getPackageManager()","Using PNPM"),"pnpm"}return xplogs_1.XpLog.debug("getPackageManager()","Using NPM"),"npm"}
|
|
30
28
|
/**
|
|
31
29
|
* Check database package versions
|
|
32
30
|
* @private
|
package/lib/src/create.js
CHANGED
|
@@ -8,5 +8,4 @@
|
|
|
8
8
|
* @link `Documentation:` https://simplyxp.js.org/docs/create
|
|
9
9
|
* @returns {Promise<UserResult>}
|
|
10
10
|
* @throws {XpFatal} If invalid parameters are provided
|
|
11
|
-
*/
|
|
12
|
-
async function create(userId,guildId,username){if(!userId)throw new xplogs_1.XpFatal({function:"create()",message:"User ID was not provided"});if(!guildId)throw new xplogs_1.XpFatal({function:"create()",message:"Guild ID was not provided"});var e;if(username)return await(e=(await Promise.resolve().then(()=>__importStar(require("./functions/database")))).db).findOne({collection:"simply-xps",data:{user:userId,guild:guildId}})||e.createOne({collection:"simply-xps",data:{name:username,user:userId,guild:guildId,level:0,xp:0}});throw new xplogs_1.XpFatal({function:"create()",message:"Username was not provided"})}var __createBinding=this&&this.__createBinding||(Object.create?function(o,m,k,k2){void 0===k2&&(k2=k);var e=Object.getOwnPropertyDescriptor(m,k);e&&("get"in e?m.__esModule:!e.writable&&!e.configurable)||(e={enumerable:!0,get:function(){return m[k]}}),Object.defineProperty(o,k2,e)}:function(o,m,k,k2){o[k2=void 0===k2?k:k2]=m[k]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(o,v){Object.defineProperty(o,"default",{enumerable:!0,value:v})}:function(o,v){o.default=v}),__importStar=this&&this.__importStar||function(mod){var e,t;if(mod&&mod.__esModule)return mod;if(e={},null!=mod)for(t in mod)"default"!==t&&Object.prototype.hasOwnProperty.call(mod,t)&&__createBinding(e,mod,t);return __setModuleDefault(e,mod),e};Object.defineProperty(exports,"__esModule",{value:!0}),exports.create=void 0;const xplogs_1=require("./functions/xplogs");exports.create=create;
|
|
11
|
+
*/async function create(userId,guildId,username){if(!userId)throw new xplogs_1.XpFatal({function:"create()",message:"User ID was not provided"});if(!guildId)throw new xplogs_1.XpFatal({function:"create()",message:"Guild ID was not provided"});var e;if(username)return await(e=(await Promise.resolve().then(()=>__importStar(require("./functions/database")))).db).findOne({collection:"simply-xps",data:{user:userId,guild:guildId}})||e.createOne({collection:"simply-xps",data:{name:username,user:userId,guild:guildId,level:0,xp:0}});throw new xplogs_1.XpFatal({function:"create()",message:"Username was not provided"})}var __createBinding=this&&this.__createBinding||(Object.create?function(o,m,k,k2){void 0===k2&&(k2=k);var e=Object.getOwnPropertyDescriptor(m,k);e&&("get"in e?m.__esModule:!e.writable&&!e.configurable)||(e={enumerable:!0,get:function(){return m[k]}}),Object.defineProperty(o,k2,e)}:function(o,m,k,k2){o[k2=void 0===k2?k:k2]=m[k]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(o,v){Object.defineProperty(o,"default",{enumerable:!0,value:v})}:function(o,v){o.default=v}),__importStar=this&&this.__importStar||function(mod){var e,t;if(mod&&mod.__esModule)return mod;if(e={},null!=mod)for(t in mod)"default"!==t&&Object.prototype.hasOwnProperty.call(mod,t)&&__createBinding(e,mod,t);return __setModuleDefault(e,mod),e};Object.defineProperty(exports,"__esModule",{value:!0}),exports.create=void 0;const xplogs_1=require("./functions/xplogs");exports.create=create;
|
package/lib/src/fetch.js
CHANGED
|
@@ -8,5 +8,4 @@
|
|
|
8
8
|
* @link `Documentation:` https://simplyxp.js.org/docs/fetch
|
|
9
9
|
* @returns {Promise<{name: string | null, user: string, guild: string, level: number, position: number, xp: number}>}
|
|
10
10
|
* @throws {XpFatal} If invalid parameters are provided, or if the user data is not found.
|
|
11
|
-
*/
|
|
12
|
-
async function fetch(userId,guildId,username){if(!userId)throw new xplogs_1.XpFatal({function:"create()",message:"User ID was not provided"});if(!guildId)throw new xplogs_1.XpFatal({function:"create()",message:"Guild ID was not provided"});var e=await(await Promise.resolve().then(()=>__importStar(require("./functions/database")))).db.find({collection:"simply-xps",data:{guild:guildId}}),t=e.find(u=>u.user===userId);if(t)return e=e.sort((a,b)=>b.xp-a.xp).findIndex(u=>u.user===userId)+1,{name:t?.name,user:t.user,guild:t.guild,level:t.level,position:e,xp:t.xp};if(xp_1.xp.auto_create&&username)return(await Promise.resolve().then(()=>__importStar(require("./create")))).create(guildId,userId,username);throw new xplogs_1.XpFatal({function:"fetch()",message:"User data not found"})}var __createBinding=this&&this.__createBinding||(Object.create?function(o,m,k,k2){void 0===k2&&(k2=k);var e=Object.getOwnPropertyDescriptor(m,k);e&&("get"in e?m.__esModule:!e.writable&&!e.configurable)||(e={enumerable:!0,get:function(){return m[k]}}),Object.defineProperty(o,k2,e)}:function(o,m,k,k2){o[k2=void 0===k2?k:k2]=m[k]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(o,v){Object.defineProperty(o,"default",{enumerable:!0,value:v})}:function(o,v){o.default=v}),__importStar=this&&this.__importStar||function(mod){var e,t;if(mod&&mod.__esModule)return mod;if(e={},null!=mod)for(t in mod)"default"!==t&&Object.prototype.hasOwnProperty.call(mod,t)&&__createBinding(e,mod,t);return __setModuleDefault(e,mod),e};Object.defineProperty(exports,"__esModule",{value:!0}),exports.fetch=void 0;const xplogs_1=require("./functions/xplogs"),xp_1=require("../xp");exports.fetch=fetch;
|
|
11
|
+
*/async function fetch(userId,guildId,username){var e;if(!userId)throw new xplogs_1.XpFatal({function:"create()",message:"User ID was not provided"});if(!guildId)throw new xplogs_1.XpFatal({function:"create()",message:"Guild ID was not provided"});let t=(e=await(await Promise.resolve().then(()=>__importStar(require("./functions/database")))).db.find({collection:"simply-xps",data:{guild:guildId}})).find(u=>u.user===userId);if(!t){if(!xp_1.xp.auto_create||!username)throw new xplogs_1.XpFatal({function:"fetch()",message:"User data not found"});t=await(await Promise.resolve().then(()=>__importStar(require("./create")))).create(guildId,userId,username)}return guildId=e.sort((a,b)=>b.xp-a.xp).findIndex(u=>u.user===userId)+1,{name:t?.name,user:t.user,guild:t.guild,level:t.level,position:guildId,xp:t.xp}}var __createBinding=this&&this.__createBinding||(Object.create?function(o,m,k,k2){void 0===k2&&(k2=k);var e=Object.getOwnPropertyDescriptor(m,k);e&&("get"in e?m.__esModule:!e.writable&&!e.configurable)||(e={enumerable:!0,get:function(){return m[k]}}),Object.defineProperty(o,k2,e)}:function(o,m,k,k2){o[k2=void 0===k2?k:k2]=m[k]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(o,v){Object.defineProperty(o,"default",{enumerable:!0,value:v})}:function(o,v){o.default=v}),__importStar=this&&this.__importStar||function(mod){var e,t;if(mod&&mod.__esModule)return mod;if(e={},null!=mod)for(t in mod)"default"!==t&&Object.prototype.hasOwnProperty.call(mod,t)&&__createBinding(e,mod,t);return __setModuleDefault(e,mod),e};Object.defineProperty(exports,"__esModule",{value:!0}),exports.fetch=void 0;const xplogs_1=require("./functions/xplogs"),xp_1=require("../xp");exports.fetch=fetch;
|
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
* @param {string} functionName
|
|
6
6
|
* @returns {void}
|
|
7
7
|
* @private
|
|
8
|
-
*/
|
|
9
|
-
function handleError(error,functionName){throw new xplogs_1.XpFatal({function:"db."+functionName,message:error})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.db=void 0;const xplogs_1=require("./xplogs"),xp_1=require("../../xp");class db{
|
|
8
|
+
*/function handleError(error,functionName){throw new xplogs_1.XpFatal({function:"db."+functionName,message:error})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.db=void 0;const xplogs_1=require("./xplogs"),xp_1=require("../../xp");class db{
|
|
10
9
|
/**
|
|
11
10
|
* Gets a collection from the database.
|
|
12
11
|
* @param {collection} collection - The collection to get.
|
|
@@ -23,7 +22,7 @@ static getCollection(collection){if(!xp_1.xp.database)throw new xplogs_1.XpFatal
|
|
|
23
22
|
* @link https://simplyxp.js.org/docs/handlers/database#createOne Documentation
|
|
24
23
|
* @returns {Promise<UserResult | LevelRoleResult>} The created document.
|
|
25
24
|
* @throws {XpFatal} Throws an error if there is no database connection.
|
|
26
|
-
*/static async createOne(query){if(!xp_1.xp.database)throw new xplogs_1.XpFatal({function:"createOne()",message:"No database connection"});let e;switch(xp_1.xp.dbType){case"mongodb":
|
|
25
|
+
*/static async createOne(query){if(!xp_1.xp.database)throw new xplogs_1.XpFatal({function:"createOne()",message:"No database connection"});let e;switch(xp_1.xp.dbType){case"mongodb":xp_1.xp.database.db().collection(query.collection).insertOne(query.data).catch(error=>handleError(error,"createOne()")),e=db.findOne(query);break;case"sqlite":e="simply-xps"===query.collection?xp_1.xp.database.prepare('INSERT INTO "simply-xps" (user, guild, name, xp, level) VALUES (?, ?, ?, ?, ?)').run(query.data.user,query.data.guild,query.data?.name,query.data.xp,query.data.level):xp_1.xp.database.prepare('INSERT INTO "simply-xp-levelroles" (guild, level, role) VALUES (?, ?, ?)').run(query.data.guild,query.data.level,query.data.roles)}return e}
|
|
27
26
|
/**
|
|
28
27
|
* Deletes one document from the database.
|
|
29
28
|
*
|
|
@@ -7,13 +7,11 @@
|
|
|
7
7
|
* @link `Documentation:` https://simplyxp.js.org/docs/utilities/convert
|
|
8
8
|
* @returns {number} - The converted value. (XP to level or level to XP)
|
|
9
9
|
* @throws {XpFatal} If an invalid type is provided or if the value is not provided.
|
|
10
|
-
*/
|
|
11
|
-
function convertFrom(value,type="level"){if(isNaN(value))throw new xplogs_1.XpFatal({function:"convertFrom()",message:"Value was not provided"});if("xp"!==type&&"level"!==type)throw new xplogs_1.XpFatal({function:"convert()",message:"Invalid type provided"});if("level"===type)return Math.pow(value/.1,2);if("xp"===type)return Math.floor(.1*Math.sqrt(value));throw new xplogs_1.XpFatal({function:"convertFrom()",message:"Invalid type provided"})}
|
|
10
|
+
*/function convertFrom(value,type="level"){if(isNaN(value))throw new xplogs_1.XpFatal({function:"convertFrom()",message:"Value was not provided"});if("xp"!==type&&"level"!==type)throw new xplogs_1.XpFatal({function:"convert()",message:"Invalid type provided"});if("level"===type)return Math.pow(value/.1,2);if("xp"===type)return Math.floor(.1*Math.sqrt(value));throw new xplogs_1.XpFatal({function:"convertFrom()",message:"Invalid type provided"})}
|
|
12
11
|
/**
|
|
13
12
|
* Updates the options of the XP client.
|
|
14
13
|
* @param {NewClientOptions} clientOptions - The new options to update.
|
|
15
14
|
* @link `Documentation:` https://simplyxp.js.org/docs/utilities/updateOptions
|
|
16
15
|
* @returns {void} - Nothing.
|
|
17
16
|
* @throws {XpFatal} If an invalid option is provided.
|
|
18
|
-
*/
|
|
19
|
-
function updateOptions(clientOptions){if(!clientOptions)throw new xplogs_1.XpFatal({function:"updateOptions()",message:"Options were not provided"});if("object"!=typeof clientOptions)throw new xplogs_1.XpFatal({function:"updateOptions()",message:"Options must be an object"});if(xp_1.xp.auto_create=clientOptions.auto_create,xp_1.xp.auto_purge=clientOptions.auto_purge,xp_1.xp.notify=clientOptions.notify,xp_1.xp.debug=clientOptions.debug,clientOptions.dbOptions&&"object"==typeof clientOptions.dbOptions&&clientOptions.dbOptions.type&&clientOptions.dbOptions.database){var{type:clientOptions,database:t}=clientOptions.dbOptions;if(!(clientOptions&&"mongodb"===clientOptions||"sqlite"===clientOptions))throw new xplogs_1.XpFatal({function:"updateOptions()",message:"Invalid database type provided"});xp_1.xp.dbType=clientOptions,t&&(xp_1.xp.database=t,"mongodb"===xp_1.xp.dbType?(0,connect_1.checkPackageVersion)("mongodb").then(result=>{if(!result)throw new xplogs_1.XpFatal({function:"updateOptions()",message:"MongoDB V4 or higher is required"});xp_1.xp.database.db().command({ping:1}).catch(()=>{throw xp_1.xp.database=void 0,new xplogs_1.XpFatal({function:"updateOptions()",message:"Invalid MongoDB connection"})})}):"sqlite"===xp_1.xp.dbType&&(0,connect_1.checkPackageVersion)("sqlite").then(result=>{if(!result)throw new xplogs_1.XpFatal({function:"updateOptions()",message:"SQLite V7 or higher is required"});try{xp_1.xp.database.prepare("SELECT 1").get()}catch(t){throw new xplogs_1.XpFatal({function:"updateOptions()",message:"Invalid SQLite connection"})}}))}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.updateOptions=exports.convertFrom=void 0;const xplogs_1=require("./xplogs"),xp_1=require("../../xp"),connect_1=require("../connect");exports.convertFrom=convertFrom,exports.updateOptions=updateOptions;
|
|
17
|
+
*/function updateOptions(clientOptions){if(!clientOptions)throw new xplogs_1.XpFatal({function:"updateOptions()",message:"Options were not provided"});if("object"!=typeof clientOptions)throw new xplogs_1.XpFatal({function:"updateOptions()",message:"Options must be an object"});if(xp_1.xp.auto_create=clientOptions.auto_create,xp_1.xp.auto_purge=clientOptions.auto_purge,xp_1.xp.notify=clientOptions.notify,xp_1.xp.debug=clientOptions.debug,clientOptions.dbOptions&&"object"==typeof clientOptions.dbOptions&&clientOptions.dbOptions.type&&clientOptions.dbOptions.database){var{type:clientOptions,database:t}=clientOptions.dbOptions;if(!(clientOptions&&"mongodb"===clientOptions||"sqlite"===clientOptions))throw new xplogs_1.XpFatal({function:"updateOptions()",message:"Invalid database type provided"});xp_1.xp.dbType=clientOptions,t&&(xp_1.xp.database=t,"mongodb"===xp_1.xp.dbType?(0,connect_1.checkPackageVersion)("mongodb").then(result=>{if(!result)throw new xplogs_1.XpFatal({function:"updateOptions()",message:"MongoDB V4 or higher is required"});xp_1.xp.database.db().command({ping:1}).catch(()=>{throw xp_1.xp.database=void 0,new xplogs_1.XpFatal({function:"updateOptions()",message:"Invalid MongoDB connection"})})}):"sqlite"===xp_1.xp.dbType&&(0,connect_1.checkPackageVersion)("sqlite").then(result=>{if(!result)throw new xplogs_1.XpFatal({function:"updateOptions()",message:"SQLite V7 or higher is required"});try{xp_1.xp.database.prepare("SELECT 1").get()}catch(t){throw new xplogs_1.XpFatal({function:"updateOptions()",message:"Invalid SQLite connection"})}}))}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.updateOptions=exports.convertFrom=void 0;const xplogs_1=require("./xplogs"),xp_1=require("../../xp"),connect_1=require("../connect");exports.convertFrom=convertFrom,exports.updateOptions=updateOptions;
|
package/lib/src/leaderboard.d.ts
CHANGED
package/lib/src/leaderboard.js
CHANGED
|
@@ -7,5 +7,4 @@
|
|
|
7
7
|
* @link `Documentation:` https://simplyxp.js.org/docs/leaderboard
|
|
8
8
|
* @returns {Promise<User[]>} Array of all users in the leaderboard
|
|
9
9
|
* @throws {XpFatal} If guild ID is not provided or limit is less than 1
|
|
10
|
-
*/
|
|
11
|
-
async function leaderboard(guildId,limit){if(!guildId)throw new xplogs_1.XpFatal({function:"leaderboard()",message:"Guild ID was not provided"});if(limit&&limit<1)throw new xplogs_1.XpFatal({function:"leaderboard()",message:"Limit must be greater than 0"});guildId=(await database_1.db.find({collection:"simply-xps",data:{guild:guildId}})).sort((a,b)=>b.xp-a.xp);return guildId.forEach((user,index)=>user.position=index+1),limit?guildId.slice(0,limit):guildId}Object.defineProperty(exports,"__esModule",{value:!0}),exports.leaderboard=void 0;const xplogs_1=require("./functions/xplogs"),database_1=require("./functions/database");exports.leaderboard=leaderboard;
|
|
10
|
+
*/async function leaderboard(guildId,limit){if(!guildId)throw new xplogs_1.XpFatal({function:"leaderboard()",message:"Guild ID was not provided"});if(limit&&limit<1)throw new xplogs_1.XpFatal({function:"leaderboard()",message:"Limit must be greater than 0"});return(guildId=(await database_1.db.find({collection:"simply-xps",data:{guild:guildId}})).sort((a,b)=>b.xp-a.xp)).forEach((user,index)=>user.position=index+1),limit?guildId.slice(0,limit):guildId}Object.defineProperty(exports,"__esModule",{value:!0}),exports.leaderboard=void 0;const xplogs_1=require("./functions/xplogs"),database_1=require("./functions/database");exports.leaderboard=leaderboard;
|
package/lib/src/migrate.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @returns {Promise<boolean>} - Returns true if migration is successful
|
|
8
8
|
* @throws {XpLog.err} - If migration fails.
|
|
9
9
|
*/
|
|
10
|
-
static async discord_xp(deleteOld=!1){var e=await database_1.db.getCollection("levels").find().toArray();xplogs_1.XpLog.debug("migrate.discord_xp()",`FOUND ${e.length} DOCUMENTS`);try{for(const
|
|
10
|
+
static async discord_xp(deleteOld=!1){var e=await database_1.db.getCollection("levels").find().toArray();xplogs_1.XpLog.debug("migrate.discord_xp()",`FOUND ${e.length} DOCUMENTS`);try{for(const r of e)await database_1.db.findOne({collection:"simply-xps",data:{guild:r.guildID,user:r.userID}})||(await database_1.db.createOne({collection:"simply-xps",data:{guild:r.guildID,user:r.userID,xp:r.xp,level:(0,xp_1.convertFrom)(r.xp,"xp")}}),deleteOld&&await database_1.db.getCollection("levels").deleteOne({userID:r.userID,guildID:r.guildID}));return!0}catch(e){return xplogs_1.XpLog.err("migrate.discord_xp()",e),!1}}
|
|
11
11
|
/**
|
|
12
12
|
* Effortlessly migrate from MongoDB to SQLite. (or vice versa)
|
|
13
13
|
* @async
|
|
@@ -16,4 +16,4 @@ static async discord_xp(deleteOld=!1){var e=await database_1.db.getCollection("l
|
|
|
16
16
|
* @link `Documentation:` https://simplyxp.js.org/docs/migrate/database
|
|
17
17
|
* @returns {Promise<boolean>} - Returns true if migration is successful
|
|
18
18
|
* @throws {XpFatal} - If parameters are not provided correctly
|
|
19
|
-
*/static async fromDB(dbType,connection){if(!dbType)throw new xplogs_1.XpFatal({function:"migrate.database()",message:"No database type provided"});if(!connection)throw new xplogs_1.XpFatal({function:"migrate.database()",message:"No database connection provided"});if(xp_1.xp.dbType===dbType)return xplogs_1.XpLog.info("migrate.fromDB()","Same database received, that was unnecessary!");switch(dbType){case"mongodb":try{if(!await(0,connect_1.checkPackageVersion)("mongodb"))return xplogs_1.XpLog.err("migrate.fromDB()","MongoDB V4 or higher is required");connection.db().collection("simply-xps").find().toArray().
|
|
19
|
+
*/static async fromDB(dbType,connection){if(!dbType)throw new xplogs_1.XpFatal({function:"migrate.database()",message:"No database type provided"});if(!connection)throw new xplogs_1.XpFatal({function:"migrate.database()",message:"No database connection provided"});if(xp_1.xp.dbType===dbType)return xplogs_1.XpLog.info("migrate.fromDB()","Same database received, that was unnecessary!");let e;switch(dbType){case"mongodb":try{if(!await(0,connect_1.checkPackageVersion)("mongodb"))return xplogs_1.XpLog.err("migrate.fromDB()","MongoDB V4 or higher is required");e=connection.db().collection("simply-xps").find().toArray(),xplogs_1.XpLog.debug("migrate.fromDB()",`FOUND ${e.length} DOCUMENTS`)}catch(e){return xplogs_1.XpLog.err("migrate.fromDB()",e),!1}break;case"sqlite":try{if(!await(0,connect_1.checkPackageVersion)("sqlite"))return xplogs_1.XpLog.err("migrate.fromDB()","better-sqlite3 V7 or higher is required");e=connection.prepare("SELECT * FROM `simply-xps`").all(),xplogs_1.XpLog.debug("migrate.fromDB()",`FOUND ${e.length} ROWS`)}catch(e){return xplogs_1.XpLog.err("migrate.fromDB()",e),!1}}return await Promise.all(e.map(async user=>await database_1.db.findOne({collection:"simply-xps",data:{guild:user.guild,user:user.user}})?database_1.db.updateOne({collection:"simply-xps",data:{guild:user.guild,user:user.user}},{collection:"simply-xps",data:{guild:user.guild,user:user.user,name:user.name,xp:user.xp,level:user.level}}):database_1.db.createOne({collection:"simply-xps",data:{guild:user.guild,user:user.user,xp:user.xp,level:user.level}}))),!0}}exports.migrate=migrate;
|
package/lib/src/reset.js
CHANGED
|
@@ -9,5 +9,4 @@
|
|
|
9
9
|
* @link `Documentation:` https://simplyxp.js.org/docs/reset
|
|
10
10
|
* @returns {Promise<boolean>}
|
|
11
11
|
* @throws {XpFatal} If an invalid type is provided or if the value is not provided.
|
|
12
|
-
*/
|
|
13
|
-
async function reset(userId,guildId,erase=!1,username){var e;if(userId&&guildId)return e={guild:guildId,user:userId},await database_1.db.findOne({collection:"simply-xps",data:e})?(erase?await database_1.db.deleteOne({collection:"simply-xps",data:e}).catch(error=>{throw new xplogs_1.XpFatal({function:"reset()",message:error})}):await database_1.db.updateOne({collection:"simply-xps",data:{user:userId,guild:guildId}},{collection:"simply-xps",data:{...e,level:0,xp:0}}).catch(error=>{throw new xplogs_1.XpFatal({function:"reset()",message:error})}),!0):xp_1.xp.auto_create&&!erase&&username?(await database_1.db.createOne({collection:"simply-xps",data:e}).catch(error=>{throw new xplogs_1.XpFatal({function:"reset()",message:error.stack})}),!0):xplogs_1.XpLog.info("reset()","User was not found, we did not know what to do without a username.");throw new xplogs_1.XpFatal({function:"reset()",message:"Invalid parameters provided"})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.reset=void 0;const xplogs_1=require("./functions/xplogs"),xp_1=require("../xp"),database_1=require("./functions/database");exports.reset=reset;
|
|
12
|
+
*/async function reset(userId,guildId,erase=!1,username){var e;if(userId&&guildId)return e={guild:guildId,user:userId},await database_1.db.findOne({collection:"simply-xps",data:e})?(erase?await database_1.db.deleteOne({collection:"simply-xps",data:e}).catch(error=>{throw new xplogs_1.XpFatal({function:"reset()",message:error})}):await database_1.db.updateOne({collection:"simply-xps",data:{user:userId,guild:guildId}},{collection:"simply-xps",data:{...e,level:0,xp:0}}).catch(error=>{throw new xplogs_1.XpFatal({function:"reset()",message:error})}),!0):xp_1.xp.auto_create&&!erase&&username?(await database_1.db.createOne({collection:"simply-xps",data:e}).catch(error=>{throw new xplogs_1.XpFatal({function:"reset()",message:error.stack})}),!0):xplogs_1.XpLog.info("reset()","User was not found, we did not know what to do without a username.");throw new xplogs_1.XpFatal({function:"reset()",message:"Invalid parameters provided"})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.reset=void 0;const xplogs_1=require("./functions/xplogs"),xp_1=require("../xp"),database_1=require("./functions/database");exports.reset=reset;
|
package/lib/src/set.js
CHANGED
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
* @link `Documentation:` https://simplyxp.js.org/docs/setlevel
|
|
10
10
|
* @returns {Promise<UserResult>} - Object of user data on success
|
|
11
11
|
* @throws {XpFatal} - If parameters are not provided correctly
|
|
12
|
-
*/
|
|
13
|
-
async function setLevel(userId,guildId,level,username){if(!userId)throw new xplogs_1.XpFatal({function:"setLevel()",message:"User ID was not provided"});if(!guildId)throw new xplogs_1.XpFatal({function:"setLevel()",message:"Guild ID was not provided"});if(isNaN(level))throw new xplogs_1.XpFatal({function:"setLevel()",message:"Level was not provided"});if(await database_1.db.findOne({collection:"simply-xps",data:{user:userId,guild:guildId}}))return database_1.db.updateOne({collection:"simply-xps",data:{user:userId,guild:guildId}},{collection:"simply-xps",data:{user:userId,guild:guildId,level:level,xp:(0,utilities_1.convertFrom)(level)}});if(xp_1.xp.auto_create&&username)return database_1.db.createOne({collection:"simply-xps",data:{guild:guildId,user:userId,name:username,level:level,xp:(0,utilities_1.convertFrom)(level)}});throw new xplogs_1.XpFatal({function:"setLevel()",message:"User does not exist"})}
|
|
12
|
+
*/async function setLevel(userId,guildId,level,username){if(!userId)throw new xplogs_1.XpFatal({function:"setLevel()",message:"User ID was not provided"});if(!guildId)throw new xplogs_1.XpFatal({function:"setLevel()",message:"Guild ID was not provided"});if(isNaN(level))throw new xplogs_1.XpFatal({function:"setLevel()",message:"Level was not provided"});if(await database_1.db.findOne({collection:"simply-xps",data:{user:userId,guild:guildId}}))return database_1.db.updateOne({collection:"simply-xps",data:{user:userId,guild:guildId}},{collection:"simply-xps",data:{user:userId,guild:guildId,level:level,xp:(0,utilities_1.convertFrom)(level)}});if(xp_1.xp.auto_create&&username)return database_1.db.createOne({collection:"simply-xps",data:{guild:guildId,user:userId,name:username,level:level,xp:(0,utilities_1.convertFrom)(level)}});throw new xplogs_1.XpFatal({function:"setLevel()",message:"User does not exist"})}
|
|
14
13
|
/**
|
|
15
14
|
* Set user XP
|
|
16
15
|
* @async
|
|
@@ -21,5 +20,4 @@ async function setLevel(userId,guildId,level,username){if(!userId)throw new xplo
|
|
|
21
20
|
* @link `Documentation:` https://simplyxp.js.org/docs/setxp
|
|
22
21
|
* @returns {Promise<XPResult>} - Object of user data on success
|
|
23
22
|
* @throws {XpFatal} - If parameters are not provided correctly
|
|
24
|
-
*/
|
|
25
|
-
async function setXP(userId,guildId,xpData,username){if(!userId)throw new xplogs_1.XpFatal({function:"setXP()",message:"User ID was not provided"});if(!guildId)throw new xplogs_1.XpFatal({function:"setXP()",message:"Guild ID was not provided"});if(isNaN(xpData))throw new xplogs_1.XpFatal({function:"setXP()",message:"XP was not provided"});var e=await database_1.db.findOne({collection:"simply-xps",data:{user:userId,guild:guildId}});let s;if(e)s=await database_1.db.updateOne({collection:"simply-xps",data:{user:userId,guild:guildId}},{collection:"simply-xps",data:{user:userId,guild:guildId,level:(0,utilities_1.convertFrom)(xpData),xp:xpData}});else{if(!xp_1.xp.auto_create||!username)throw new xplogs_1.XpFatal({function:"setXP()",message:"User does not exist"});s=await database_1.db.createOne({collection:"simply-xps",data:{guild:guildId,user:userId,name:username,level:(0,utilities_1.convertFrom)(xpData),xp:xpData}})}return{...s,hasLevelledUp:s.level>e.level}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.setXP=exports.setLevel=void 0;const xplogs_1=require("./functions/xplogs"),utilities_1=require("./functions/utilities"),database_1=require("./functions/database"),xp_1=require("../xp");exports.setLevel=setLevel,exports.setXP=setXP;
|
|
23
|
+
*/async function setXP(userId,guildId,xpData,username){if(!userId)throw new xplogs_1.XpFatal({function:"setXP()",message:"User ID was not provided"});if(!guildId)throw new xplogs_1.XpFatal({function:"setXP()",message:"Guild ID was not provided"});if(isNaN(xpData))throw new xplogs_1.XpFatal({function:"setXP()",message:"XP was not provided"});var e=await database_1.db.findOne({collection:"simply-xps",data:{user:userId,guild:guildId}});let s;if(e)s=await database_1.db.updateOne({collection:"simply-xps",data:{user:userId,guild:guildId}},{collection:"simply-xps",data:{user:userId,guild:guildId,level:(0,utilities_1.convertFrom)(xpData),xp:xpData}});else{if(!xp_1.xp.auto_create||!username)throw new xplogs_1.XpFatal({function:"setXP()",message:"User does not exist"});s=await database_1.db.createOne({collection:"simply-xps",data:{guild:guildId,user:userId,name:username,level:(0,utilities_1.convertFrom)(xpData),xp:xpData}})}return{...s,hasLevelledUp:s.level>e.level}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.setXP=exports.setLevel=void 0;const xplogs_1=require("./functions/xplogs"),utilities_1=require("./functions/utilities"),database_1=require("./functions/database"),xp_1=require("../xp");exports.setLevel=setLevel,exports.setXP=setXP;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "simply-xp",
|
|
3
|
-
"version": "2.0.0-dev.
|
|
3
|
+
"version": "2.0.0-dev.4",
|
|
4
4
|
"description": "The easiest way to implement xp system",
|
|
5
5
|
"main": "lib/xp.js",
|
|
6
6
|
"scripts": {
|
|
@@ -40,18 +40,18 @@
|
|
|
40
40
|
"url": "git+https://github.com/Rahuletto/simply-xp.git"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@napi-rs/canvas": "^0.1.
|
|
43
|
+
"@napi-rs/canvas": "^0.1.44"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/better-sqlite3": "^7.6.4",
|
|
47
|
-
"@types/node": "^20.5.
|
|
48
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
49
|
-
"@typescript-eslint/parser": "^6.
|
|
50
|
-
"better-sqlite3": "8.5.
|
|
51
|
-
"discord.js": "^14.
|
|
47
|
+
"@types/node": "^20.5.4",
|
|
48
|
+
"@typescript-eslint/eslint-plugin": "^6.4.1",
|
|
49
|
+
"@typescript-eslint/parser": "^6.4.1",
|
|
50
|
+
"better-sqlite3": "8.5.1",
|
|
51
|
+
"discord.js": "^14.13.0",
|
|
52
52
|
"eslint": "^8.47.0",
|
|
53
53
|
"jsdoc-to-markdown": "^8.0.0",
|
|
54
|
-
"mongodb": "^5.
|
|
54
|
+
"mongodb": "^5.8.1",
|
|
55
55
|
"typescript": "^5.1.6",
|
|
56
56
|
"uglify-js": "^3.17.4"
|
|
57
57
|
},
|
|
Binary file
|