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
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);
以及如何删除/停用权限?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.