Add display to show if user has permissions to channel or no
This commit is contained in:
parent
1a8f4e8ae9
commit
ad7f6dcee6
44
index.ts
44
index.ts
@ -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';
|
import fs from 'fs';
|
||||||
|
|
||||||
class InfoClient extends Client {
|
class InfoClient extends Client {
|
||||||
@ -11,34 +11,40 @@ class InfoClient extends Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async init(): Promise<void> {
|
private async init(): Promise<void> {
|
||||||
this.once('ready', () => this.onReady());
|
this.once('ready', () => this.onReady());
|
||||||
await this.login(this.token);
|
await this.login(this.token);
|
||||||
}
|
}
|
||||||
|
|
||||||
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[] } } = {};
|
const guildData: { [key: string]: { [key: string]: { channels: string[], permissions: string[] } } } = {};
|
||||||
|
|
||||||
this.guilds.cache.forEach((guild: Guild) => {
|
this.guilds.cache.forEach((guild: Guild) => {
|
||||||
const guildInfo: { [key: string]: string[] } = {};
|
const guildInfo: { [key: string]: { channels: string[], permissions: string[] } } = {};
|
||||||
console.log(`Guild: ${guild}`);
|
console.log(`Guild: ${guild.name}`);
|
||||||
const channels = guild.channels.cache;
|
guild.channels.cache.forEach(channel => {
|
||||||
console.log(`There are ${channels.size} channels in the guild.`);
|
if (channel.type !== 'GUILD_CATEGORY') {
|
||||||
channels.forEach(channel => {
|
const categoryName = channel.parent?.name || 'Uncategorized';
|
||||||
if (channel && channel.type !== 'GUILD_CATEGORY') {
|
const categoryID = channel.parent?.id || 'Uncategorized';
|
||||||
const categoryName = channel.parent?.name || 'Uncategorized';
|
|
||||||
const categoryID = channel.parent?.id || 'Uncategorized';
|
|
||||||
|
|
||||||
if (!guildInfo[categoryName]) {
|
if (!guildInfo[categoryName]) {
|
||||||
guildInfo[categoryName] = [];
|
guildInfo[categoryName] = { channels: [], permissions: [] };
|
||||||
}
|
}
|
||||||
|
|
||||||
guildInfo[categoryName].push(`${channel.name} (${channel.type} ${channel.id})`);
|
let access = 'unknown';
|
||||||
}
|
if (channel.permissionsFor(this.user!)?.has(Permissions.FLAGS.VIEW_CHANNEL)) {
|
||||||
});
|
access = 'ACCESS';
|
||||||
guildData[guild.name] = guildInfo;
|
} else {
|
||||||
|
access = 'NO_ACCESS';
|
||||||
|
}
|
||||||
|
|
||||||
|
guildInfo[categoryName].channels.push(`${channel.name} (${access} ${channel.type} ${channel.id})`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
guildData[guild.name] = guildInfo;
|
||||||
});
|
});
|
||||||
|
|
||||||
const filename = `output/${this.user?.tag} ${this.token.slice(-5)}.json`;
|
const filename = `output/${this.user?.tag} ${this.token.slice(-5)}.json`;
|
||||||
const jsonData = JSON.stringify(guildData, null, 2);
|
const jsonData = JSON.stringify(guildData, null, 2);
|
||||||
fs.writeFileSync(filename, jsonData);
|
fs.writeFileSync(filename, jsonData);
|
||||||
|
Loading…
Reference in New Issue
Block a user