I want to put some data with colons separating them, but want to ensure the colon lines up horizontally on each line. Only way is to padd it with spaces, except multiple adjacent spaces get collapsed into 1 space. How can I force a space? In html it is possible using a html entity
for non breaking space, but wondering how do do it in discord.js? Using \u200B
didn't work either.
I have like
.addFields(
{ name : 'Stats' , value : 'A : test\r\nBBBB : test2'}
)
This will turn into
Stats
A : test
BBBB : test2
but I want it more like
Stats
A : test
BBBB : test2
I want to put some data with colons separating them, but want to ensure the colon lines up horizontally on each line. Only way is to padd it with spaces, except multiple adjacent spaces get collapsed into 1 space. How can I force a space? In html it is possible using a html entity
for non breaking space, but wondering how do do it in discord.js? Using \u200B
didn't work either.
I have like
.addFields(
{ name : 'Stats' , value : 'A : test\r\nBBBB : test2'}
)
This will turn into
Stats
A : test
BBBB : test2
but I want it more like
Stats
A : test
BBBB : test2
Share
Improve this question
asked Jul 14, 2020 at 18:33
omegaomega
44.1k90 gold badges286 silver badges523 bronze badges
1
- Have you figured this out? having the same issue. The \ suggestion below does not work. – Bagzli Commented Jul 16, 2022 at 21:50
4 Answers
Reset to default 1Use code blocks in your discord message. The text is displayed in monospaced font and can be arranged by using spaces and linefeeds. Complete info: https://gist.github./matthewzring/9f7bbfd102003963f9be7dbcf7d40e51#syntax-highlighting
While this may not be an exact solution, it may help some so I will add this. Discord filters some characters from messages that they believe are problematic. Assuming discord.js doesn't filter out additional characters there are some unicode spaces that appear to work. In my case I wanted to add a blank inline field. I was able to add a zero width space.
Example
const msg = JSON.stringify({
username: "Example",
content: "Example Content",
embeds: [
{
title: "Title",
description: "Test",
color: 16758413,
fields: [
{
name: "Header 1",
value: "Some Data",
inline: true,
},
{
name: ``,
value: ``,
inline: true,
},
{
name: "Header 3",
value: "Some More Data",
inline: true,
},
],
},
],
});
While you cannot see it, there is a zero width space in index 1 of the fields array between the backticks. You might be able to play with other types of unicode spaces to see if you can bypass that filter. On Mac ctrl+cmd - space
will open the character viewer. You can then search for space
to see various unicode spaces.
You simply need to embrace your string with magic quote (`) like:
addFields([{
name: "Stats",
value: "`A : test\nBBBB : test2`"
}, {
name: "Stats",
value: `\`A : ${"test"}\nBBBB : test2\``
}]);
Both are identic, the second one allow you to use string templating.
use "\ " (backslash, then space) and that will force the additional spaces to appear. Do that for as many spaces as you need, as often as you need them.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745418378a4626855.html
评论列表(0条)