小编Cho*_*ini的帖子

使用 discord.js V12 获取消息对我不起作用。[Discord.js V12]

正如您在我的标题中看到的那样,我无法使用 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

javascript node.js discord.js

6
推荐指数
1
解决办法
6887
查看次数

标签 统计

discord.js ×1

javascript ×1

node.js ×1