| import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js"; |
| import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; |
| import { WrappedCheck } from "jshaiku"; |
| import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js"; |
| import getEmojiByName from "../../utils/getEmojiByName.js"; |
| import generateKeyValueList from "../../utils/generateKeyValueList.js"; |
| import createPageIndicator from "../../utils/createPageIndicator.js"; |
| |
| const command = (builder: SlashCommandSubcommandBuilder) => |
| builder |
| .setName("about") |
| .setDescription("Shows info about a user") |
| .addUserOption(option => option.setName("user").setDescription("The user to get info about | Default: Yourself")) |
| |
| const callback = async (interaction: CommandInteraction) => { |
| // @ts-ignore |
| const { renderUser, renderDelta } = interaction.client.logger |
| let member = (interaction.options.getMember("user") || interaction.member) as Discord.GuildMember; |
| let flags: string[] = []; |
| if ([ |
| "438733159748599813", // Pinea |
| "317731855317336067", // Mini |
| "261900651230003201", // Coded |
| "511655498676699136", // Zan |
| ].includes(member.user.id)) { flags.push("NUCLEUSDEVELOPER") } |
| if ((await interaction.client.guilds.cache.get("684492926528651336")?.members.fetch())?.filter(m => m.roles.cache.has("760896837866749972"))?.map(m => m.id).includes(member.user.id)) { flags.push("CLICKSDEVELOPER") } |
| member.user.flags.toArray().map(flag => { |
| flags.push(flag.toString()) |
| }) |
| if (member.user.bot === true) { flags.push("BOT") } |
| // Check if they are boosting the server |
| if (member.premiumSince) { flags.push("BOOSTER") } |
| let nameReplacements = { |
| "NUCLEUSDEVELOPER": "**Nucleus Developer**", |
| "CLICKSDEVELOPER": "Clicks Developer", |
| "HOUSE_BRAVERY": "Hypesquad Bravery", |
| "HOUSE_BRILLIANCE": "Hypesquad Brilliance", |
| "HOUSE_BALANCE": "Hypesquad Balance", |
| "HYPESQUAD_EVENTS": "Hypesquad Events", |
| "EARLY_SUPPORTER": "Early Supporter", |
| "BUGHUNTER_LEVEL_1": "Bug Hunter Level 1", |
| "BUGHUNTER_LEVEL_2": "Bug Hunter Level 2", |
| "PARTNERED_SERVER_OWNER": "Partnered Server Owner", |
| "DISCORD_EMPLOYEE": "Discord Staff", |
| "EARLY_VERIFIED_BOT_DEVELOPER": "Verified Bot Developer", |
| "BOT": "Bot", |
| "BOOSTER": "Server Booster" |
| } |
| let members = await interaction.guild.members.fetch() |
| let membersArray = [...members.values()] |
| membersArray.sort((a, b) => a.joinedTimestamp - b.joinedTimestamp) |
| let joinPos = membersArray.findIndex(m => m.id === member.user.id) |
| |
| let roles = member.roles.cache.filter(r => r.id != interaction.guild.id).sort() |
| let s = ""; |
| let count = 0; |
| let ended = false |
| roles.map(item => { |
| if (ended) return; |
| let string = `<@&${item.id}>, ` |
| if(s.length + string.length > 1000) { |
| ended = true |
| s += `and ${roles.size - count} more` |
| return |
| }; |
| count ++ |
| s += string; |
| }) |
| if(s.length > 0 && !ended) s = s.slice(0, -2); |
| |
| let perms = "" |
| let permsArray = { |
| "ADMINISTRATOR": "Administrator", |
| "MANAGE_GUILD": "Manage Server", |
| "MANAGE_ROLES": "Manage Roles", |
| "MANAGE_CHANNELS": "Manage Channels", |
| "KICK_MEMBERS": "Kick Members", |
| "BAN_MEMBERS": "Ban Members", |
| "MODERATE_MEMBERS": "Moderate Members", |
| "MANAGE_NICKNAMES": "Manage Nicknames", |
| "MANAGE_WEBHOOKS": "Manage Webhooks", |
| "MANAGE_MESSAGES": "Manage Messages", |
| "VIEW_AUDIT_LOG": "View Audit Log", |
| "MENTION_EVERYONE": "Mention Everyone" |
| } |
| Object.keys(permsArray).map(perm => { |
| let hasPerm = member.permissions.has(perm as Discord.PermissionString) |
| perms += `${getEmojiByName("CONTROL." + (hasPerm ? "TICK" : "CROSS"))} ${permsArray[perm]}\n` |
| }) |
| |
| let embeds = [ |
| new generateEmojiEmbed() |
| .setTitle("User Info: General") |
| .setStatus("Success") |
| .setEmoji("MEMBER.JOIN") |
| .setDescription( |
| flags.map(flag => { |
| if (nameReplacements[flag]) { |
| return getEmojiByName(`BADGES.${flag}`) + " " + nameReplacements[flag]; |
| } |
| }).join("\n") + "\n\n" + |
| generateKeyValueList({ |
| "member": renderUser(member.user), |
| "nickname": member.nickname || "*None set*", |
| "id": `\`${member.id}\``, |
| "joined the server": renderDelta(member.joinedTimestamp), |
| "joined discord": renderDelta(member.user.createdTimestamp), |
| "boost status": member.premiumSince ? `Started boosting ${renderDelta(member.premiumSinceTimestamp)}` : "*Not boosting*", |
| "join position": `${joinPos + 1}` |
| }) |
| ) |
| .setThumbnail(await member.user.displayAvatarURL({dynamic: true})) |
| .setImage((await member.user.fetch()).bannerURL({format: "gif"})), |
| new generateEmojiEmbed() |
| .setTitle("User Info: Roles") |
| .setStatus("Success") |
| .setEmoji("GUILD.ROLES.CREATE") |
| .setDescription( |
| generateKeyValueList({ |
| "member": renderUser(member.user), |
| "id": `\`${member.id}\``, |
| "roles": `${member.roles.cache.size - 1}`, |
| }) + "\n" + |
| (s.length > 0 ? s : "*None*") + "\n" |
| ) |
| .setThumbnail(await member.user.displayAvatarURL({dynamic: true})), |
| new generateEmojiEmbed() |
| .setTitle("User Info: Key Permissions") |
| .setStatus("Success") |
| .setEmoji("GUILD.ROLES.CREATE") |
| .setDescription( |
| generateKeyValueList({ |
| "member": renderUser(member.user), |
| "id": `\`${member.id}\``, |
| }) + "\n" + perms |
| ) |
| .setThumbnail(await member.user.displayAvatarURL({dynamic: true})) |
| ] |
| let m |
| m = await interaction.reply({embeds: [new generateEmojiEmbed().setTitle("Loading").setEmoji("NUCLEUS.LOADING").setStatus("Danger")], fetchReply: true, ephemeral: true}); |
| let page = 0 |
| while (true) { |
| let em = new Discord.MessageEmbed(embeds[page]) |
| em.setDescription(em.description + "\n" + createPageIndicator(embeds.length, page)); |
| await interaction.editReply({ |
| embeds: [em], |
| components: [new MessageActionRow().addComponents([ |
| new MessageButton() |
| .setEmoji(getEmojiByName("CONTROL.LEFT", "id")) |
| .setStyle("SECONDARY") |
| .setCustomId("left") |
| .setDisabled(page === 0), |
| new MessageButton() |
| .setEmoji(getEmojiByName("CONTROL.RIGHT", "id")) |
| .setCustomId("right") |
| .setStyle("SECONDARY") |
| .setDisabled(page === embeds.length - 1), |
| new MessageButton() |
| .setEmoji(getEmojiByName("CONTROL.CROSS", "id")) |
| .setCustomId("close") |
| .setStyle("DANGER") |
| ])] |
| }) |
| let i |
| try { |
| i = await m.awaitMessageComponent({componentType: "BUTTON", time: 600000}); |
| } catch { break } |
| i.deferUpdate() |
| if (i.component.customId == "left") { |
| if (page > 0) page--; |
| } else if (i.component.customId == "right") { |
| if (page < embeds.length - 1) page++; |
| } else if (i.component.customId == "close") { |
| break; |
| } else { |
| break; |
| } |
| } |
| await interaction.editReply({embeds: [m.embeds[0]], components: [new MessageActionRow().addComponents([ |
| new MessageButton() |
| .setEmoji(getEmojiByName("CONTROL.LEFT", "id")) |
| .setStyle("SECONDARY") |
| .setCustomId("left") |
| .setDisabled(true), |
| new MessageButton() |
| .setEmoji(getEmojiByName("CONTROL.RIGHT", "id")) |
| .setCustomId("right") |
| .setStyle("SECONDARY") |
| .setDisabled(true), |
| new MessageButton() |
| .setEmoji(getEmojiByName("CONTROL.CROSS", "id")) |
| .setCustomId("close") |
| .setStyle("PRIMARY") |
| .setDisabled(true) |
| ])]}) |
| } |
| |
| const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => { |
| return true; |
| } |
| |
| export { command }; |
| export { callback }; |
| export { check }; |