我正在尝试在嵌入的消息描述中创建一个新行。
如果有任何区别,该命令是使用斜杠命令发送的。
/say edit message-id:812711763061375056 description:hello \n newline here
处理程序看起来像这样
const embedMessage = new Discord.MessageEmbed()
.setTitle(title == undefined ? message.embeds[0].title : title.value)
.setDescription(description == undefined ? message.embeds[0].description : description.value)
.setColor(0xfa6607)
description.value
的类型是字符串
谢谢!
解决您问题的一种方法是让您选择的某个字符代表回车符。
可以这样做:
//I have chosen "n" as the character
var index = args.indexOf("n"); //looks for n in your message arguments
if (index !== -1) {
args[index] = "\n"; //replaces any "n" element with "\n"
}
//now you can do whatever you need with your message
message.channel.send(args.join(" "));
示例:编辑消息 ID:812711763061375056 描述:你好,此处换行
注意:我强烈建议不要使用 eval 命令,它们是一个巨大的安全漏洞
今天我测试了它,它可以工作,但在消息开始或结束时不起作用。 但您也可以使用不可见的最终字符,例如“⠀”。 例子。 这个:
⠀\n\nYour description.\n\n⠀
应该给你这个:
⠀
Your description.
⠀