From 030060164913ba072f692711f01c910bc5db4a72 Mon Sep 17 00:00:00 2001 From: Gus Caplan Date: Thu, 19 Jan 2017 11:11:24 -0600 Subject: [PATCH] remove redundant editing (#1116) * remove redundant editing * update docs --- src/client/rest/RESTMethods.js | 5 +++-- src/structures/Guild.js | 15 ++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/client/rest/RESTMethods.js b/src/client/rest/RESTMethods.js index 744136e9f..da1f2142b 100644 --- a/src/client/rest/RESTMethods.js +++ b/src/client/rest/RESTMethods.js @@ -323,8 +323,9 @@ class RESTMethods { ); } - createGuildRole(guild) { - return this.rest.makeRequest('post', Constants.Endpoints.guildRoles(guild.id), true).then(role => + createGuildRole(guild, data) { + if (data.color) data.color = this.client.resolver.resolveColor(data.color); + return this.rest.makeRequest('post', Constants.Endpoints.guildRoles(guild.id), true, data).then(role => this.client.actions.GuildRoleCreate.handle({ guild_id: guild.id, role, diff --git a/src/structures/Guild.js b/src/structures/Guild.js index dff0f610a..2a9c3d90d 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -608,7 +608,7 @@ class Guild { } /** - * Creates a new role in the guild, and optionally updates it with the given information. + * Creates a new role in the guild with given information * @param {RoleData} [data] The data to update the role with * @returns {Promise} * @example @@ -618,14 +618,15 @@ class Guild { * .catch(console.error); * @example * // create a new role with data - * guild.createRole({ name: 'Super Cool People' }) - * .then(role => console.log(`Created role ${role}`)) - * .catch(console.error) + * guild.createRole({ + * name: 'Super Cool People', + * color: 'BLUE', + * }) + * .then(role => console.log(`Created role ${role}`)) + * .catch(console.error) */ createRole(data) { - const create = this.client.rest.methods.createGuildRole(this); - if (!data) return create; - return create.then(role => role.edit(data)); + return this.client.rest.methods.createGuildRole(this, data); } /**