我有一些承诺链接,只有一个承诺会引发内部错误, 但我不知道为什么。有谁知道这个错误?: (给我这个错误的线索,我尝试使用Chrome调试器和其他东西)
facebook.GetDiscordPosts(5) //5 posts default
.then(posts => TournamentsFilter(posts))
.then(tournaments => ToDataFile(tournaments))
//.then(pPosts => discord.PostTournament(pPosts)) <-- Error!
.then(r => console.log("Done!"))
.catch(err => console.log(err))
discord.js代码
'use strict';
const config = require("./config.json");
const Discord = require("discord.js");
const { discord : { token, prefix, channelTarget, webhookID, webhookToken, roleid } } = config;
async function PostTournament (pPosts) {
try {
let discordClient = new Discord.Client();
for (let pPost of pPosts) {
let client = new Discord.WebhookClient(webhookID, webhookToken);
client.name = "Network of Darkness - Admin";
let embed = new Discord.RichEmbed()
.setTitle("New Tournament")
.setURL(pPost.link)
.setImage(pPost.picture)
.setDescription(pPost.message)
.setColor("b23aee");
await client.send(`:loudspeaker: <@&${roleid}>`, embed);
}
} catch (error) {
console.log(error);
}
}
module.exports.PostTournament = async function (pPosts) {
PostTournament(pPosts)
.catch(err => console.log(err))
}
完整错误代码:
internal/process/warning.js:130
warning.name = String(type || 'Warning');
^
TypeError: String is not a function
at process.emitWarning (internal/process/warning.js:130:22)
at emitWarning (internal/process/promises.js:92:15)
at emitPendingUnhandledRejections (internal/process/promises.js:109:11)
at runMicrotasksCallback (internal/process/next_tick.js:124:9)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
答案 0 :(得分:0)
我的问题是:
let postElement = {
id:String = post.id,
link:String = post.permalink_url,
message:String = post.message,
picture:String = post.full_picture
}
修正:
let postElement = {
id : post.id,
link : post.permalink_url,
message : post.message,
picture : post.full_picture
}
Ty @Jaromanda X