Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2338,6 +2338,7 @@ declare namespace Eris {
getRESTGuildMembers(guildID: string, options?: GetRESTGuildMembersOptions): Promise<Member[]>;
/** @deprecated */
getRESTGuildMembers(guildID: string, limit?: number, after?: string): Promise<Member[]>;
getRESTGuildRole(guildID: string, roleID: string): Promise<Role>;
getRESTGuildRoles(guildID: string): Promise<Role[]>;
getRESTGuilds(options?: GetRESTGuildsOptions): Promise<Guild[]>;
/** @deprecated */
Expand Down Expand Up @@ -2703,6 +2704,7 @@ declare namespace Eris {
getRESTMembers(options?: GetRESTGuildMembersOptions): Promise<Member[]>;
/** @deprecated */
getRESTMembers(limit?: number, after?: string): Promise<Member[]>;
getRESTRole(roleID: string): Promise<Role>;
getRESTRoles(): Promise<Role[]>;
getRESTScheduledEvent(eventID: string): Promise<GuildScheduledEvent>;
getRESTSticker(stickerID: string): Promise<Sticker>;
Expand Down
13 changes: 13 additions & 0 deletions lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -3244,6 +3244,19 @@ class Client extends EventEmitter {
return this.requestHandler.request("GET", Endpoints.GUILD_MEMBERS(guildID), true, options).then((members) => members.map((member) => new Member(member, this.guilds.get(guildID), this)));
}

/**
* Get a guild role via the REST API. REST mode is required to use this endpoint.
* @arg {String} guildID The ID of the guild
* @arg {String} roleID The ID of the role
* @returns {Promise<Role>}
*/
getRESTGuildRole(guildID, roleID) {
if (!this.options.restMode) {
return Promise.reject(new Error("Eris REST mode is not enabled"));
}
return this.requestHandler.request("GET", Endpoints.GUILD_ROLE(guildID, roleID), true).then((role) => new Role(role, { shard: { client: this } }));
}

/**
* Get a guild's roles via the REST API. REST mode is required to use this endpoint.
* @arg {String} guildID The ID of the guild
Expand Down
9 changes: 9 additions & 0 deletions lib/structures/Guild.js
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,15 @@ class Guild extends Base {
return this._client.getRESTGuildMembers.call(this._client, this.id, options, after);
}

/**
* Get a guild's roles via the REST API. REST mode is required to use this endpoint.
* @arg {String} roleID The ID of the role
* @returns {Promise<Role>}
*/
getRESTRole(roleID) {
return this._client.getRESTGuildRole.call(this._client, this.id, roleID);
}

/**
* Get a guild's roles via the REST API. REST mode is required to use this endpoint.
* @returns {Promise<Array<Role>>}
Expand Down
2 changes: 1 addition & 1 deletion lib/structures/Role.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const Permission = require("./Permission");
class Role extends Base {
constructor(data, guild) {
super(data.id);
this.guild = guild;
this.guild = guild; // REVIEW Should really consider changing this to client
this.update(data);
}

Expand Down