-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautogreet.js
More file actions
63 lines (58 loc) · 2.3 KB
/
Copy pathautogreet.js
File metadata and controls
63 lines (58 loc) · 2.3 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
module.exports.config = {
name: "autogreet",
version: "1.0.0",
hasPermission: 0,
credits: "Prince Sanel",
description: "Bot Greet",
commandCategory: "No Prefix",
cooldowns: 0,
};
const fs = require("fs");
module.exports.handleEvent = function({ api, event, client, __GLOBAL }) {
var { threadID, messageID } = event;
const cron = require("node-cron")
cron.schedule('0 0 0 * * *', () => {
api.getThreadList(30, null, ["INBOX"], (err, list) => {
if (err) return console.log("ERR: "+err);
list.forEach(now => (now.isGroup == true && now.threadID != list.threadID) ? api.sendMessage("Goodmorning everyone, have a nice day!!", now.threadID) : '');
});
}, {
scheduled: true,
timezone: "Asia/Manila"
});
cron.schedule('0 0 8 * *', () => {
api.getThreadList(30, null, ["INBOX"], (err, list) => {
if (err) return console.log("ERR: "+err);
list.forEach(now => (now.isGroup == true && now.threadID != list.threadID) ? api.sendMessage("Goodmorning everyone, Dont forget to eat your breakfast!!", now.threadID) : '');
});
}, {
scheduled: true,
timezone: "Asia/Manila"
});
cron.schedule('0 0 12 * *', () => {
api.getThreadList(30, null, ["INBOX"], (err, list) => {
if (err) return console.log("ERR: "+err);
list.forEach(now => (now.isGroup == true && now.threadID != list.threadID) ? api.sendMessage("Goodnoon everyone, Dont forget to eat your lunch!!", now.threadID) : '');
});
}, {
scheduled: true,
timezone: "Asia/Manila"
});
cron.schedule('0 0 15 * *', () => {
api.getThreadList(30, null, ["INBOX"], (err, list) => {
if (err) return console.log("ERR: "+err);
list.forEach(now => (now.isGroup == true && now.threadID != list.threadID) ? api.sendMessage("Good afternoon everyone, Stay safe!!", now.threadID) : '');
});
}, {
scheduled: true,
timezone: "Asia/Manila"
});
var link = [
"https://i.imgur.com/nmpei2t.gif",
"https://i.imgur.com/nmpei2t.gif",
]
var callback = () => api.sendMessage({ body: msg, attachment: fs.createReadStream(__dirname + "/cache/randomly.jpg")}, event.threadID, () => fs.unlinkSync(__dirname + "/cache/randomly.jpg"));
return request(encodeURI(link[Math.floor(Math.random() * link.length)])).pipe(fs.createWriteStream(__dirname + "/cache/randomly.jpg")).on("close", () => callback());
}
module.exports.run = function({ api, event, client, __GLOBAL }) {
}