user and serverinfo bugs and impvts

master
Kit Kasune 3 years ago
parent 50c701a5de
commit e1eca1bff9
  1. 1
      .gitignore
  2. 2
      bot.js
  3. 33
      commands/misc/serverinfo.js
  4. 25
      commands/misc/userinfo.js

1
.gitignore vendored

@ -7,3 +7,4 @@ test.js
api/**/*
api/
.idea/**/*
/man.js

@ -139,7 +139,7 @@ async function init() {
client.utils.an = (text, caps) => `${caps ? 'A' : 'a'}${['a', 'e', 'i', 'o', 'u'].includes(text.toLowerCase().trim().slice(0, 1)) ? 'n' : ''} ${text}`;
client.utils.c = (text, a=true) => `${text.slice(0, 1).toUpperCase()}${a ? text.slice(1).toLowerCase() : text.slice(1)}`;
client.utils.ca = (text, a=true) => text.split(/\s+/gm).map(t => client.utils.c(t, a)).join(" ");
client.utils.sm = (mpr, ago=true) => `${mpr.years} year${client.utils.s(mpr.years)}, ${mpr.months} month${client.utils.s(mpr.months)}, and ${mpr.days} day${client.utils.s(mpr.days)}${ago ? ' ago' : ''}`;
client.utils.sm = (mpr, ago=true) => `${mpr.years ? `${mpr.years} year${client.utils.s(mpr.years)} ` : ''}${mpr.months ? `${mpr.months} month${client.utils.s(mpr.months)} ` : ''}${mpr.days} day${client.utils.s(mpr.days)}${ago ? ' ago' : ''}`;
['commands', 'aliases', 'executables'].forEach(x => client[x] = new Discord.Collection());
client.responses = {triggers: [], commands: new Discord.Collection()};

@ -1,5 +1,6 @@
const Discord = require("discord.js");
const moment = require('moment');
require('moment-precise-range-plugin');
module.exports = {
name: "serverinfo",
@ -14,18 +15,28 @@ module.exports = {
},
execute(message, msg, args, cmd, prefix, mention, client) {
let now = new Date();
return message.channel.send({embeds: [new Discord.MessageEmbed()
.setAuthor({name: "Server info", iconURL: message.author.avatarURL()})
.setTitle(message.guild.name)
.setThumbnail(message.guild.iconURL({size: 2048}))
.setDescription(`Name: \`${message.guild.name}\`\n\nOwner: <@${message.guild.ownerId}>\nRegion: ${message.guild.region}\nIcon: [URL](${message.guild.iconURL({size: 2048})})`)
.addField("Members", `${message.guild.members.cache.size}\n[${message.guild.members.cache.filter(m => !client.users.cache.get(m.id).bot).size} Humans | ${message.guild.members.cache.filter(m => client.users.cache.get(m.id).bot).size} Bots]\n\nOnline: ${message.guild.members.cache.filter(m => client.users.cache.get(m.id).presence.status === "online").size} | Idle: ${message.guild.members.cache.filter(m => client.users.cache.get(m.id).presence.status === "idle").size} | Do not Disturb: ${message.guild.members.cache.filter(m => client.users.cache.get(m.id).presence.status === "dnd").size}`)
.addField("Channels", `${message.guild.channels.cache.size}\n[${message.guild.channels.cache.filter(ch => ch.type === "text").size} Text | ${message.guild.channels.cache.filter(ch => ch.type === "voice").size} Voice]`, true)
.addField("Roles", `${message.guild.roles.cache.size} (you have ${message.member.roles.cache.size})\nYour highest is <@&${message.member.roles.highest.id}>`, true)
.addField("Other Info", `Server created roughly **${moment(message.guild.createdAt).fromNow()}**\n\nYou joined ${moment(message.member.joinedAt).fromNow()} (Member for **${Math.round(((now.getTime() - new Date(message.member.joinedAt.getTime()).getTime()) / (new Date(message.guild.createdAt).getTime() - now.getTime())) * -100)}%** of server lifetime)`)
let tg = message.guild;
let text = ["GUILD_MESSAGE", "DM", "GUILD_NEWS_THREAD", "GUILD_PRIVATE_THREAD", "GUILD_PUBLIC_THREAD", "GUILD_NEWS", "GROUP_DM", "GUILD_STORE", "GUILD_TEXT"];
let voice = ["GUILD_VOICE", "GUILD_STAGE_VOICE"];
let siembed = new Discord.MessageEmbed()
.setAuthor({name: "Server info", iconURL: message.author.avatarURL({dynamic: true})})
.setTitle(tg.name)
.setThumbnail(tg.iconURL({size: 2048, dynamic: true, format: 'png'}))
.setDescription(`Name: \`${tg.name}\`\n\nOwner: <@${tg.ownerId}>\nBoost Level: **${tg.premiumTier === 'NONE' ? 'None' : tg.premiumTier.slice(tg.premiumTier.length - 1, tg.premiumTier.length)}**\nIcon: [URL](${tg.iconURL({size: 2048})})${tg.banner ? ` | Banner: [URL](${tg.bannerURL({size: 4096, format: 'png'})})` : ''}${tg.splash ? ` | Splash: [URL](${tg.splashURL({size: 4096, format: 'png'})})` : ''}\nID: ${tg.id}`)
.addField("Channels", `${tg.channels.cache.filter(ch => ch.type !== 'GUILD_CATEGORY').size}\n[${tg.channels.cache.filter(ch => text.includes(ch.type)).size} Text | ${tg.channels.cache.filter(ch => voice.includes(ch.type)).size} Voice]`, true)
.addField("Roles", `${tg.roles.cache.size} (you have ${message.member.roles.cache.size}) -> ${Math.round((message.member.roles.cache.size / tg.roles.cache.size) * 100)}%\nYour highest is <@&${message.member.roles.highest.id}>`, true)
.addField("Members", `${tg.memberCount}\n[${tg.members.cache.filter(m => !client.users.cache.get(m.id).bot).size} Humans | ${tg.members.cache.filter(m => client.users.cache.get(m.id).bot).size} Bots]\n\nOnline: ${tg.members.cache.filter(m => m.presence && m.presence.status === "online").size} | Idle: ${tg.members.cache.filter(m => m.presence && m.presence.status === "idle").size} | Do not Disturb: ${tg.members.cache.filter(m => m.presence && m.presence.status === "dnd").size}`)
.addField("Emojis", `${tg.emojis.cache.size}`, true)
.addField("Stickers", `${tg.stickers.cache.size}`, true)
.addField("Other Info", `Server created **${client.utils.sm(moment.preciseDiff(Date.now(), tg.createdAt, true))}**\nYou joined ${client.utils.sm(moment.preciseDiff(Date.now(), message.member.joinedAt, true))} (Member for **${Math.round(((now.getTime() - message.member.joinedAt.getTime()) / (now.getTime() - message.guild.createdAt.getTime())) * 100)}%** of server lifetime)`)
.setColor('c375f0')
.setFooter({text: "Natsuki"})
.setTimestamp()
]});
.setTimestamp();
if (tg.banner) {siembed.setImage(tg.bannerURL({size: 4096, format: 'png'}));}
else if (tg.splash) {siembed.setImage(tg.splashURL({size: 4096, format: 'png'}));}
if (tg.premiumTier !== 'NONE') {siembed.addField("Features", tg.features.map(f => client.utils.ca(f.replace(/_/gm, ' '))).join(", "));}
return message.channel.send({embeds: [siembed]});
}
};

@ -1,6 +1,7 @@
const Discord = require('discord.js');
const moment = require('moment');
const mongoose = require('mongoose');
require('moment-precise-range-plugin');
const UserData = require('../../models/user');
module.exports = {
@ -11,25 +12,31 @@ module.exports = {
category: 'Misc',
description: "See some info about a user",
syntax: '`userinfo [@user]`',
extra: null
extra: null,
guildOnly: true
},
async execute(message, msg, args, cmd, prefix, mention, client) {
let person = message.guild ? mention ? message.guild.members.cache.get(mention.id) : args[0] ? message.guild.members.cache.has(args[0]) ? message.guild.members.cache.get(args[0]) : message.member : message.member : message.author;
let person = message.mentions.members.first() || message.guild.members.cache.get(args[0]) || message.member;
if (!person) {return message.channel.send("Hmmm... that doesn't seem to be a real user.");}
let u = await client.users.fetch(person.id, {force: true, cache: false}).catch(() => {});
if (!u) {return message.channel.send("There was an issue finding that user. They might not be a real user!");}
temp = await message.guild.members.fetch(person.id);
if (!temp) {return message.channel.send("There was an issue finding that user. They might not be a real user, or not one that exists in this server.");}
let name = message.guild ? person.displayName : person.username;
let tu = await UserData.findOne({uid: person.id});
let now = new Date();
let infoembed = new Discord.MessageEmbed()
.setTitle(`User Info for ${name}`)
.setDescription(`Requested by ${message.guild ? message.member.displayName : message.author.username}`)
.setThumbnail(client.users.cache.get(person.id).avatarURL({size: 2048}))
.addField("Account Created", `${moment(client.users.cache.get(person.id).createdAt).fromNow()}`, true)
.addField("Bot User?", client.users.cache.get(person.id).bot ? "Is a bot" : "Is not a bot", true)
.setThumbnail((message.guild ? person : u).displayAvatarURL({size: 4096}))
.addField("Account Created", `${moment(u.createdAt).fromNow()}`, true)
.addField("Bot User?", u.bot ? "Is a bot" : "Is not a bot", true)
.setColor('c375f0')
.setFooter({text: "Natsuki", iconURL: client.user.avatarURL()})
.setTimestamp();
if (message.guild) {
infoembed.addField('In Server Since', `${moment(person.joinedAt).fromNow()}${!moment(person.joinedAt).fromNow().includes('days') ? ` | ${Math.floor((new Date().getTime() - person.joinedAt.getTime()) / (60 * 60 * 24 * 1000))} days` : ''}\nMember for **${Math.round(((now.getTime() - new Date(message.member.joinedAt.getTime()).getTime()) / (new Date(message.guild.createdAt).getTime() - now.getTime())) * -100)}%** of server lifetime`, false)
infoembed.addField('In Server Since', `${client.utils.sm(moment.preciseDiff(Date.now(), person.joinedAt, true))}${!moment(person.joinedAt).fromNow().includes('days') ? ` | ${Math.floor((new Date().getTime() - person.joinedAt.getTime()) / (60 * 60 * 24 * 1000))} days` : ''}\nMember for **${Math.round(((now.getTime() - person.joinedAt.getTime()) / (now.getTime() - message.guild.createdAt.getTime())) * 100)}%** of server lifetime`, false)
.addField('Roles', `**${person.roles.cache.size}** roles | [${person.roles.cache.size}/${message.guild.roles.cache.size}] - ${Math.round((person.roles.cache.size / message.guild.roles.cache.size) * 100)}%\nHighest: ${person.roles.highest ? `<@&${person.roles.highest.id}>` : 'No roles!'}`, true)
if (message.guild.ownerId === person.id) {infoembed.addField("Extra", "User is the server's owner!");}
else if (person.permissions.has("ADMINISTRATOR")) {infoembed.addField("Extra", "User is an admin! Watch out :eyes:");}
@ -40,6 +47,10 @@ module.exports = {
if (tu.donator || tu.developer) {infoembed.addField('Donator?', tu.developer ? `Well, ${name} makes me work, so they're a supporter in my book!` : tu.donator ? 'Yes! They have donated or supported me in the past!' : 'No', true);}
if (tu.staff) {infoembed.addField('Natsuki Staff Level', tu.developer ? 'Developer' : tu.admin ? 'Admin; Audit access to the bot' : tu.staff ? 'Staff; Support but with maintenance permissions' : tu.support ? 'Support; Answers tickets and help queries' : 'Member; Does not have a staff rank.', true);}
}
console.log()
if (u.banner) {infoembed.setImage(u.bannerURL({size: 4096, dynamic: true, format: 'png'}));}
return message.channel.send({embeds: [infoembed]});
}
};
Loading…
Cancel
Save