Write to file
This commit is contained in:
parent
f51f7e66c0
commit
216bb7a672
44
index.ts
44
index.ts
@ -1,7 +1,6 @@
|
|||||||
import { Client, Guild } from 'discord.js-selfbot-v13';
|
import { Client, Guild } from 'discord.js-selfbot-v13';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
|
||||||
|
|
||||||
class InfoClient extends Client {
|
class InfoClient extends Client {
|
||||||
public token: string;
|
public token: string;
|
||||||
|
|
||||||
@ -12,8 +11,8 @@ class InfoClient extends Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async init(): Promise<void> {
|
private async init(): Promise<void> {
|
||||||
this.once('ready', () => this.onReady());
|
this.once('ready', () => this.onReady());
|
||||||
await this.login(this.token);
|
await this.login(this.token);
|
||||||
}
|
}
|
||||||
|
|
||||||
private onReady(): void {
|
private onReady(): void {
|
||||||
@ -27,7 +26,7 @@ class InfoClient extends Client {
|
|||||||
const channels = guild.channels.cache;
|
const channels = guild.channels.cache;
|
||||||
console.log(`There are ${channels.size} channels in the guild.`);
|
console.log(`There are ${channels.size} channels in the guild.`);
|
||||||
channels.forEach(channel => {
|
channels.forEach(channel => {
|
||||||
if (channel && channel.type !== 'GUILD_CATEGORY') {
|
if (channel && channel.type !== 'GUILD_CATEGORY') {
|
||||||
const categoryName = channel.parent?.name || 'Uncategorized';
|
const categoryName = channel.parent?.name || 'Uncategorized';
|
||||||
const categoryID = channel.parent?.id || 'Uncategorized';
|
const categoryID = channel.parent?.id || 'Uncategorized';
|
||||||
|
|
||||||
@ -36,26 +35,41 @@ class InfoClient extends Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
guildInfo[categoryName].push(`${channel.name} (${channel.type} ${channel.id})`);
|
guildInfo[categoryName].push(`${channel.name} (${channel.type} ${channel.id})`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
guildData[guild.name] = guildInfo;
|
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);
|
const jsonData = JSON.stringify(guildData, null, 2);
|
||||||
fs.writeFileSync(filename, jsonData);
|
fs.writeFileSync(filename, jsonData);
|
||||||
process.exit();
|
console.log(`Data saved to ${filename}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createInfoClientsFromFile(filePath: string): void {
|
async function createInfoClientsFromFile(filePath: string): Promise<void> {
|
||||||
const tokens = fs.readFileSync(filePath, 'utf-8').split('\n').map(token => token.trim());
|
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) {
|
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';
|
const tokensFilePath = 'tokens.txt';
|
||||||
createInfoClientsFromFile(tokensFilePath);
|
createInfoClientsFromFile(tokensFilePath).catch(err => {
|
||||||
|
console.error('Error creating InfoClients:', err);
|
||||||
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user