0
votes

I want to make a command to change the permissions of a certain role so it has admin.

I've tried:

if(message.content.toString() == '!admin') {
    var role = '649795089606115329';
    role.edit({permissions: 'ADMINISTRATOR'})
}

and I got the error:

TypeError: role.edit is not a function

Not sure how else to go about this

1

1 Answers

0
votes

The main problem is that you haven't got the role, to do this you need to do the following

const theguild = client.guilds.get("The_server_id");
let therole = theguild.roles.get("The_role_id");

This gets the role object so you can use the methods (functions)

You may also want to look into the role.setPermissions() method to change the permissions instead of role.edit()

so you will want something like this

const server = client.guilds.get("The_server_id");
const role = server.roles.get("649795089606115329");

role.setPermissions(["ADMINISTRATOR"])
  .then(updated => console.log("Updated permissions to " + updated.permissions.bitfield))
  .catch(console.error);