Change writing format

This commit is contained in:
Joren 2024-06-28 01:56:26 +02:00
parent ad7f6dcee6
commit 7c202dfa3c
Signed by: Joren
GPG Key ID: 280E33DFBC0F1B55

View File

@ -18,10 +18,10 @@ class InfoClient extends Client {
private onReady(): void { private onReady(): void {
console.log(`Logged in as ${this.user?.tag}!`); 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<string, { channelname: string, channeltype: string, access: boolean }> } } } = {};
this.guilds.cache.forEach((guild: Guild) => { this.guilds.cache.forEach((guild: Guild) => {
const guildInfo: { [key: string]: { channels: string[], permissions: string[] } } = {}; const guildInfo: { [key: string]: { channels: Record<string, { channelname: string, channeltype: string, access: boolean }> } } = {};
console.log(`Guild: ${guild.name}`); console.log(`Guild: ${guild.name}`);
guild.channels.cache.forEach(channel => { guild.channels.cache.forEach(channel => {
if (channel.type !== 'GUILD_CATEGORY') { if (channel.type !== 'GUILD_CATEGORY') {
@ -29,17 +29,19 @@ class InfoClient extends Client {
const categoryID = channel.parent?.id || 'Uncategorized'; const categoryID = channel.parent?.id || 'Uncategorized';
if (!guildInfo[categoryName]) { 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)) { if (channel.permissionsFor(this.user!)?.has(Permissions.FLAGS.VIEW_CHANNEL)) {
access = 'ACCESS'; access = true;
} else {
access = 'NO_ACCESS';
} }
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; guildData[guild.name] = guildInfo;