Andrew Rayner
Andrew Rayner

Reputation: 1064

Line separator/break in discord embded

I have the following discord embed:

    message.reply({
    content: '',
    embed: {
        color: 11416728,
        author: {
            name: 'xx know-it-all',
            icon_url: 'https://xx.png'
        },
        description: '',
        footer: {
            icon_url: client.user.avatarURL,
            text: '© xx Network'
        },
        fields: [
            {
                name: '1st Line',
                value: '2nd Line',
            },
            {
                name: 'MAKE THIS JUST A SPACER',
                value: 'MAKE THIS JUST A SPACER',
            },
            {
                name: '5th Line',
                value: '6th Line',
            }
        ]
    }
})

I am trying to figure out how to create a spacer of sorts. I have tried using a html space, blank space, and alt code space. None of them seem to work. Any ideas on how to accomplish this?

The issue is discord is returning the field as null, so it's not taking it when I use the invisible html space or putting \n

Upvotes: 4

Views: 35633

Answers (3)

Airofoil
Airofoil

Reputation: 36

Interestingly, I figured out you can get around this by using the backspace escape-sequence too:

\b

This is useful if you want your embed fields formatted in a 2 x 2:

fields: [
  {
    name: 'Field1',
    value: 'Value1',
    inline: true
  },
  {
    name: 'Field2',
    value: 'Value2',
    inline: true
  },
  {
    name: '\b',
    value: '\b',
    inline: true
  },
  {
    name: 'Field3',
    value: 'Value3',
    inline: true
  },
  {
    name: 'Field4',
    value: 'Value4',
    inline: true
  },
]

Upvotes: 1

André
André

Reputation: 4497

Discord.JS has a method .addEmptyField() that uses \u200B to display a empty line.

    message.reply({
    content: '',
    embed: {
        color: 11416728,
        author: {
            name: 'xx know-it-all',
            icon_url: 'https://xx.png'
        },
        description: '',
        footer: {
            icon_url: client.user.avatarURL,
            text: '© xx Network'
        },
        fields: [
            {
                name: '1st Line',
                value: '2nd Line',
            },
            {
                name: '\u200B',
                value: '\u200B',
            },
            {
                name: '5th Line',
                value: '6th Line',
            }
        ]
    }
})

Appears to be working here.

Upvotes: 3

Andrew Rayner
Andrew Rayner

Reputation: 1064

I got it!

All I needed to do was use the C/C++/Java encoding version of the invisible space

\u200B

Reference: https://www.fileformat.info/info/unicode/char/200B/index.htm

This can come into use for other people looking to make embeds look more clear as discord complicates it

Upvotes: 11

Related Questions