This repository has been archived by the owner on Feb 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
63 lines (52 loc) · 1.82 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const { Client } = require("honeygain.js");
const cron = require("node-cron");
const { Webhook } = require("simple-discord-webhooks");
const config = require("./config.json");
const client = new Client();
const postman = new Webhook(config.discordWebhookURL);
const RETRY_MAX = 5;
client.login(config.authorization);
const main = async () => {
const embed = {
title: "HoneyGain Honeypot report",
thumbnail: {
url: "https://cdn.discordapp.com/attachments/943520861565091891/943826193734590494/hg_logo_icon_color_dark.png",
},
fields: [],
footer: {
text: "HoneyGain Honeypot bot © LockBlock-dev",
},
};
const { data: user } = await client.me();
const { data: notifications } = await client.notifications();
if (notifications.length === 0)
console.log(new Date().toISOString(), "Honeypot already claimed today!");
else {
await client.notificationsAction(notifications[0].hash, {
campaign_id: notifications[0].campaign_id,
action: "triggered",
user_id: user.id,
});
const { data: winnings } = await client.contestWinnings();
console.log(new Date().toISOString(), `Congrats you won ${winnings.credits}CR today!`);
embed.fields.push({
name: "Winnings:",
value: `${winnings.credits} CR`,
});
await client.notificationsAction(notifications[0].hash, {
campaign_id: notifications[0].campaign_id,
action: "closed",
user_id: user.id,
});
postman.send(null, [embed]);
}
};
cron.schedule("0 12 */1 * *", async () => {
for (let i = 0; i < RETRY_MAX; i++) {
try {
main();
} catch (e) {
console.error(new Date().toISOString(), e);
}
}
});