【问题标题】:Is there a way to make a discord.js bot on startup send a message to a certain text channel? [duplicate]有没有办法让 discord.js 机器人在启动时向某个文本通道发送消息? [复制]
【发布时间】:2021-01-07 18:43:43
【问题描述】:

我想知道是否有办法让 discord.js 机器人在启动时向某个文本频道发送消息。

【问题讨论】:

    标签: discord.js


    【解决方案1】:

    是的,这可以通过使用 ready 事件来实现。 当机器人准备好时,这里的任何代码都会被执行”

    client.on("ready", () => {
        client.channels.cache.get("channel-id-here")
              .send(`I'm online!`)
    })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-09-29
      • 2021-06-10
      • 2021-08-22
      • 1970-01-01
      • 2020-11-19
      • 1970-01-01
      • 1970-01-01
      • 2019-04-07
      相关资源
      最近更新 更多