【问题标题】:Discord.js | How do i make a command that sends to a specific channel by id不和谐.js |我如何制作一个通过 id 发送到特定频道的命令
【发布时间】:2021-03-04 10:48:14
【问题描述】:

如何让我的机器人通过 id 向另一个频道发送消息,例如 !say 6969420420 hello

我目前对整个 discord bot 这种东西还是新手,所以请帮帮我,这真的很有帮助

我记得它就像get cache find channel 之类的......

【问题讨论】:

    标签: javascript node.js discord discord.js


    【解决方案1】:

    您可以从客户端获取频道并将消息发送到该频道

     channel = client.channels.cache.get('6969420420');
        channel.send('hello');
    

    你可以阅读更多关于 discord 的缓存here

    【讨论】:

      【解决方案2】:

      使用 args 获取 id 并获取要发送的消息

      client.channels.cache.get(args[0]).send(args[1]);
      

      【讨论】:

      • 试试这个你需要先设置args
      猜你喜欢
      • 2020-05-07
      • 2019-04-11
      • 2021-08-14
      • 2022-08-19
      • 2021-06-22
      • 1970-01-01
      • 1970-01-01
      • 2020-07-14
      • 2021-09-24
      相关资源
      最近更新 更多