ChannelGrab/index.ts

76 lines
2.3 KiB
TypeScript
Raw Normal View History

2024-06-28 00:51:24 +02:00
import { Client, Guild } from 'discord.js-selfbot-v13';
2024-06-28 01:16:25 +02:00
import fs from 'fs';
2024-06-28 00:51:24 +02:00
class InfoClient extends Client {
public token: string;
public constructor(token: string) {
2024-06-28 00:51:24 +02:00
super();
this.token = token;
2024-06-28 00:51:24 +02:00
this.init();
}
private async init(): Promise<void> {
2024-06-28 01:35:13 +02:00
this.once('ready', () => this.onReady());
await this.login(this.token);
2024-06-28 00:51:24 +02:00
}
private onReady(): void {
console.log(`Logged in as ${this.user?.tag}!`);
2024-06-28 00:59:36 +02:00
const guildData: { [key: string]: { [key: string]: string[] } } = {};
2024-06-28 00:51:24 +02:00
this.guilds.cache.forEach((guild: Guild) => {
2024-06-28 00:59:36 +02:00
const guildInfo: { [key: string]: string[] } = {};
2024-06-28 00:51:24 +02:00
console.log(`Guild: ${guild}`);
const channels = guild.channels.cache;
console.log(`There are ${channels.size} channels in the guild.`);
channels.forEach(channel => {
2024-06-28 01:35:13 +02:00
if (channel && channel.type !== 'GUILD_CATEGORY') {
2024-06-28 00:59:36 +02:00
const categoryName = channel.parent?.name || 'Uncategorized';
const categoryID = channel.parent?.id || 'Uncategorized';
if (!guildInfo[categoryName]) {
guildInfo[categoryName] = [];
}
guildInfo[categoryName].push(`${channel.name} (${channel.type} ${channel.id})`);
2024-06-28 01:35:13 +02:00
}
2024-06-28 00:51:24 +02:00
});
2024-06-28 00:59:36 +02:00
guildData[guild.name] = guildInfo;
2024-06-28 00:51:24 +02:00
});
2024-06-28 01:35:13 +02:00
const filename = `output/${this.user?.tag} ${this.token.substring(0, 5)}.json`;
2024-06-28 01:03:43 +02:00
const jsonData = JSON.stringify(guildData, null, 2);
2024-06-28 01:16:25 +02:00
fs.writeFileSync(filename, jsonData);
2024-06-28 01:35:13 +02:00
console.log(`Data saved to ${filename}`);
2024-06-28 00:51:24 +02:00
}
}
2024-06-28 01:35:13 +02:00
async function createInfoClientsFromFile(filePath: string): Promise<void> {
try {
const tokens = fs.readFileSync(filePath, 'utf-8').split('\n').map(token => token.trim());
const clientPromises = tokens.map(async token => {
if (token) {
const client = new InfoClient(token);
await client.login(token);
console.log(`Logged in with token: ${token}`);
}
});
2024-06-28 01:35:13 +02:00
await Promise.all(clientPromises);
console.log("All clients logged in successfully.");
process.exit();
} catch (error) {
console.error('Error creating InfoClients:', error);
process.exit(1);
}
}
2024-06-28 00:51:24 +02:00
const tokensFilePath = 'tokens.txt';
2024-06-28 01:35:13 +02:00
createInfoClientsFromFile(tokensFilePath).catch(err => {
console.error('Error creating InfoClients:', err);
});