moderator-toolbox-nxg-for-reddit / modules/removalreasons/nativeMacros
modules/removalreasons/nativeMacros¶
Functions¶
findUnresolvedMacros()¶
findUnresolvedMacros(
text,resolved):string[]
Defined in: extension/data/modules/removalreasons/nativeMacros.ts:87
Finds {macro} references in reason text that nothing will substitute, so the overlay can
warn before the moderator sends them.
Substitution leaves an unrecognized token untouched, which means it reaches the removed user verbatim. That is deliberate - blanking it would silently delete a line and make the preview disagree with what was sent - but the moderator is the one who can act on it, so it has to be surfaced to them rather than left for the author to discover.
Only bare {name} forms are considered. Most of Toolbox’s interactive tokens carry a : or
# ({input: label}, {choice#id}), so they cannot be mistaken for an unresolved macro;
toolboxBareTokens covers the one that does not.
Parameters¶
text¶
string
The reason text to scan.
resolved¶
Record<string, string>
The token names substitution will replace.
Returns¶
string[]
nativeMacroTokens()¶
nativeMacroTokens(
data):Record<string,string>
Defined in: extension/data/modules/removalreasons/nativeMacros.ts:27
Reddit’s saved-response macros, resolved against the item being removed.
Reddit spells its macros with the same single braces Toolbox uses, but every one carries a
community_, content_ or linked_ prefix, so the two namespaces cannot collide and one
substitution pass serves both. That is why these can be folded straight into the overlay’s
token source rather than needing a separate pass over native-origin text.
Macros Reddit resolves but Toolbox cannot are deliberately left out rather than mapped to an
empty string. replaceTokens leaves an unrecognized token untouched, so the moderator sees
the macro text and can tell it did not resolve, instead of the message quietly losing a line.
The community macros resolve only when their data was fetched (see communityTitle and
friends on RemovalReasonsData); the fetch is skipped on removals whose reasons never
mention them.
{linked_community_rule} is the one macro that cannot be resolved at all. It names the rule
bound to a saved response, and that binding is not in the removal-reasons API - a reason comes
back as id/title/message and nothing else. Having the rules list does not help, because
the problem is knowing which rule was linked, not how to render it.
Parameters¶
data¶
The overlay’s context for the item being removed.
Returns¶
Record<string, string>