stats without leveling enabled

master
Kit Kasune 3 years ago
parent 7720a464c7
commit 9418f55e06
  1. 5
      .idea/workspace.xml
  2. 17
      commands/leveling/stats.js

@ -6,8 +6,7 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="826c705b-a7fa-4ece-b82a-e278fca7d494" name="Changes" comment="marriage declining"> <list default="true" id="826c705b-a7fa-4ece-b82a-e278fca7d494" name="Changes" comment="marriage declining">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/package-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/package-lock.json" afterDir="false" /> <change beforePath="$PROJECT_DIR$/commands/leveling/stats.js" beforeDir="false" afterPath="$PROJECT_DIR$/commands/leveling/stats.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -165,6 +164,8 @@
<workItem from="1645490767613" duration="1990000" /> <workItem from="1645490767613" duration="1990000" />
<workItem from="1645646716022" duration="11456000" /> <workItem from="1645646716022" duration="11456000" />
<workItem from="1645765271756" duration="14000" /> <workItem from="1645765271756" duration="14000" />
<workItem from="1646073200451" duration="122000" />
<workItem from="1646163659329" duration="994000" />
</task> </task>
<task id="LOCAL-00001" summary="not even gonna explain"> <task id="LOCAL-00001" summary="not even gonna explain">
<created>1640148826800</created> <created>1640148826800</created>

@ -53,17 +53,16 @@ module.exports = {
.setDescription("View your level and XP in the server, or someone else's") .setDescription("View your level and XP in the server, or someone else's")
.addField("Syntax", "`stats [@user|userID]`"), .addField("Syntax", "`stats [@user|userID]`"),
async execute(message, msg, args, cmd, prefix, mention, client) { async execute(message, msg, args, cmd, prefix, mention, client) {
if (!client.misc.cache.lxp.enabled.includes(message.guild.id)) {return message.channel.send("Your server doesn't have leveling enabled!");}
let u = args[0] ? (message.mentions.members.first() || message.guild.members.cache.get(args[0])) : message.member; let u = args[0] ? (message.mentions.members.first() || message.guild.members.cache.get(args[0])) : message.member;
if (!u) {return message.channel.send("I can't find that user!");} if (!u) {return message.channel.send("I can't find that user!");}
let xp; let xp; let hasXp = true;
if (!client.misc.cache.lxp.xp[message.guild.id] || !client.misc.cache.lxp.xp[message.guild.id][u.id]) { if (!client.misc.cache.lxp.xp[message.guild.id] || !client.misc.cache.lxp.xp[message.guild.id][u.id]) {
let txp = await LXP.findOne({gid: message.guild.id}); let txp = await LXP.findOne({gid: message.guild.id});
if (!txp) {return message.channel.send("Your server doesn't have leveling enabled!");} if (!txp) {hasXp = false;}
if (!txp.xp[u.id]) {return message.channel.send(`${u.id === message.author.id ? "You" : "That user"} doesn't have any leveling info available!`);} else {if (txp.xp[u.id]) {xp = {xp: txp.xp[u.id][0], level: txp.xp[u.id][1]};}}
xp = {xp: txp.xp[u.id][0], level: txp.xp[u.id][1]}; } else if (hasXp) {xp = client.misc.cache.lxp.xp[message.guild.id][u.id];}
} else {xp = client.misc.cache.lxp.xp[message.guild.id][u.id];}
let tmoon = client.misc.cache.monners[u.id] ? {currency: client.misc.cache.monners[u.id]} : await Monners.findOne({uid: u.id}); let tmoon = client.misc.cache.monners[u.id] ? {currency: client.misc.cache.monners[u.id]} : await Monners.findOne({uid: u.id});
if (!tmoon) {return message.channel.send("There was an error getting your level and Monners information. Try again?");}
let tcur = tmoon ? tmoon.currency : 0; let tcur = tmoon ? tmoon.currency : 0;
if (!message.channel.permissionsFor(message.guild.me.id).has("ATTACH_FILES")) { if (!message.channel.permissionsFor(message.guild.me.id).has("ATTACH_FILES")) {
return message.channel.send({embeds: [new Discord.MessageEmbed() return message.channel.send({embeds: [new Discord.MessageEmbed()
@ -94,9 +93,9 @@ module.exports = {
ctx.fillStyle = '#ffffff'; ctx.fillStyle = '#ffffff';
ctx.fillText(`${u.displayName}${u.displayName.toLowerCase().endsWith('s') ? "'" : "'s"} Stats`, canvas.width / 2.8, canvas.height / 2); ctx.fillText(`${u.displayName}${u.displayName.toLowerCase().endsWith('s') ? "'" : "'s"} Stats`, canvas.width / 2.8, canvas.height / 2);
ctx.font = applyText(120, canvas, `${xp.xp} / ${Math.ceil(100 + (((xp.level / 3) ** 2) * 2))} | Level ${xp.level}`); //top text ctx.font = applyText(120, canvas, `${xp ? `${xp.xp} / ${Math.ceil(100 + (((xp.level / 3) ** 2) * 2))} | Level ${xp.level}` : "Leveling N/A"}`); //top text
ctx.fillStyle = '#ffffff'; ctx.fillStyle = '#ffffff';
ctx.fillText(`${xp.xp} / ${Math.ceil(100 + (((xp.level / 3) ** 2) * 2))} | Level ${xp.level}`, canvas.width / 2.8, canvas.height / 3.2); ctx.fillText(`${xp ? `{xp.xp} / ${Math.ceil(100 + (((xp.level / 3) ** 2) * 2))} | Level ${xp.level}` : "Leveling N/A"}`, canvas.width / 2.8, canvas.height / 3.2);
const monnersImage = await Canvas.loadImage('https://cdn.discordapp.com/emojis/926736756047495218'); const monnersImage = await Canvas.loadImage('https://cdn.discordapp.com/emojis/926736756047495218');
ctx.drawImage(monnersImage, canvas.width / 2.8, (canvas.height / 1.53) - 11, 58, 60); //draw monners icon ctx.drawImage(monnersImage, canvas.width / 2.8, (canvas.height / 1.53) - 11, 58, 60); //draw monners icon
@ -105,6 +104,7 @@ module.exports = {
ctx.fillText(` | `, (canvas.width / 2.8) + 70 + ctx.measureText(`${tcur}`).width, (canvas.height / 1.53) + 57 - 24); // draw monners amount ctx.fillText(` | `, (canvas.width / 2.8) + 70 + ctx.measureText(`${tcur}`).width, (canvas.height / 1.53) + 57 - 24); // draw monners amount
let monnersWidth = ctx.measureText(`${tcur} | `).width + 75; //get width of monners text and icon to account for bar size later let monnersWidth = ctx.measureText(`${tcur} | `).width + 75; //get width of monners text and icon to account for bar size later
if (xp) {
//draw the bar borders //draw the bar borders
ctx.strokeStyle = '#ffffff'; ctx.strokeStyle = '#ffffff';
ctx.strokeWidth = 6; ctx.strokeWidth = 6;
@ -114,6 +114,7 @@ module.exports = {
ctx.fillStyle = '#4aa4e0c8'; ctx.fillStyle = '#4aa4e0c8';
//draw the bar filler //draw the bar filler
ctx.fillRect((canvas.width / 2.8) + monnersWidth, canvas.height / 1.53, (xp.xp / Math.ceil(100 + (((xp.level / 3) ** 2) * 2))) * (canvas.width - (canvas.width / 2.8) - monnersWidth - 80), 40); ctx.fillRect((canvas.width / 2.8) + monnersWidth, canvas.height / 1.53, (xp.xp / Math.ceil(100 + (((xp.level / 3) ** 2) * 2))) * (canvas.width - (canvas.width / 2.8) - monnersWidth - 80), 40);
}
message.channel.send({files: [new Discord.MessageAttachment(canvas.toBuffer(), 'xp-stats.png')]}); message.channel.send({files: [new Discord.MessageAttachment(canvas.toBuffer(), 'xp-stats.png')]});
} }

Loading…
Cancel
Save