3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

fix(userinfocmd): limit the amount of roles shown

This commit is contained in:
almeidx 2022-02-07 21:18:41 +00:00
parent feeb048855
commit af4b82d48d
No known key found for this signature in database
GPG key ID: D3B8D0FDD91CDA0E

View file

@ -16,6 +16,13 @@ import {
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin";
import { UtilityPluginType } from "../types";
const MAX_ROLES_TO_DISPLAY = 15;
const trimRoles = (roles: string[]) =>
roles.length > MAX_ROLES_TO_DISPLAY
? roles.slice(0, MAX_ROLES_TO_DISPLAY).join(", ") + `, and ${MAX_ROLES_TO_DISPLAY - roles.length} more roles`
: roles.join(", ");
export async function getUserInfoEmbed(
pluginData: GuildPluginData<UtilityPluginType>,
userId: string,
@ -109,7 +116,7 @@ export async function getUserInfoEmbed(
name: preEmbedPadding + "Member information",
value: trimLines(`
${user.bot ? "Added" : "Joined"}: **${joinAge} ago** (\`${prettyJoinedAt}\`)
${roles.length > 0 ? "Roles: " + roles.map((r) => `<@&${r.id}>`).join(", ") : ""}
${roles.length > 0 ? "Roles: " + trimRoles(roles.map((r) => `<@&${r.id}>`)) : ""}
`),
});