ChannelGrab/index.ts

50 lines
1.4 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
const token = '';
class InfoClient extends Client {
public constructor() {
super();
this.init();
}
private async init(): Promise<void> {
this.once('ready', () => this.onReady());
await this.login(token);
}
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 00:59:36 +02:00
if (channel && channel.type !== 'GUILD_CATEGORY') {
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 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:16:25 +02:00
const filename = `${this.user?.tag}[${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 00:51:24 +02:00
process.exit();
}
}
new InfoClient();