53 lines
2.1 KiB
JavaScript
53 lines
2.1 KiB
JavaScript
require('dotenv').config();
|
|
const { Client, GatewayIntentBits } = require('discord.js');
|
|
|
|
async function checkServerAccess() {
|
|
const client = new Client({
|
|
intents: [
|
|
GatewayIntentBits.Guilds,
|
|
GatewayIntentBits.GuildMessages,
|
|
GatewayIntentBits.MessageContent,
|
|
],
|
|
});
|
|
|
|
try {
|
|
await client.login(process.env.BOT_TOKEN);
|
|
console.log('\nBot Information:');
|
|
console.log(`Bot Name: ${client.user.tag}`);
|
|
|
|
// List all servers the bot is in
|
|
console.log('\nServers the bot is in:');
|
|
client.guilds.cache.forEach(guild => {
|
|
console.log(`- ${guild.name} (ID: ${guild.id})`);
|
|
|
|
// Check if the notification channel is in this server
|
|
const channel = guild.channels.cache.get(process.env.NOTIFICATION_CHANNEL_ID);
|
|
if (channel) {
|
|
console.log(` ✅ Found notification channel: #${channel.name}`);
|
|
|
|
// Check bot's permissions in this channel
|
|
const botMember = guild.members.cache.get(client.user.id);
|
|
const permissions = channel.permissionsFor(botMember);
|
|
|
|
console.log('\nPermissions in notification channel:');
|
|
console.log(` View Channel: ${permissions.has('ViewChannel') ? '✅' : '❌'}`);
|
|
console.log(` Send Messages: ${permissions.has('SendMessages') ? '✅' : '❌'}`);
|
|
console.log(` Embed Links: ${permissions.has('EmbedLinks') ? '✅' : '❌'}`);
|
|
}
|
|
});
|
|
|
|
// If notification channel wasn't found
|
|
if (!client.guilds.cache.some(guild =>
|
|
guild.channels.cache.has(process.env.NOTIFICATION_CHANNEL_ID))) {
|
|
console.log('\n❌ Notification channel not found in any server!');
|
|
console.log('Channel ID:', process.env.NOTIFICATION_CHANNEL_ID);
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('Error:', error);
|
|
} finally {
|
|
client.destroy();
|
|
}
|
|
}
|
|
|
|
checkServerAccess().catch(console.error); |