fmt
ref / parse-mode / fmt
This is the format tagged template function. It accepts a template literal containing any mix of Stringable
, string
, Formatted
, Text
, Caption
, and Entity
values, and constructs a Formatted
that represents the combination of all the given values. The constructed Formatted
also implements Stringable, TextWithEntities, and CaptionWithEntities, and can be used in further fmt
tagged templates.
Can also be called like regular function and passed an array of Stringable
s.
ts
// Using return values of fmt in fmt
const left = fmt`${b}bolded${b}`;
const right = fmt`${u}underlined${u}`;
const combined = fmt`${left} ${ctx.msg.text} ${right}`;
await ctx.reply(combined.text { entities: combined.entities });
Parameters
rawStringParts
ts
rawStringParts: TemplateStringsArray
An array of string
parts found in the tagged template
…entityTagsOrFormattedTextObjects
ts
...entityTagsOrFormattedTextObjects: (Stringable | TextWithEntities | CaptionWithEntities | EntityTag | (() => EntityTag))[]