Write to file
This commit is contained in:
parent
f51f7e66c0
commit
216bb7a672
28
index.ts
28
index.ts
@ -1,7 +1,6 @@
|
||||
import { Client, Guild } from 'discord.js-selfbot-v13';
|
||||
import fs from 'fs';
|
||||
|
||||
|
||||
class InfoClient extends Client {
|
||||
public token: string;
|
||||
|
||||
@ -40,22 +39,37 @@ class InfoClient extends Client {
|
||||
});
|
||||
guildData[guild.name] = guildInfo;
|
||||
});
|
||||
const filename = `${this.user?.tag} ${this.token.substring(0, 5)}.json`;
|
||||
const filename = `output/${this.user?.tag} ${this.token.substring(0, 5)}.json`;
|
||||
const jsonData = JSON.stringify(guildData, null, 2);
|
||||
fs.writeFileSync(filename, jsonData);
|
||||
process.exit();
|
||||
console.log(`Data saved to ${filename}`);
|
||||
}
|
||||
}
|
||||
|
||||
function createInfoClientsFromFile(filePath: string): void {
|
||||
async function createInfoClientsFromFile(filePath: string): Promise<void> {
|
||||
try {
|
||||
const tokens = fs.readFileSync(filePath, 'utf-8').split('\n').map(token => token.trim());
|
||||
|
||||
tokens.forEach(token => {
|
||||
const clientPromises = tokens.map(async token => {
|
||||
if (token) {
|
||||
new InfoClient(token);
|
||||
const client = new InfoClient(token);
|
||||
await client.login(token);
|
||||
console.log(`Logged in with token: ${token}`);
|
||||
}
|
||||
});
|
||||
|
||||
await Promise.all(clientPromises);
|
||||
|
||||
console.log("All clients logged in successfully.");
|
||||
process.exit();
|
||||
} catch (error) {
|
||||
console.error('Error creating InfoClients:', error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
const tokensFilePath = 'tokens.txt';
|
||||
createInfoClientsFromFile(tokensFilePath);
|
||||
createInfoClientsFromFile(tokensFilePath).catch(err => {
|
||||
console.error('Error creating InfoClients:', err);
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user