pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [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; |
| 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 |
pineafan | 02ba023 | 2022-07-24 22:16:15 +0100 | [diff] [blame] | 5 | .replace("{member:mention}", memberID ? `<@${memberID}>` : "{member:mention}") |
| 6 | .replace("{member:name}", memberName ? `${memberName}` : "{member:name}") |
| 7 | .replace("{serverName}", serverName ? `${serverName}` : "{serverName}") |
| 8 | .replace("{memberCount}", memberCount ? `${memberCount}` : "{memberCount}") |
| 9 | .replace("{memberCount:bots}", bots ? `${bots}` : "{memberCount:bots}") |
| 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; |