問題描述
\n 換行符不保留代碼塊文本樣式 (\n Line break does not preserve code block text style)
\n 不能用作此處所示的換行符 圖片
代碼部分:
client.on("message", message => {
const embedmsg = new discord.MessageEmbed()
.setTitle("About us")
.setDescription("We are team azec we would like to become a big international fortnite team")
.setDescription("What We Offer: We are team azec we would like to become a big international Fortnite team\n︴VFX and GFX when the discord is bigger\n︴Tryouts\n︴Organised discord server\n︴Good Team\n\n We’re Looking For:\n︴Fortnite Players\n︴VFX and GFX\n︴Manager & Booster & Promoters\n︴Community\n︴Fortnite Coaches
")
.setColor("BLUE")
.setFooter("Yahmo")
message.channel.send(embedmsg);
})
</code></pre>
參考解法
方法 1:
Try setting your text to a variable first
client.on("message", message => {
const desc = "What We Offer: We are team azec we would like to become a big international Fortnite team\n︴VFX and GFX when the discord is bigger\n︴Tryouts\n︴Organised discord server\n︴Good Team\n\n We’re Looking For:\n︴Fortnite Players\n︴VFX and GFX\n︴Manager & Booster & Promoters\n︴Community\n︴Fortnite Coaches";
const embedmsg = new discord.MessageEmbed()
.setTitle("About us")
.setDescription("We are team azec we would like to become a big international fortnite team")
.setDescription("`" + desc + "`")
.setColor("BLUE")
.setFooter("Yahmo")
message.channel.send(embedmsg);
})
方法 2:
Update
I think I get what you mean now. Instead of separated code lines, you want one big code block. Like this:
The trick is instead of using one backtick (`), Discord requires that you use three backticks, like (```) in order to signify that you want to take up multiple lines instead of one. So all you had to do was replace one backtick with three backticks.
Slight changes to osekmedia's observation since your code still pops up errors. I'm also confused by what you mean by \n don't work as line message
. Do you mean you want \n
to show up in the message itself? If not, then your code is already working fine.
If you ran the code, you would've gotten a MessageEmbed
error. To fix that, I would recommend just installing the entire discord.js
module.
Code:
const Discord = require('discord.js');
const client = new Discord.Client();
const prefix = '!';
require('dotenv').config();
client.on("message", message => {
const embedmsg = new Discord.MessageEmbed()
.setTitle("About us")
.setDescription("We are team azec we would like to become a big international fortnite team")
.setDescription("`What We Offer: We are team azec we would like to become a big international Fortnite team\n︴VFX and GFX when the discord is bigger\n︴Tryouts\n︴Organised discord server\n︴Good Team\n\n We’re Looking For:\n︴Fortnite Players\n︴VFX and GFX\n︴Manager & Booster & Promoters\n︴Community\n︴Fortnite Coaches`")
.setColor("BLUE")
.setFooter("Yahmo")
message.channel.send(embedmsg);
});
client.login(process.env.BOTTOKEN);
NEW CODE:
const Discord = require('discord.js');
const client = new Discord.Client();
const prefix = '!';
require('dotenv').config();
client.on("message", message => {
const embedmsg = new Discord.MessageEmbed()
.setTitle("About us")
.setDescription("```We are team azec we would like to become a big international fortnite team```")
.setDescription("```What We Offer: We are team azec we would like to become a big international Fortnite team\n︴VFX and GFX when the discord is bigger\n︴Tryouts\n︴Organised discord server\n︴Good Team\n\n We’re Looking For:\n︴Fortnite Players\n︴VFX and GFX\n︴Manager & Booster & Promoters\n︴Community\n︴Fortnite Coaches```")
.setColor("BLUE")
.setFooter("Yahmo")
message.channel.send(embedmsg);
});
client.login(process.env.BOTTOKEN);
(by Yahmo、osekmedia、PerplexingParadox)
參考文件