【问题标题】:Finding names of a channel array查找通道数组的名称
【发布时间】:2020-10-12 03:24:37
【问题描述】:

我想通过获取公会中频道的名称来创建一个字符串数组,但是我尝试过的方法没有奏效。这是我的代码,但 console.log 不发送数组。

if (message.content.startsWith(`${prefix}command`)){
    var channel_list = Array.from(message.guild.channels.name);
    console.log(channel_list);
}

【问题讨论】:

    标签: discord.js


    【解决方案1】:

    你会想要使用Collection.prototype.map()

    Discord.js v11.x

    console.log(message.guild.channels.map((c) => c.name))
    

    Discord.js v12.x

    console.log(message.guild.channels.cache.map((c) => c.name))
    

    【讨论】:

      猜你喜欢
      • 2023-02-23
      • 1970-01-01
      • 2021-09-27
      • 2016-12-19
      • 2020-02-16
      • 2019-05-01
      • 2020-06-05
      • 2013-11-07
      • 2021-05-19
      相关资源
      最近更新 更多