diff --git a/index.ts b/index.ts index ca0d9df..6c1753e 100644 --- a/index.ts +++ b/index.ts @@ -1,4 +1,4 @@ -import { Client, Guild } from 'discord.js-selfbot-v13'; +import { Client, Guild, Permissions } from 'discord.js-selfbot-v13'; import fs from 'fs'; class InfoClient extends Client { @@ -11,34 +11,40 @@ class InfoClient extends Client { } private async init(): Promise { - this.once('ready', () => this.onReady()); - await this.login(this.token); + this.once('ready', () => this.onReady()); + await this.login(this.token); } private onReady(): void { console.log(`Logged in as ${this.user?.tag}!`); - - const guildData: { [key: string]: { [key: string]: string[] } } = {}; + + const guildData: { [key: string]: { [key: string]: { channels: string[], permissions: string[] } } } = {}; this.guilds.cache.forEach((guild: Guild) => { - const guildInfo: { [key: string]: string[] } = {}; - console.log(`Guild: ${guild}`); - const channels = guild.channels.cache; - console.log(`There are ${channels.size} channels in the guild.`); - channels.forEach(channel => { - if (channel && channel.type !== 'GUILD_CATEGORY') { - const categoryName = channel.parent?.name || 'Uncategorized'; - const categoryID = channel.parent?.id || 'Uncategorized'; + const guildInfo: { [key: string]: { channels: string[], permissions: string[] } } = {}; + console.log(`Guild: ${guild.name}`); + guild.channels.cache.forEach(channel => { + if (channel.type !== 'GUILD_CATEGORY') { + const categoryName = channel.parent?.name || 'Uncategorized'; + const categoryID = channel.parent?.id || 'Uncategorized'; - if (!guildInfo[categoryName]) { - guildInfo[categoryName] = []; - } + if (!guildInfo[categoryName]) { + guildInfo[categoryName] = { channels: [], permissions: [] }; + } - guildInfo[categoryName].push(`${channel.name} (${channel.type} ${channel.id})`); - } - }); - guildData[guild.name] = guildInfo; + let access = 'unknown'; + if (channel.permissionsFor(this.user!)?.has(Permissions.FLAGS.VIEW_CHANNEL)) { + access = 'ACCESS'; + } else { + access = 'NO_ACCESS'; + } + + guildInfo[categoryName].channels.push(`${channel.name} (${access} ${channel.type} ${channel.id})`); + } + }); + guildData[guild.name] = guildInfo; }); + const filename = `output/${this.user?.tag} ${this.token.slice(-5)}.json`; const jsonData = JSON.stringify(guildData, null, 2); fs.writeFileSync(filename, jsonData); @@ -51,7 +57,7 @@ async function createInfoClientsFromFile(filePath: string): Promise { const tokens = fs.readFileSync(filePath, 'utf-8').split('\n').map(token => token.trim()); const clientPromises = tokens.map(async token => { - if (token) { + if (token) { const client = new InfoClient(token); await client.login(token); console.log(`Logged in with token: ${token}`);