-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
109 lines (90 loc) · 3.21 KB
/
app.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
const Discord = require("discord.js-selfbot-v13");
const chalk = require('chalk');
require("dotenv").config();
const keepAlive = require("./server.js");
const config = require("./config.js");
keepAlive(config.keepAlivePort);
function formatTime() {
const date = new Date();
const options = {
timeZone: config.timeZone,
hour12: false,
hour: "numeric",
minute: "numeric",
};
return new Intl.DateTimeFormat("en-US", options).format(date);
}
function getRandomStatus(lastStatus) {
const statuses = ["idle", "dnd", "online"];
let newStatus;
do {
const randomIndex = Math.floor(Math.random() * statuses.length);
newStatus = statuses[randomIndex];
} while (newStatus === lastStatus);
return newStatus;
}
function setupClient(client, token) {
let lastStatus = null;
client.on("ready", async () => {
console.clear();
console.log(`${client.user.tag} - RCP STARTED!`);
const r = new Discord.RichPresence(client)
.setApplicationId(config.userid)
.setType(config.type);
if (config.url) r.setURL(config.url);
if (config.state) r.setState(config.state);
if (config.name) r.setName(config.name);
if (config.details) r.setDetails(config.details);
if (config.largeImage) r.setAssetsLargeImage(config.largeImage);
if (config.largeText) r.setAssetsLargeText(config.largeText);
if (config.smallImage) r.setAssetsSmallImage(config.smallImage);
if (config.smallText) r.setAssetsSmallText(config.smallText);
// Jika ingin timestamp selalu diatur, tidak perlu cek
r.setStartTimestamp(Date.now());
config.buttons.forEach(button => {
r.addButton(button.label, button.url);
});
client.user.setActivity(r);
if (config.statusMode === "auto") {
setInterval(() => {
const currentStatus = getRandomStatus(lastStatus);
client.user.setPresence({ status: currentStatus });
if (config.enableLogging) {
let statusMessage;
switch (currentStatus) {
case 'online':
statusMessage = chalk.rgb(153, 153, 255)(`AUTO status: `) + chalk.green(currentStatus) + ' 🟢';
break;
case 'idle':
statusMessage = chalk.rgb(153, 153, 255)(`AUTO status: `) + chalk.yellow(currentStatus) + ' 🟡';
break;
case 'dnd':
statusMessage = chalk.rgb(153, 153, 255)(`AUTO status: `) + chalk.red(currentStatus) + ' 🔴';
break;
}
process.stdout.write(`\r${statusMessage} `);
}
lastStatus = currentStatus;
}, config.statusChangeInterval);
} else if (config.statusMode === "manual") {
client.user.setPresence({ status: config.manualStatus });
if (config.enableLogging) {
console.log(chalk.rgb(153, 153, 255)(`RCP manual status: ${config.manualStatus}`));
}
}
if (config.enableCurrentTime) {
setInterval(() => {
const currentTime = formatTime();
const newDetails = `${config.Message}${currentTime}`;
r.setState(newDetails);
client.user.setActivity(r);
}, 1000);
}
});
client.login(token).catch(console.error);
}
const client = new Discord.Client({
readyStatus: true,
checkUpdate: true,
});
setupClient(client, process.env.TOKEN);