正如您在我的标题中看到的那样,我无法使用 discord.js 获取消息。
在 discord.js v11 中,我使用了这个:
var bot = new Discord.Client();
bot.on('ready', () => {
bot.channels.get(channelID).fetchMessages({ around: messageID, limit: 1 })
.then(async msg => {
//my code here
});
});
Run Code Online (Sandbox Code Playgroud)
Id discord.js v12 应该是这样的:
var bot = new Discord.Client();
bot.on('ready', () => {
bot.channels.cache.get(channelID).messages.fetch({ around: messageID, limit: 1 })
.then(async msg => {
//my code here
});
});
Run Code Online (Sandbox Code Playgroud)
但它对我不起作用..
你能帮我吗?可能有其他选择。
感谢您的帮助 !
编辑1:它返回:
(node:17184) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'messages' of undefined