Skip to main content

Class: MediaParser<Options>

@sapphire/plugin-api.MediaParser

A media parser

Since

1.3.0

Type parameters

NameType
Optionsextends Options = Options

Hierarchy

  • Piece<Options, "mediaParsers">

    MediaParser

Constructors

constructor

new MediaParser<Options>(context, options?): MediaParser<Options>

Type parameters

NameType
Optionsextends PieceOptions = PieceOptions

Parameters

NameType
contextLoaderContext
optionsOptions

Returns

MediaParser<Options>

Overrides

Piece&lt;Options, 'mediaParsers'&gt;.constructor

Defined in

projects/plugins/packages/api/src/lib/structures/MediaParser.ts:13

Properties

enabled

enabled: boolean

Whether or not the piece is enabled.

Inherited from

Piece.enabled

Defined in

node_modules/@sapphire/pieces/dist/esm/index.d.mts:234


location

Readonly location: PieceLocation

The location metadata for the piece's file.

Inherited from

Piece.location

Defined in

node_modules/@sapphire/pieces/dist/esm/index.d.mts:226


name

Readonly name: string

The name of the piece.

Inherited from

Piece.name

Defined in

node_modules/@sapphire/pieces/dist/esm/index.d.mts:230


options

Readonly options: Options

The raw options passed to this Piece

Inherited from

Piece.options

Defined in

node_modules/@sapphire/pieces/dist/esm/index.d.mts:238


store

Readonly store: MediaParserStore

The store that contains the piece.

Inherited from

Piece.store

Defined in

node_modules/@sapphire/pieces/dist/esm/index.d.mts:222

Accessors

container

get container(): Container

A reference to the Container object for ease of use.

Returns

Container

See

container

Inherited from

Piece.container

Defined in

node_modules/@sapphire/pieces/dist/esm/index.d.mts:244

Methods

accepts

accepts(route): boolean

Checks if a route accepts the media type from this parser.

Parameters

NameTypeDescription
routeRoute<RouteOptions>The route to be checked.

Returns

boolean

Since

1.3.0

Defined in

projects/plugins/packages/api/src/lib/structures/MediaParser.ts:28


contentStream

contentStream(request): null | Gunzip | ApiRequest

Reads the content stream from a request, piping the data through a transformer stream.

Parameters

NameTypeDescription
requestApiRequestThe request to read the body from.

Returns

null | Gunzip | ApiRequest

Since

1.3.0

Defined in

projects/plugins/packages/api/src/lib/structures/MediaParser.ts:67


onLoad

onLoad(): unknown

Per-piece listener that is called when the piece is loaded into the store. Useful to set-up asynchronous initialization tasks.

Returns

unknown

Inherited from

Piece.onLoad

Defined in

node_modules/@sapphire/pieces/dist/esm/index.d.mts:249


onUnload

onUnload(): unknown

Per-piece listener that is called when the piece is unloaded from the store. Useful to set-up clean-up tasks.

Returns

unknown

Inherited from

Piece.onUnload

Defined in

node_modules/@sapphire/pieces/dist/esm/index.d.mts:254


readBuffer

readBuffer(request): Promise<Buffer>

Reads the content body as a buffer, this is useful for parsing/reading binary data.

Parameters

NameTypeDescription
requestApiRequestThe request to read the body from.

Returns

Promise<Buffer>

Since

1.3.0

Defined in

projects/plugins/packages/api/src/lib/structures/MediaParser.ts:52


readString

readString(request): Promise<string>

Reads the content body as a string, this is useful for parsing/reading plain-text data.

Parameters

NameTypeDescription
requestApiRequestThe request to read the body from.

Returns

Promise<string>

Since

1.3.0

Defined in

projects/plugins/packages/api/src/lib/structures/MediaParser.ts:37


reload

reload(): Promise<void>

Reloads the piece by loading the same path in the store.

Returns

Promise<void>

Inherited from

Piece.reload

Defined in

node_modules/@sapphire/pieces/dist/esm/index.d.mts:262


run

run(request): unknown

Parses the body data from an API request.

Parameters

NameType
requestApiRequest

Returns

unknown

Since

1.3.0

Defined in

projects/plugins/packages/api/src/lib/structures/MediaParser.ts:21


toJSON

toJSON(): PieceJSON

Defines the JSON.stringify behavior of this piece.

Returns

PieceJSON

Inherited from

Piece.toJSON

Defined in

node_modules/@sapphire/pieces/dist/esm/index.d.mts:266


unload

unload(): Promise<void>

Unloads and disables the piece.

Returns

Promise<void>

Inherited from

Piece.unload

Defined in

node_modules/@sapphire/pieces/dist/esm/index.d.mts:258