Save in json format

This commit is contained in:
Joren 2024-06-28 00:59:36 +02:00
parent 92d22d7ef0
commit 9fe5ccc308
Signed by: Joren
GPG Key ID: 280E33DFBC0F1B55

View File

@ -16,14 +16,28 @@ 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]: string[] } } = {};
this.guilds.cache.forEach((guild: Guild) => { this.guilds.cache.forEach((guild: Guild) => {
const guildInfo: { [key: string]: string[] } = {};
console.log(`Guild: ${guild}`); console.log(`Guild: ${guild}`);
const channels = guild.channels.cache; const channels = guild.channels.cache;
console.log(`There are ${channels.size} channels in the guild.`); console.log(`There are ${channels.size} channels in the guild.`);
channels.forEach(channel => { 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(); process.exit();
} }
} }