add voice to monit

master
Kit Kasune 4 years ago
parent ff60a23353
commit 618af90442
  1. 58
      commands/utility/monitor.js

@ -24,26 +24,50 @@ module.exports = {
if (!args.length || (args.length && ['v', 'view', 'stats'].includes(args[0].toLowerCase()))) { 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!");} 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!");}
if (!Object.keys(tm.messages.members).length && !Object.keys(tm.voice.members).length) {return message.channel.send("Your server doesn't have any monitoring data available yet. Send some messages or hop in a VC, wait a few minutes, and try again.");}
let ch; let chs; let u; let us;
let vch; let vchs; let vu; let vus;
let thm = false; let tv = false;
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); if (Object.keys(tm.messages.members).length) {
let chs = ``; thm = true;
let i; for (i=0; i<ch.length; i++) {chs += `${i+1}. <#${ch[i]}> -> **${tm.messages.channels[ch[i]]} Messages**\n`;} 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);
chs = ``;
let i; for (i=0; i<ch.length; i++) {chs += `${i+1}. <#${ch[i]}> -> **${tm.messages.channels[ch[i]]} Messages**\n`;}
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); 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 = ``; us = ``;
let i2; for (i2=0; i2<u.length; i2++) {us += `${i2+1}. <@${u[i2]}> -> **${tm.messages.members[u[i2]]} Messages**\n`;} let i2; for (i2=0; i2<u.length; i2++) {us += `${i2+1}. <@${u[i2]}> -> **${tm.messages.members[u[i2]]} Messages**\n`;}
}
return message.channel.send(new Discord.MessageEmbed() if (Object.keys(tm.voice.members).length) {
.setTitle(`Activity stats for ${message.guild.name}`) tv = true;
.setThumbnail(message.guild.iconURL({size: 1024})) vch = Object.keys(tm.voice.channels).sort((a, b) => {return tm.voice.channels[a] - tm.voice.channels[b];}).reverse().slice(0, Object.keys(tm.voice.channels).length >= 5 ? 5 : Object.keys(tm.voice.channels).length);
.setDescription("*These statistics have an accuracy of about 10 minutes.*") vchs = ``;
.addField("Top Channels", chs) let i; for (i=0; i<vch.length; i++) {vchs += `${i+1}. ${message.guild.channels.cache.get(vch[i]).name} -> **${(tm.voice.channels[vch[i]] / 60).toFixed(1)} Hours**\n`;}
.addField("Top Members", us)
.addField("Total Messages in Server", tm.messages.total) vu = Object.keys(tm.voice.members).sort((a, b) => {return tm.voice.members[a] - tm.voice.members[b];}).reverse().slice(0, Object.keys(tm.voice.members).length >= 5 ? 5 : Object.keys(tm.voice.members).length);
.setColor('c375f0') vus = ``;
.setFooter("Natsuki", client.user.avatarURL()) let i2; for (i2=0; i2<vu.length; i2++) {vus += `${i2+1}. <@${vu[i2]}> -> **${(tm.voice.members[vu[i2]] / 60).toFixed(1)} Hours**\n`;}
.setTimestamp() }
);
let emb = new Discord.MessageEmbed()
.setTitle(`Activity stats for ${message.guild.name}`)
.setThumbnail(message.guild.iconURL({size: 1024}))
.setDescription("*These statistics have an accuracy of about 10 minutes.*")
.setColor('c375f0')
.setFooter("Natsuki", client.user.avatarURL())
.setTimestamp();
if (thm) {emb.addField("Top Channels", chs).addField("Top Members", us);}
if (tv) {emb.addField("Top Voice Channels", vchs).addField("Top VC Members", vus);}
if (thm) {emb.addField("Total Messages", tm.messages.total, true);}
if (tv) {emb.addField("Total Voice Hours", (tm.voice.total / 60).toFixed(1), true);}
return message.channel.send(emb);
} }
if (['s', 'setup', 'config', 'configure', 'enable', 'e'].includes(args[0].toLowerCase())) { if (['s', 'setup', 'config', 'configure', 'enable', 'e'].includes(args[0].toLowerCase())) {

Loading…
Cancel
Save