forked from alexandreteles/jmusicbot-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckPerms.js
41 lines (31 loc) · 1.17 KB
/
checkPerms.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const { Client, GatewayIntentBits, PermissionsBitField } = require('discord.js');
require('dotenv').config();
const BOT_TOKEN = process.env.BOT_TOKEN;
const SERVER_ID = '904546782426570792';
async function checkPermissions() {
const client = new Client({
intents: [GatewayIntentBits.Guilds]
});
try {
await client.login(BOT_TOKEN);
const guild = await client.guilds.fetch(SERVER_ID);
if (!guild) {
console.log('Bot is not in that server or server ID is invalid.');
return;
}
const botMember = await guild.members.fetch(client.user.id);
const permissions = botMember.permissions;
console.log(`\nBot Permissions for ${client.user.tag} in ${guild.name}:`);
console.log('----------------------------------------');
const permissionsList = new PermissionsBitField(permissions.bitfield)
.toArray();
permissionsList.forEach(perm => {
console.log(`• ${perm}`);
});
} catch (error) {
console.error('Error:', error.message);
} finally {
client.destroy();
}
}
checkPermissions();