-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcron.js
42 lines (36 loc) · 1.08 KB
/
cron.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const http = require("http");
http
.createServer(function (req, res) {
res.write("day_check.js is active.\nPlease check it.");
res.end();
})
.listen(8080);
const { Client, GatewayIntentBits } = require("discord.js");
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMessages,
],
});
require("dotenv").config();
//起動確認
client.once("ready", () => {
const cron = require("node-cron");
cron.schedule("30 * * * * *", () => {
//現在時刻が30秒の時に実行
console.log("30秒だよ");
});
// コンソールにReady!!と表示
console.log("Ready!!");
// ステータスを設定する
setInterval(() => {
client.user.setActivity({
name: `所属サーバー数は、${client.guilds.cache.size}サーバー| Ping値は、${client.ws.ping}msです`,
});
}, 10 * 1000); //10秒おきに実行
client.channels.cache.get("889486664760721418").send("起動しました!");
});
//Discordへの接続
const token = process.env.token;
client.login(token);