Line separator/break in discord embded

2020-08-01 04:36发布

问题:

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

回答1:

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



回答2:

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.