-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
144 lines (124 loc) · 4.88 KB
/
Copy pathindex.js
File metadata and controls
144 lines (124 loc) · 4.88 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
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
const { Client } = require("discord.js-selfbot-v13");
const fs = require('fs');
const path = require('path');
require("dotenv").config({ path: path.join(__dirname, ".env") });
const channelId = process.env.CHANNEL_ID;
const tokens = process.env.DISCORD_TOKENS.split(",");
const totalClients = tokens.length;
let connectedClients = 0;
// Load bump bots configuration
const configPath = path.join(__dirname, 'config.json');
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
const bumpBots = config.bots;
const delayConfig = config.settings?.delay || { min: 90, max: 300 };
const statusConfig = config.settings?.status || {
enabled: false,
type: "online",
duration: 600,
afterStatus: "invisible"
};
const minutesToMs = (minutes) => minutes * 60 * 1000;
const getRandomInterval = (min, max) => Math.floor(Math.random() * (max - min + 1) + min);
const activeClients = new Set();
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
const getRandomDelay = () => minutesToMs(getRandomInterval(delayConfig.min, delayConfig.max) / 60);
const getBotInterval = (config) => minutesToMs(getRandomInterval(config.interval.min, config.interval.max));
const formatTime = (ms) => {
const seconds = Math.round(ms / 1000);
return seconds >= 60 ? `${Math.round(seconds / 60)}m` : `${seconds}s`;
};
async function manageStatus(client, status, duration = null) {
try {
await client.user.setStatus(status);
console.log(`[${client.user.username}] Status: ${status}${duration ? ` for ${duration}s` : ''}`);
} catch (error) {
console.error(`[${client.user.username}] Failed to set status:`, error);
}
}
async function executeBumpCommand(channel, botId, config, username, client) {
let statusPromise = Promise.resolve();
if (statusConfig.enabled) {
statusPromise = (async () => {
await manageStatus(client, statusConfig.type, statusConfig.duration);
await sleep(minutesToMs(statusConfig.duration / 60));
await manageStatus(client, statusConfig.afterStatus);
})();
}
try {
await channel.sendSlash(botId, config.command, ...config.args);
console.log(`[${client.user.username}] Command executed: /${config.command} for Bot ${botId}`);
} catch (error) {
console.error(`[${client.user.username}] Command failed for Bot ${botId}:`, error);
}
statusPromise.catch(error => {
console.error(`[${username}] Status management error:`, error);
});
}
function getRandomClient() {
const clients = Array.from(activeClients);
return clients[Math.floor(Math.random() * clients.length)];
}
function startBotCommands() {
Object.entries(bumpBots).forEach(([botId, config]) => {
const scheduleNext = (delay) => {
console.log(`[Bot ${botId}] Next execution in ${formatTime(delay)}`);
setTimeout(executeCommand, delay);
};
const executeCommand = async () => {
if (config.singleAccount) {
// For single account bots, schedule next execution immediately
const nextDelay = getBotInterval(config);
scheduleNext(nextDelay);
const randomClient = getRandomClient();
const channel = randomClient.channels.cache.get(channelId);
await executeBumpCommand(channel, botId, config, randomClient.user.username, randomClient);
} else {
// For multi-account bots, execute all accounts first
let isFirst = true;
for (const client of activeClients) {
if (!isFirst) {
const accountDelay = getRandomDelay();
console.log(`[Bot ${botId}] Waiting ${formatTime(accountDelay)} between accounts`);
await sleep(accountDelay);
}
const channel = client.channels.cache.get(channelId);
await executeBumpCommand(channel, botId, config, client.user.username, client);
isFirst = false;
}
// Schedule next execution after all accounts are done
const nextDelay = getBotInterval(config);
scheduleNext(nextDelay);
}
};
// Initial execution with a short random delay
const initialDelay = Math.floor(Math.random() * 15000);
console.log(`[Bot ${botId}] Initial execution in ${formatTime(initialDelay)}`);
setTimeout(executeCommand, initialDelay);
});
}
async function setupClient(token) {
const client = new Client();
client.on("ready", async () => {
console.log(`${client.user.username} is ready!`);
try {
await client.channels.fetch(channelId);
activeClients.add(client);
connectedClients++;
if (connectedClients === totalClients) {
console.log("All clients connected. Starting bot commands...");
startBotCommands();
}
} catch (error) {
console.error(`Error occurred for ${client.user.username}:`, error);
}
});
try {
await client.login(token);
} catch (error) {
console.error(`Failed to login with token:`, error);
}
}
// Initialize all clients
tokens.forEach(token => {
setupClient(token);
});