0
Imは別のメソッドからメソッドを呼び出そうとオブジェクト内で定義されていない言うと、私が手にエラーがこれです:は、関数が
TypeError: this.displayCur is not a function
エラーが方法this.start
私のコード内にあります:
function Game(room , author) {
this.room = room;
this.author = author;
this.wrongLetters = [];
this.rightLetters = [];
this.guessesLeft = 5;
this.correctGuesses = [];
this.wrongGuesses = [];
this.start = function() {
dClient.on("message" , function(message) {
//this.prototype.guess(message);
if (!message.author.bot && this.guessesLeft > 0) {
console.log("Guess made: " + message);
} else if (!message.author.bot && this.guessesLeft <= 0) {
this.end();
}
this.displayCur("hello"); < ------ the error occurs here
});
};
this.displayCur = function(state) {
this.finStr = "";
for (var l = 0; l < this.word.length;l++) {
if (this.correctGuesses.includes(this.word[l])) {
this.finStr += this.word[l] + "\ \\";
} else {
this.finStr += "_" + "\ \\";
}
}
if (state != "begin") {
this.room.send(this.finStr);
}
};
this.displayCur("begin");
}
NOTE
コードの一部が削除されたので、無関係なコードで埋められません。 コンテキストがないものがある場合は、無視してください。
dClient.on("message" , (message) => {
へ
ああ、ありがとう!それを解決しました。 – greuzr