【问题标题】:How to get channel ID through bot - Discord.js如何通过机器人获取频道 ID - Discord.js
【发布时间】:2021-04-10 03:23:08
【问题描述】:

我正在尝试获取命令发送位置的频道 ID,以便我可以使用该 ID 删除频道。我一直在查看 Discord.js 文档,但似乎无法弄清楚。

【问题讨论】:

标签: node.js discord discord.js bots


【解决方案1】:

很简单

message.channel.id

message.channel 是您当前的文本频道,id 是它的 ID。

【讨论】:

  • 当我使用它时,我收到message.channel.id is not a function 的错误消息。我像这样使用message.channel.id:const channelId = message.channel.id();,然后稍后将其用作channelId.delete();。
  • 是的,只需删除 id 处的(),因为id 不是函数^^ 我不知道您为什么这样做id(),因为我的示例中没有显示。 @Arcitezz
  • @Arcitezz 并删除该频道,您必须制作:message.guild.channels.cache.get(channelId).delete()
  • @Arcitezz 我刚刚在评论中解释了它^^
  • 没问题
猜你喜欢
  • 2018-09-24
  • 1970-01-01
  • 2020-03-02
  • 2021-05-04
  • 1970-01-01
  • 2023-04-10
  • 2020-07-26
  • 2020-11-26
  • 2020-03-06
相关资源
最近更新 更多