Save in json format
This commit is contained in:
parent
92d22d7ef0
commit
9fe5ccc308
16
index.ts
16
index.ts
@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user