Skip to content

Instantly share code, notes, and snippets.

@jumoog
Created December 28, 2023 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jumoog/82e432943de087bcf044f0995d4101e1 to your computer and use it in GitHub Desktop.
Save jumoog/82e432943de087bcf044f0995d4101e1 to your computer and use it in GitHub Desktop.
gain admin rights from a running bot that has admin rights
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