【问题标题】:Sending message to a specific channel at a specific time using cron in Discord在 Discord 中使用 cron 在特定时间向特定频道发送消息
【发布时间】:2021-09-30 01:09:28
【问题描述】:

我想在 Discord 中的凌晨 2:00 向特定频道发送消息。我无法让它工作。我做错了吗?

这是我的代码:

const Discord = require("discord.js")
const cron = require("cron")
const client = new Discord.Client()
let channel = "ID#"

let job = new cron.CronJob('0 00 2 * * *', () => {
client.channels.cache.get(channel).send("Hello!!")
})

job.start()

client.login("Server#")

【问题讨论】:

  • 有错误吗?你能把它们也发在这里吗
  • 没有错误。

标签: javascript cron discord discord.js


【解决方案1】:

现在可以了。显然,cron 时间字符串中只有 5 个值,我放了 6 个

现在是代码:

let job = new cron.CronJob('00 2 * * *', () => {
client.channels.cache.get(channel).send("Hello!!")
})

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-10-01
    • 2023-03-27
    • 2019-03-01
    • 2020-07-06
    • 2021-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多