blob: 49a4418470923c3960234c9799e9732372a85c9d [file] [log] [blame]
Skyler Grey75ea9172022-08-06 10:22:23 +01001async function convertCurlyBracketString(
2 str,
3 memberID,
4 memberName,
5 serverName,
6 members
7): Promise<string> {
pineafan63fc5e22022-08-04 22:04:10 +01008 const memberCount = (await members.fetch()).size;
Skyler Grey75ea9172022-08-06 10:22:23 +01009 const bots = (await members.fetch()).filter((m) => m.user.bot).size;
pineafan32767212022-03-14 21:27:39 +000010 str = str
Skyler Grey75ea9172022-08-06 10:22:23 +010011 .replace(
12 "{member:mention}",
13 memberID ? `<@${memberID}>` : "{member:mention}"
14 )
15 .replace(
16 "{member:name}",
17 memberName ? `${memberName}` : "{member:name}"
18 )
pineafan02ba0232022-07-24 22:16:15 +010019 .replace("{serverName}", serverName ? `${serverName}` : "{serverName}")
Skyler Grey75ea9172022-08-06 10:22:23 +010020 .replace(
21 "{memberCount}",
22 memberCount ? `${memberCount}` : "{memberCount}"
23 )
pineafan02ba0232022-07-24 22:16:15 +010024 .replace("{memberCount:bots}", bots ? `${bots}` : "{memberCount:bots}")
Skyler Grey75ea9172022-08-06 10:22:23 +010025 .replace(
26 "{memberCount:humans}",
27 memberCount && bots
28 ? `${memberCount - bots}`
29 : "{memberCount:humans}"
30 );
pineafan32767212022-03-14 21:27:39 +000031
pineafan63fc5e22022-08-04 22:04:10 +010032 return str;
pineafan32767212022-03-14 21:27:39 +000033}
34
pineafanc6158ab2022-06-17 16:34:07 +010035export default convertCurlyBracketString;