TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published


Builders library for JaDL

Base Builders


Embed allows the creation of a normal Discord embed object through a builder

Create an embed

import { Embed } from '@jadl/builders'

const embed = new Embed()
  .title('Hello world!')
  .description('I am here')

You can then render the embed to a Discord API embed object

embed.render() // APIEmbed


FileBuilder allows the appension of files to a MessageBuilder or through the parser

import { FileBuilder } from '@jadl/builders'

const attachments = new FileBuilder()
  .add('hello.txt', Buffer.from('Hi'))
  .add('image.png', imageBuffer)

You can then render the FIleBuilder as a form-data object ready to be sent to Discord or through parser



MessageBuilder allows the appension of the builders and other useful objects to be sent through the parser

import { MessageBuilder } from '@jadl/builders'

const message = new MessageBuilder({ content: 'Hello world' })
    type: ComponentType.Button,
    custom_id: 'Hello',
    style: ButtonStyle.Primary,
    label: 'Hello World'

You can then render these MessageBuilder's into form-data or a JSON body filled with the data added

message.render() // form-data or JSON body



parse() turns any readable type & the builders in this package into a valid @discordjs/rest RequestData object to be passed directly to the request. It uses the parseMessage() method (below) to create the type, but then adds all of the extra properties and headers necesarry for the request.

worker // instantiated worker with @discordjs/rest REST on .api

import { parse, MessageTypes } from '@jadl/builders'

function sendMessage (channelId: string, input: MessageTypes) {
  worker.api.post(`/channels/${channelId}/messages`, parse(input))
// example list of what you can pass into parse below


parseMessage() turns any readable type & the builders in this package into a valid message JSON or form-data. It can take many types like strings, our builders like Embeds and FileBuilders, and of course MessageBuilders, and tries it's best to configure it into a message ready to be sent

⚠️ It is recommended to use parse() as not doing so might lack the necesarry headers and configuration to send it as an actual message

import { parseMessage } from '@jadl/builders'

// works on stringified types such as strings, bigints, numbers & symbols
parseMessage('hello world') => { content: 'hello world' }

// works on our builders
  new Embed()
    .title('hello world')
) => { embeds: [ { title: 'hello world' } ] }
// anything with files involved will return a form-data
  new FileBuilder()
    .add('hello.txt', Buffer.from('hi'))
) => FormData<[ ['hello.txt', Buffer<68 69>] ]>

// and of course, on MessageBuilders
  new MessageBuilder({ content: 'hello' })
      new Embed()
) => { content: 'hello', embeds: [ { title: 'goobye' }], components: [ ... ] }

// as afforementied, when a file is involed MessageBuilders will also turn into form-data
  new MessageBuilder({ content: 'hi' })
      new FileBuilder()
        .add('hi.txt', Buffer.from('hi'))
) => FormData<[ ['hi.txt', Buffer<68 69>], [ 'payload_json', '{"content": "hi"}' ] ]>
                                           // json payloads are attached correctly for Discord uploading


npm i @jadl/builders

DownloadsWeekly Downloads






Unpacked Size

44.1 kB

Total Files


Last publish


  • jpbberry