nyx/command/Information/userinfo.js

94 lines
3 KiB
JavaScript
Raw Permalink Normal View History

2023-04-02 14:12:53 +02:00
const { Client, CommandInteraction, EmbedBuilder } = require("discord.js");
const Utils = require("../../util/functions/function");
2021-09-06 12:38:25 +02:00
module.exports = {
name: "userinfo",
description: "Check the info of a user",
usage: "{User}",
category: "Information",
options: [
{
type: 6,
name: "user",
description: "The user you want to see",
required: false,
},
],
2023-04-02 14:12:53 +02:00
/**
*
* @param {Client} client
* @param {CommandInteraction} interaction
* @param {String[]} args
* @param {Utils} utils
*/
2021-09-06 12:38:25 +02:00
run: async (client, interaction, args, utils) => {
const member =
interaction.guild.members.cache.get(args[0]) || interaction.member;
2023-04-02 14:12:53 +02:00
const x = Date.now() - member.user.createdAt;
const y =
2021-09-06 12:38:25 +02:00
Date.now() - interaction.guild.members.cache.get(member.id).joinedAt;
const created = Math.floor(x / 86400000);
const joined = Math.floor(y / 86400000);
const nickname =
2021-09-06 12:38:25 +02:00
member.nickname !== undefined && member.nickname !== null
? member.nickname
: "None";
const roles = member.roles.cache
.filter(r => r.id != interaction.guild.id)
.sort((a, b) => b.position - a.position)
.map(role => role.toString())
.slice(0, -1);
2023-04-02 14:12:53 +02:00
const createDateFormatted = utils.parseDate(
new Date(member.user.createdAt)
2021-09-06 12:38:25 +02:00
);
2023-04-02 14:12:53 +02:00
const joinDateFormatted = utils.parseDate(new Date(member.joinedAt));
2022-10-26 12:38:28 +02:00
const embed = new EmbedBuilder()
2023-02-03 20:14:39 +01:00
.setAuthor({
name: member.user.tag,
iconURL: member.user.displayAvatarURL({ dynamic: true, size: 2048 }),
})
2021-09-06 12:38:25 +02:00
.setTimestamp()
.setColor(member.displayHexColor || client.color)
2021-09-06 12:38:25 +02:00
.setURL(client.web)
2022-10-26 12:38:28 +02:00
.setFooter({
text: `Made by ${client.author}`,
2023-04-02 14:12:53 +02:00
iconURL: client.user.displayAvatarURL({ dynamic: true }),
2022-10-26 12:38:28 +02:00
})
2021-09-06 12:38:25 +02:00
.setThumbnail(member.user.displayAvatarURL({ dynamic: true, size: 512 }))
.setColor(member.displayHexColor || client.color)
2023-04-02 14:12:53 +02:00
.addFields([
{
name: "User",
value: `** Username:** ${member.user.username}
2021-09-06 12:38:25 +02:00
** Discriminator:** ${member.user.discriminator}
** Nickname:** ${nickname}
** User ID:** ${member.id}
2021-09-06 12:38:25 +02:00
** Avatar:** [Link to avatar](${member.user.displayAvatarURL({
dynamic: true,
size: 2048,
})})
2023-04-02 14:12:53 +02:00
** Time Created:** ${createDateFormatted} \nSince ${created} day(s) ago
\u200b`,
},
{
name: "Member",
value: `** Highest Role:** ${
member.roles.highest.id === interaction.guild.id
? "None"
: member.roles.highest.name
}
** Server Join Date:** ${joinDateFormatted} \nSince ${joined} day(s) ago
** Roles [${roles.length}]:** ${
roles.length < 10
? roles.join(" **|** ")
: roles.length > 10
? utils.trimArray(roles)
: "None"
}
\u200b`,
},
]);
interaction.followUp({ embeds: [embed] });
2021-09-06 12:38:25 +02:00
},
};