split monners and xp gains

master
Kit Kasune 3 years ago
parent 1cdbc6a65c
commit 9f55729ebe
  1. 69
      .idea/workspace.xml
  2. 1
      bot.js
  3. 11
      events/messageCreate.js
  4. 22
      util/lxp/cacheloop.js
  5. 1
      util/lxp/gainxp.js

@ -4,7 +4,13 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="826c705b-a7fa-4ece-b82a-e278fca7d494" name="Changes" comment="/deathnote" />
<list default="true" id="826c705b-a7fa-4ece-b82a-e278fca7d494" name="Changes" comment="/deathnote">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bot.js" beforeDir="false" afterPath="$PROJECT_DIR$/bot.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/events/messageCreate.js" beforeDir="false" afterPath="$PROJECT_DIR$/events/messageCreate.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/util/lxp/cacheloop.js" beforeDir="false" afterPath="$PROJECT_DIR$/util/lxp/cacheloop.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/util/lxp/gainxp.js" beforeDir="false" afterPath="$PROJECT_DIR$/util/lxp/gainxp.js" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@ -73,10 +79,68 @@
<command value="git pull origin master" />
</option>
</component>
<component name="RunManager">
<component name="RunManager" selected="npm.dev:pretty">
<configuration name="Start" type="NodeJSConfigurationType" path-to-js-file="bot.js" working-dir="$PROJECT_DIR$">
<method v="2" />
</configuration>
<configuration name="dev" type="js.build_tools.npm" nameIsGenerated="true">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="dev" />
</scripts>
<node-interpreter value="project" />
<envs />
<method v="2" />
</configuration>
<configuration name="dev:pretty" type="js.build_tools.npm" nameIsGenerated="true">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="dev:pretty" />
</scripts>
<node-interpreter value="project" />
<envs />
<method v="2" />
</configuration>
<configuration name="start" type="js.build_tools.npm" nameIsGenerated="true">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="start" />
</scripts>
<node-interpreter value="project" />
<envs />
<method v="2" />
</configuration>
<configuration name="start:pretty" type="js.build_tools.npm" nameIsGenerated="true">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="start:pretty" />
</scripts>
<node-interpreter value="project" />
<envs />
<method v="2" />
</configuration>
<configuration name="sync" type="js.build_tools.npm" nameIsGenerated="true">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="sync" />
</scripts>
<node-interpreter value="project" />
<envs />
<method v="2" />
</configuration>
<list>
<item itemvalue="Node.js.Start" />
<item itemvalue="npm.dev:pretty" />
<item itemvalue="npm.dev" />
<item itemvalue="npm.start" />
<item itemvalue="npm.start:pretty" />
<item itemvalue="npm.sync" />
</list>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
@ -99,6 +163,7 @@
<workItem from="1642638383959" duration="700000" />
<workItem from="1642707112676" duration="1337000" />
<workItem from="1644446122031" duration="7044000" />
<workItem from="1645389860831" duration="4164000" />
</task>
<task id="LOCAL-00001" summary="not even gonna explain">
<created>1640148826800</created>

@ -54,6 +54,7 @@ client.misc = {
charsNum: 0,
charsLove: new Discord.Collection(),
monners: {},
lastMonners: {},
monnersNames: new Map(),
spin: new spinnies(),
rp: new Map(),

@ -122,6 +122,17 @@ module.exports = async (client, message) => {
if (!client.misc.cache.monners[message.author.id]) {
let tmonners = await Monners.findOne({uid: message.author.id}) || new Monners({uid: message.author.id});
client.misc.cache.monners[message.author.id] = tmonners.currency;
client.misc.cache.lastMonners[message.author.id] = new Date().getTime() - (62 * 1000);
}
if (message.guild && client.misc.cache.lastMonners[message.author.id] && new Date().getTime() - client.misc.cache.lastMonners[message.author.id] > 60000) {
client.misc.cache.monners[message.author.id] += (Math.floor(
(client.misc.cache.lxp.xp[message.guild.id] && client.misc.cache.lxp.xp[message.guild.id][message.author.id]
? client.misc.cache.lxp.xp[message.guild.id][message.member.id].level
: 35)
/ 35
) + 1);
client.misc.cache.lastMonners[message.author.id] = new Date().getTime();
}
if (message.guild && client.misc.cache.monitEnabled.includes(message.guild.id)) {

@ -7,22 +7,28 @@ module.exports = async (client) => {
LXP.findOne({gid: gxp}).then(xp => {
if (!xp) {return;}
Object.keys(client.misc.cache.lxp.xp[gxp]).forEach(user => {
Monners.findOne({uid: user}).then(m => {
if (!Object.keys(client.misc.cache.monners).includes(user)) {return;}
if (isNaN(client.misc.cache.monners[user])) {return;}
if (!m) {m = new Monners({uid: user});}
m.currency = client.misc.cache.monners[user];
m.save().catch(() => {});
});
xp.xp[user] = [client.misc.cache.lxp.xp[gxp][user].xp, client.misc.cache.lxp.xp[gxp][user].level];
xp.markModified(`xp.${user}`);
if (cd - client.misc.cache.lxp.xp[gxp][user].lastXP > 600000) {
delete client.misc.cache.lxp.xp[gxp][user];
delete client.misc.cache.monners[user];
if (!Object.keys(client.misc.cache.lxp.xp[gxp]).length) {delete client.misc.cache.lxp.xp[gxp];}
}
});
xp.save().catch(() => {});
});
Object.keys(client.misc.cache.monners).forEach(user => {
Monners.findOne({uid: user}).then(m => {
if (!Object.keys(client.misc.cache.monners).includes(user)) {return;}
if (isNaN(client.misc.cache.monners[user])) {return;}
if (!m) {m = new Monners({uid: user});}
m.currency = client.misc.cache.monners[user];
m.save().catch(() => {});
if (cd - client.misc.cache.lastMonners[user] > 600000) {
delete client.misc.cache.monners[user];
delete client.misc.cache.lastMonners[user];
}
});
})
});
};

@ -18,7 +18,6 @@ const applyText = (canvas, text) => {
module.exports = async (client, member, channel) => {
client.misc.cache.lxp.xp[channel.guild.id][member].lastXP = new Date().getTime();
client.misc.cache.lxp.xp[channel.guild.id][member].xp += 10;
client.misc.cache.monners[member] += (Math.floor(client.misc.cache.lxp.xp[channel.guild.id][member].level / 35) + 1);
let x = client.misc.cache.lxp.xp[channel.guild.id][member].level;
let max = Math.ceil(100 + (((x / 3) ** 2) * 2));

Loading…
Cancel
Save