Skip to content

Commit

Permalink
Update cache in createRole() (#604)
Browse files Browse the repository at this point in the history
For compatibility with role-related methods that depend on caching
  • Loading branch information
LJNeon authored and abalabahaha committed Jan 1, 2020
1 parent 9d377c9 commit f952ada
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/Client.js
Expand Up @@ -761,7 +761,14 @@ class Client extends EventEmitter {
*/
createRole(guildID, options, reason) {
options.reason = reason;
return this.requestHandler.request("POST", Endpoints.GUILD_ROLES(guildID), true, options).then((role) => new Role(role, this.guilds.get(guildID)));
return this.requestHandler.request("POST", Endpoints.GUILD_ROLES(guildID), true, options).then((role) => {
const guild = this.guilds.get(guildID);
if(guild) {
return guild.roles.add(role, guild);
} else {
return new Role(role);
}
});
}

/**
Expand Down

0 comments on commit f952ada

Please sign in to comment.