mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 16:43:31 +01:00
Add createRole with data (#637)
This commit is contained in:
committed by
GitHub
parent
bfc9de438a
commit
e1bda864f7
@@ -357,16 +357,24 @@ class Guild {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new role in the guild, as of now this is just a blank role.
|
||||
* Creates a new role in the guild, and optionally updates it with the given information.
|
||||
* @param {RoleData} [data] The data to update the role with
|
||||
* @returns {Promise<Role>}
|
||||
* @example
|
||||
* // create a new role
|
||||
* guild.createRole()
|
||||
* .then(role => console.log(`Created role ${role}`))
|
||||
* .catch(console.log);
|
||||
* @example
|
||||
* // create a new role with data
|
||||
* guild.createRole({ name: 'Super Cool People' })
|
||||
* .then(role => console.log(`Created role ${role}`))
|
||||
* .catch(console.log)
|
||||
*/
|
||||
createRole() {
|
||||
return this.client.rest.methods.createGuildRole(this);
|
||||
createRole(data) {
|
||||
const create = this.client.rest.methods.createGuildRole(this);
|
||||
if (!data) return create;
|
||||
return create.then(role => role.edit(data));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user