From f295a0bd05441d9e72ec0e5777a300676afad965 Mon Sep 17 00:00:00 2001 From: WubzyGD Date: Thu, 29 Apr 2021 11:11:30 -0600 Subject: [PATCH] more monit bugs --- commands/utility/monitor.js | 6 ++++-- util/monitorloop.js | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/commands/utility/monitor.js b/commands/utility/monitor.js index cf9b289..3ce1c33 100644 --- a/commands/utility/monitor.js +++ b/commands/utility/monitor.js @@ -25,11 +25,11 @@ module.exports = { if (!args.length || (args.length && ['v', 'view', 'stats'].includes(args[0].toLowerCase()))) { if (!tm) {return message.channel.send("Your server doesn't have monitoring enabled. If it's something you actually think you'll use, feel free to run `setup` on this command to enable it!");} - let ch = Object.keys(tm.messages.channels).sort((a, b) => {tm.messages.channels[a] - tm.messages.channels[b];}).slice(0, Object.keys(tm.messages.channels).length >= 5 ? 5 : Object.keys(tm.messages.channels).length); + let ch = Object.keys(tm.messages.channels).sort((a, b) => {return tm.messages.channels[a] - tm.messages.channels[b];}).reverse().slice(0, Object.keys(tm.messages.channels).length >= 5 ? 5 : Object.keys(tm.messages.channels).length); let chs = ``; let i; for (i=0; i -> **${tm.messages.channels[ch[i]]} Messages**\n`;} - let u = Object.keys(tm.messages.members).sort((a, b) => {tm.messages.members[a] - tm.messages.members[b];}).slice(0, Object.keys(tm.messages.members).length >= 5 ? 5 : Object.keys(tm.messages.members).length); + let u = Object.keys(tm.messages.members).sort((a, b) => {return tm.messages.members[a] - tm.messages.members[b];}).reverse().slice(0, Object.keys(tm.messages.members).length >= 5 ? 5 : Object.keys(tm.messages.members).length); let us = ``; let i2; for (i2=0; i2 -> **${tm.messages.members[u[i2]]} Messages**\n`;} @@ -58,6 +58,8 @@ module.exports = { } if (['d', 'disable'].includes(args[0].toLowerCase())) { + let tg = await GuildData.findOne({gid: message.guild.id}); + if ((tg && tg.staffrole && tg.staffrole.length && !message.member.roles.cache.has(tg.staffrole)) && !message.member.permissions.has("ADMINISTRATOR")) {return message.channel.send("You must be an administrator or have the staff role in your server in order to use this command!");} let conf = await ask(message, "Are you sure you want to disable monitors for this server? This will delete all monitoring data.", 60000); if (!conf || !['yes', 'y'].includes(conf.toLowerCase().trim())) {return message.channel.send("Okay. I won't delete or disable anything.");} delete client.misc.cache.monit[message.guild.id]; diff --git a/util/monitorloop.js b/util/monitorloop.js index 0fac2e1..eda1362 100644 --- a/util/monitorloop.js +++ b/util/monitorloop.js @@ -14,7 +14,7 @@ module.exports = async (client) => { Object.keys(client.misc.cache.monit[cache].voice.members).forEach(m => tm.markModified(`voice.members.${m}`)); Object.keys(client.misc.cache.monit[cache].voice.channels).forEach(c => tm.markModified(`voice.channels.${c}`)); tm.save(); - if (cd > client.misc.cache.monit[cache].expiry.getTime()) {delete client.misc.cache.monit[cache];} + if (cd - client.misc.cache.monit[cache].expiry.getTime() > 600000) {delete client.misc.cache.monit[cache];} }); }); }; \ No newline at end of file