Created
December 28, 2023 11:39
-
-
Save jumoog/82e432943de087bcf044f0995d4101e1 to your computer and use it in GitHub Desktop.
gain admin rights from a running bot that has admin rights
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Client, GatewayIntentBits } from 'discord.js'; | |
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages] }); | |
client.on('ready', async () => { | |
// Replace 'YOUR_GUILD_ID' with your actual guild ID | |
const guildId = 'YOUR_GUILD_ID'; | |
// Replace 'YOUR_ROLE_ID' with your actual role ID | |
const roleId = 'YOUR_ROLE_ID'; | |
try { | |
// Fetch the guild | |
const guild = await client.guilds.fetch(guildId); | |
// Fetch the role | |
const role = await guild.roles.fetch(roleId); | |
// get current permissions | |
const currentPermissions = role?.permissions.toArray(); | |
// add Administrator | |
currentPermissions?.push('Administrator'); | |
// Update the role permissions | |
await role?.setPermissions(currentPermissions!); | |
console.log(`Admin rights added to the role ${role?.name}`); | |
} catch (error) { | |
console.error('Error updating role permissions:', error); | |
} | |
}); | |
// Replace 'TOKEN' with your actual discord token | |
client.login("TOKEN"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment