为什么说 .setDescription 不是函数? (RichEmbed 在 JavaScript)
why does it say .setDescription is not a function? (RichEmbed in JavaScript)
我正在为我的命令 /quotes
创建一个嵌入,它将用于我的 discord 机器人。
代码如下:
if(cmd === `${prefix}quotes`){
quotes = new Discord.RichEmbed();
q1 = " -- Andres Iniesta";
q2 = " -- French Poverb";
q3 = " -- www.quotesgate.com"
.setDescription("**__Here are some inspirational quotes!__**")
.setColor("#319786")
.addField("**Some people like you, some people don't. In the end, you just have to be yourself.**". q1)
.addField("**Wherever life plants you, bloom with grace**", q2)
.addField("Don’t forget you’re human. It’s okay to have a meltdown. Just don’t unpack and live there. Cry it out. Then refocus on where you’re headed", q3)
return message.channel.send(quotes);
}
我一直在我的控制台上收到一条错误消息,提示 .setDescription 不是一个函数
/ | TomatoHeadIdiot is now active in 4 servers!
(node:7448) UnhandledPromiseRejectionWarning: TypeError: " -- www.quotesgate.com".setDescription is not a function
问题是您在 q3 = " -- www.quotesgate.com"
行之后没有分号,所以它会在它后面粘贴下一行。所以基本上就变成了
q3 = " -- www.quotesgate.com".setDescription("**__Here are some inspirational quotes!__**")
这当然行不通。我假设您想在嵌入中调用 setDescription
和 addField
,因此您需要将代码更改为以下内容:
if(cmd === `${prefix}quotes`){
q1 = " -- Andres Iniesta";
q2 = " -- French Poverb";
q3 = " -- www.quotesgate.com";
quotes = new Discord.RichEmbed()
.setDescription("**__Here are some inspirational quotes!__**")
.setColor("#319786")
.addField("**Some people like you, some people don't. In the end, you just have to be yourself.**", q1)
.addField("**Wherever life plants you, bloom with grace**", q2)
.addField("Don’t forget you’re human. It’s okay to have a meltdown. Just don’t unpack and live there. Cry it out. Then refocus on where you’re headed", q3);
return message.channel.send(quotes);
}
if(cmd === `${prefix}quotes`){
quotes = new Discord.RichEmbed();
q1 = " -- Andres Iniesta";
q2 = " -- French Poverb";
q3 = " -- www.quotesgate.com";
quotes.setDescription("**__Here are some inspirational quotes!__**");
quotes.setColor("#319786");
quotes.addField("**Some people like you, some people don't. In the end, you just have to be yourself.**". q1);
quotes.addField("**Wherever life plants you, bloom with grace**", q2);
quotes.addField("Don’t forget you’re human. It’s okay to have a meltdown. Just don’t unpack and live there. Cry it out. Then refocus on where you’re headed", q3);
return message.channel.send(quotes);
}
完成! :-)
我正在为我的命令 /quotes
创建一个嵌入,它将用于我的 discord 机器人。
代码如下:
if(cmd === `${prefix}quotes`){
quotes = new Discord.RichEmbed();
q1 = " -- Andres Iniesta";
q2 = " -- French Poverb";
q3 = " -- www.quotesgate.com"
.setDescription("**__Here are some inspirational quotes!__**")
.setColor("#319786")
.addField("**Some people like you, some people don't. In the end, you just have to be yourself.**". q1)
.addField("**Wherever life plants you, bloom with grace**", q2)
.addField("Don’t forget you’re human. It’s okay to have a meltdown. Just don’t unpack and live there. Cry it out. Then refocus on where you’re headed", q3)
return message.channel.send(quotes);
}
我一直在我的控制台上收到一条错误消息,提示 .setDescription 不是一个函数
/ | TomatoHeadIdiot is now active in 4 servers!
(node:7448) UnhandledPromiseRejectionWarning: TypeError: " -- www.quotesgate.com".setDescription is not a function
问题是您在 q3 = " -- www.quotesgate.com"
行之后没有分号,所以它会在它后面粘贴下一行。所以基本上就变成了
q3 = " -- www.quotesgate.com".setDescription("**__Here are some inspirational quotes!__**")
这当然行不通。我假设您想在嵌入中调用 setDescription
和 addField
,因此您需要将代码更改为以下内容:
if(cmd === `${prefix}quotes`){
q1 = " -- Andres Iniesta";
q2 = " -- French Poverb";
q3 = " -- www.quotesgate.com";
quotes = new Discord.RichEmbed()
.setDescription("**__Here are some inspirational quotes!__**")
.setColor("#319786")
.addField("**Some people like you, some people don't. In the end, you just have to be yourself.**", q1)
.addField("**Wherever life plants you, bloom with grace**", q2)
.addField("Don’t forget you’re human. It’s okay to have a meltdown. Just don’t unpack and live there. Cry it out. Then refocus on where you’re headed", q3);
return message.channel.send(quotes);
}
if(cmd === `${prefix}quotes`){
quotes = new Discord.RichEmbed();
q1 = " -- Andres Iniesta";
q2 = " -- French Poverb";
q3 = " -- www.quotesgate.com";
quotes.setDescription("**__Here are some inspirational quotes!__**");
quotes.setColor("#319786");
quotes.addField("**Some people like you, some people don't. In the end, you just have to be yourself.**". q1);
quotes.addField("**Wherever life plants you, bloom with grace**", q2);
quotes.addField("Don’t forget you’re human. It’s okay to have a meltdown. Just don’t unpack and live there. Cry it out. Then refocus on where you’re headed", q3);
return message.channel.send(quotes);
}
完成! :-)