Shasha/cmds/profile/profile.js
Neko-Life bf43f30da9 hm
2021-07-22 16:57:11 +07:00

50 lines
No EOL
2 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
const commando = require("@iceprod/discord.js-commando");
const { MessageEmbed, User, Message } = require("discord.js");
const { DateTime } = require("luxon");
const { errLog, trySend, getUser, defaultImageEmbed, splitOnLength } = require("../../resources/functions");
const getColor = require("../../resources/getColor");
const { DT_PRINT_FORMAT } = require("../moderation/src/duration");
module.exports = class profile extends commando.Command {
constructor(client) {
super(client, {
name: "profile",
memberName: "profile",
aliases: ["about", "who-is"],
group: "profile",
description: "Show Users/Member profile"
});
}
/**
*
* @param {Message} msg
* @param {*} arg
* @returns
*/
async run(msg, arg) {
let TM;
if (!arg) TM = msg.author; else TM = getUser(msg, arg, true);
if (!TM) return trySend(msg.client, msg, "Bro stop lookin for yo imaginary gf");
const MEM = msg.guild.member(TM),
emb = defaultImageEmbed(msg, null, `\`${TM.tag}\`'s Profile`);
emb
.setThumbnail(TM.displayAvatarURL({ format: "png", size: 4096, dynamic: true }))
.addField("Registered", DateTime.fromJSDate(TM.createdAt).toFormat(DT_PRINT_FORMAT), true)
.addField("ID", TM.id, true);
if (TM.description) emb.setDescription(TM.description);
if (MEM) {
const RI = MEM.roles.cache.sort((a, b) => b.position - a.position).map(r => r.id).slice(0, -1),
RFS = splitOnLength(RI, 1010, ">, <@&");
emb.addField("Joined", DateTime.fromJSDate(MEM.joinedAt).toFormat(DT_PRINT_FORMAT))
.addField("Nick", `\`${MEM.displayName}\``);
if (RFS[0]?.length > 0) {
for (const p of RFS) {
emb.addField(emb.fields.length === 4 ? "Roles" : "", "<@&" + p.join(">, <@&") + ">");
}
}
}
return trySend(this.client, msg, emb);
}
};