diff --git a/index.ts b/index.ts index b2fdb80..9e36316 100644 --- a/index.ts +++ b/index.ts @@ -15,15 +15,29 @@ class InfoClient extends Client { private onReady(): void { console.log(`Logged in as ${this.user?.tag}!`); + + const guildData: { [key: string]: { [key: string]: 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 => { - console.log(`- ${channel.name} (${channel.type} ${channel.id})`); + 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})`); + } }); + guildData[guild.name] = guildInfo; }); + console.log(guildData) process.exit(); } }