我在使用v12,过了很长时间,我决定重新开始编码,但我遇到了一个我无法完全修复的问题。一开始,我想向Message类添加一个函数,如下所示
Discord.Message.prototype.no = function(content){
this.channel.send(`:x: - ${content}`)
};但过了一段时间后,我发现我发送的一些消息没有这个函数,并抛给我一个错误,我使用console.log来查看哪些消息没有这个函数,它不是一个Message,而是一个ExtendedMessage类。

我的问题是,什么是ExtendedMessage?我在文档中什么也没有找到,在google上搜索它时,我只找到了与内联回复等相关的东西。不和谐没有类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"
}发布于 2021-11-01 15:03:41
discord-buttons包使用ExtendedMessage来扩展Message类。你可以看到here。这就是为什么在控制台中它会像这样显示。此外,箭头函数没有自己的this。需要使用function关键字来绑定this。
这对我很有效
Discord.Message.prototype.no = function(content) {
this.channel.send(`:x: - ${content}`)
}https://stackoverflow.com/questions/69798399
复制相似问题