Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame^] | 1 | async function convertCurlyBracketString(str, memberID, memberName, serverName, members): Promise<string> { |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 2 | const memberCount = (await members.fetch()).size; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 3 | const bots = (await members.fetch()).filter((m) => m.user.bot).size; |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 4 | str = str |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame^] | 5 | .replace("{member:mention}", memberID ? `<@${memberID}>` : "{member:mention}") |
| 6 | .replace("{member:name}", memberName ? `${memberName}` : "{member:name}") |
pineafan | 02ba023 | 2022-07-24 22:16:15 +0100 | [diff] [blame] | 7 | .replace("{serverName}", serverName ? `${serverName}` : "{serverName}") |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame^] | 8 | .replace("{memberCount}", memberCount ? `${memberCount}` : "{memberCount}") |
pineafan | 02ba023 | 2022-07-24 22:16:15 +0100 | [diff] [blame] | 9 | .replace("{memberCount:bots}", bots ? `${bots}` : "{memberCount:bots}") |
Skyler Grey | 11236ba | 2022-08-08 21:13:33 +0100 | [diff] [blame^] | 10 | .replace("{memberCount:humans}", memberCount && bots ? `${memberCount - bots}` : "{memberCount:humans}"); |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 11 | |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 12 | return str; |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 13 | } |
| 14 | |
pineafan | c6158ab | 2022-06-17 16:34:07 +0100 | [diff] [blame] | 15 | export default convertCurlyBracketString; |