blob: 53c32670a663b91bec5d53c4a99daa67cfe2257e [file] [log] [blame]
Skyler Grey11236ba2022-08-08 21:13:33 +01001async function convertCurlyBracketString(str, memberID, memberName, serverName, members): Promise<string> {
pineafan63fc5e22022-08-04 22:04:10 +01002 const memberCount = (await members.fetch()).size;
Skyler Grey75ea9172022-08-06 10:22:23 +01003 const bots = (await members.fetch()).filter((m) => m.user.bot).size;
pineafan32767212022-03-14 21:27:39 +00004 str = str
Skyler Grey11236ba2022-08-08 21:13:33 +01005 .replace("{member:mention}", memberID ? `<@${memberID}>` : "{member:mention}")
6 .replace("{member:name}", memberName ? `${memberName}` : "{member:name}")
pineafan02ba0232022-07-24 22:16:15 +01007 .replace("{serverName}", serverName ? `${serverName}` : "{serverName}")
Skyler Grey11236ba2022-08-08 21:13:33 +01008 .replace("{memberCount}", memberCount ? `${memberCount}` : "{memberCount}")
pineafan02ba0232022-07-24 22:16:15 +01009 .replace("{memberCount:bots}", bots ? `${bots}` : "{memberCount:bots}")
Skyler Grey11236ba2022-08-08 21:13:33 +010010 .replace("{memberCount:humans}", memberCount && bots ? `${memberCount - bots}` : "{memberCount:humans}");
pineafan32767212022-03-14 21:27:39 +000011
pineafan63fc5e22022-08-04 22:04:10 +010012 return str;
pineafan32767212022-03-14 21:27:39 +000013}
14
pineafanc6158ab2022-06-17 16:34:07 +010015export default convertCurlyBracketString;