-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
44 lines (40 loc) · 1.28 KB
/
index.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
43
44
const { Client, Intents } = require('discord.js');
const { token, channels } = require('./config.json');
const cron = require('node-cron');
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
client.once('ready', async () => {
console.log('Ready!');
await sendMikuomoConoHa();
cron.schedule(
'0 */30 * * * *',
async () => await sendMikuomoConoHa(),
{
timezone: "Asia/Tokyo"
}
);
});
client.login(token);
async function sendMikuomoConoHa () {
try {
let imgUrl = `https://conoha.mikumo.com/guideline/images/fanfic/fanfic_${Math.floor(Math.random() * 39) + 1}.png`;
if (!imgUrl) return;
for (const channelKey in channels) {
let channel = client.channels.cache.get(channels[channelKey]);
if (!channel || !channel.isText()) return;
await channel.send({
embeds: [
{
image: {
url: imgUrl
},
footer: {
text: "(C)GMO Internet, Inc. 再使用の禁止されています。"
}
}
]
})
}
} catch (err) {
console.error(err);
}
}