InputMediaBuilder
Holds a number of helper methods for building Input
objects. They are useful when sending media groups and when editing media messages.
For example, media groups can be sent like this.
ts
const paths = [
'/tmp/pic0.jpg',
'/tmp/pic1.jpg',
'/tmp/pic2.jpg',
]
const files = paths.map((path) => new InputFile(path))
const media = files.map((file) => InputMediaBuilder.photo(file))
await bot.api.sendMediaGroup(chatId, media)
Media can be edited like this.
ts
const file = new InputFile('/tmp/pic0.jpg')
const media = InputMediaBuilder.photo(file, {
caption: 'new caption'
})
await bot.api.editMessageMedia(chatId, messageId, media)
Type
ts
{
photo(media: string | InputFile, options: InputMediaOptions<InputMediaPhoto>): InputMediaPhoto;
video(media: string | InputFile, options: InputMediaOptions<InputMediaVideo>): InputMediaVideo;
animation(media: string | InputFile, options: InputMediaOptions<InputMediaAnimation>): InputMediaAnimation;
audio(media: string | InputFile, options: InputMediaOptions<InputMediaAudio>): InputMediaAudio;
document(media: string | InputFile, options: InputMediaOptions<InputMediaDocument>): InputMediaDocument;
}