Compare commits

..

2 Commits

Author SHA1 Message Date
7c202dfa3c
Change writing format 2024-06-28 01:56:26 +02:00
ad7f6dcee6
Add display to show if user has permissions to channel or no 2024-06-28 01:48:09 +02:00

View File

@ -1,4 +1,4 @@
import { Client, Guild } from 'discord.js-selfbot-v13';
import { Client, Guild, Permissions } from 'discord.js-selfbot-v13';
import fs from 'fs';
class InfoClient extends Client {
@ -18,27 +18,35 @@ class InfoClient extends Client {
private onReady(): void {
console.log(`Logged in as ${this.user?.tag}!`);
const guildData: { [key: string]: { [key: string]: string[] } } = {};
const guildData: { [key: string]: { [key: string]: { channels: Record<string, { channelname: string, channeltype: string, access: boolean }> } } } = {};
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 => {
if (channel && channel.type !== 'GUILD_CATEGORY') {
const guildInfo: { [key: string]: { channels: Record<string, { channelname: string, channeltype: string, access: boolean }> } } = {};
console.log(`Guild: ${guild.name}`);
guild.channels.cache.forEach(channel => {
if (channel.type !== 'GUILD_CATEGORY') {
const categoryName = channel.parent?.name || 'Uncategorized';
const categoryID = channel.parent?.id || 'Uncategorized';
if (!guildInfo[categoryName]) {
guildInfo[categoryName] = [];
guildInfo[categoryName] = { channels: {} };
}
guildInfo[categoryName].push(`${channel.name} (${channel.type} ${channel.id})`);
let access = false;
if (channel.permissionsFor(this.user!)?.has(Permissions.FLAGS.VIEW_CHANNEL)) {
access = true;
}
guildInfo[categoryName].channels[channel.id] = {
channelname: channel.name,
channeltype: channel.type,
access: access
};
}
});
guildData[guild.name] = guildInfo;
});
const filename = `output/${this.user?.tag} ${this.token.slice(-5)}.json`;
const jsonData = JSON.stringify(guildData, null, 2);
fs.writeFileSync(filename, jsonData);