正如您可以从我的标题中看出的那样,我无法使用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
});
});
在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
});
});
但这对我没用...
你能帮我吗?或许有其他替代方法。
感谢您的帮助!
编辑1:
它会返回:
(node:17184) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'messages' of undefined