From 7c202dfa3c05f8b27cccc7518584ea8d73d02e7f Mon Sep 17 00:00:00 2001 From: Joren Date: Fri, 28 Jun 2024 01:56:26 +0200 Subject: [PATCH] Change writing format --- index.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/index.ts b/index.ts index 6c1753e..a0ccc10 100644 --- a/index.ts +++ b/index.ts @@ -18,10 +18,10 @@ class InfoClient extends Client { private onReady(): void { console.log(`Logged in as ${this.user?.tag}!`); - const guildData: { [key: string]: { [key: string]: { channels: string[], permissions: string[] } } } = {}; + const guildData: { [key: string]: { [key: string]: { channels: Record } } } = {}; this.guilds.cache.forEach((guild: Guild) => { - const guildInfo: { [key: string]: { channels: string[], permissions: string[] } } = {}; + const guildInfo: { [key: string]: { channels: Record } } = {}; console.log(`Guild: ${guild.name}`); guild.channels.cache.forEach(channel => { if (channel.type !== 'GUILD_CATEGORY') { @@ -29,17 +29,19 @@ class InfoClient extends Client { const categoryID = channel.parent?.id || 'Uncategorized'; if (!guildInfo[categoryName]) { - guildInfo[categoryName] = { channels: [], permissions: [] }; + guildInfo[categoryName] = { channels: {} }; } - let access = 'unknown'; + let access = false; if (channel.permissionsFor(this.user!)?.has(Permissions.FLAGS.VIEW_CHANNEL)) { - access = 'ACCESS'; - } else { - access = 'NO_ACCESS'; + access = true; } - guildInfo[categoryName].channels.push(`${channel.name} (${access} ${channel.type} ${channel.id})`); + guildInfo[categoryName].channels[channel.id] = { + channelname: channel.name, + channeltype: channel.type, + access: access + }; } }); guildData[guild.name] = guildInfo;