【问题标题】:messages.array is not a function in discord.js v13 [duplicate]messages.array 不是 discord.js v13 中的函数 [重复]
【发布时间】:2022-01-17 09:31:53
【问题描述】:

我的这项工作在 discord.js 的 v12 中运行良好,但在 v13 中不起作用。有任何想法吗?这是代码的一部分,稍后关闭。

 interaction.channel.messages.fetch().then(async messages => {

      let finalArray = [];

      const putInArray = async (data) => finalArray.push(data);
      const handleTime = (timestamp) => moment(timestamp).format(`DD/MM/YYYY - hh:mm:ss a`).replace("pm", "PM").replace("am", "AM");

      for (const message of messages.array().reverse()) await putInArray(`${handleTime(message.createdTimestamp)} ${message.author.tag}: ${message.content}`);

来自https://discord.js.org/#/docs/main/stable/class/MessageManagerscrollTo=fetch的解决方案 不工作

【问题讨论】:

    标签: javascript node.js discord.js


    【解决方案1】:

    messages 已经是一个数组,所以你不需要调用 messages.array() 函数,见https://discord.js.org/#/docs/main/stable/class/MessageManager?scrollTo=fetch

    【讨论】:

    • 它清楚地声明它返回一个消息或消息集合。它从来没有说过要返回一个数组
    猜你喜欢
    • 1970-01-01
    • 2023-01-05
    • 2021-02-18
    • 2022-01-07
    • 2021-01-13
    • 2020-09-03
    • 2020-09-02
    • 2021-10-13
    • 2021-11-09
    相关资源
    最近更新 更多