【发布时间】:2019-05-18 03:49:15
【问题描述】:
我正在尝试让机器人在特定时间编写消息。示例:
const Discord = require("discord.js");
const client = new Discord.Client();
client.on("ready", () => {
console.log("Online!");
});
var now = new Date();
var hour = now.getUTCHours();
var minute = now.getUTCMinutes();
client.on("message", (message) => {
if (hour === 10 && minute === 30) {
client.channels.get("ChannelID").send("Hello World!");
}
});
不幸的是,它只有在我触发另一个命令时才有效,例如:
if (message.content.startsWith("!ping")) {
message.channel.send("pong!");
}
my message: !ping (at 10:10 o'clock)
-> pong!
-> Hello World!
我猜它需要不断检查时间变量的东西。
【问题讨论】:
标签: javascript discord.js