我在 v12 上,經過很多時間我決定再次開始編碼,但遇到了一個無法解決的問題。在開始我想一個函式添加到Message類像這樣
Discord.Message.prototype.no = function(content){
this.channel.send(`:x: - ${content}`)
};
但是過了一段時間我看到我發送的一些訊息沒有這個功能并給我一個錯誤msg.no is not a function
我曾經console.log看到什么沒有這個功能,它不是一個Message,它是一個ExtendedMessage類。
我的問題是,什么是 ExtendedMessage ?我在檔案中一無所獲,在 google 上搜索時,我只找到了與行內回復等相關的內容。 Discord 沒有課程ExtendedMessage
我嘗試洗掉 node_modules 并重新安裝所有內容,但沒有幫助。
我的依賴:
"dependencies": {
"@blad3mak3r/reddit-memes": "^0.2.5",
"color": "^4.0.1",
"discord-buttons": "^4.0.0",
"discord.bio": "^10.1.2",
"discord.js": "^12.5.3",
"easier-pokemon": "^1.0.7",
"easy-json-database": "^1.5.0",
"figlet": "^1.5.2",
"genshin": "^1.2.4",
"imgur-api.js": "^2.10.6",
"mal-scraper": "^2.11.3",
"moment": "^2.29.1",
"nekos.life": "^2.0.7",
"node": "^14.17.3",
"node-osu": "^2.2.1",
"node-spotify-api": "^1.1.1",
"node.js": "^0.0.1-security",
"tiktok-scraper": "^1.4.36",
"twitch-api-v5": "^2.0.4",
"user-instagram": "^3.0.0",
"ytsearcher": "^1.2.4"
}
uj5u.com熱心網友回復:
該discord-buttons包使用ExtendedMessage擴展Message類。你可以在這里看到。這就是為什么在控制臺中它顯示這樣的原因。此外,箭頭函式沒有自己的this. 您需要使用function關鍵字來系結this。
這對我有用
Discord.Message.prototype.no = function(content) {
this.channel.send(`:x: - ${content}`)
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/344576.html
標籤:javascript 节点.js 班级 不和谐 不和谐.js
