mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-01 20:46:08 +00:00
feat: fetch guild role
This commit is contained in:
parent
4f3d5548a9
commit
5b6cb6ece6
@ -34,6 +34,7 @@ import type {
|
||||
RESTGetAPIGuildPruneCountResult,
|
||||
RESTGetAPIGuildQuery,
|
||||
RESTGetAPIGuildResult,
|
||||
RESTGetAPIGuildRoleResult,
|
||||
RESTGetAPIGuildRolesResult,
|
||||
RESTGetAPIGuildScheduledEventQuery,
|
||||
RESTGetAPIGuildScheduledEventResult,
|
||||
@ -219,6 +220,7 @@ export interface GuildRoutes {
|
||||
(
|
||||
id: string,
|
||||
): {
|
||||
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildRoleResult>;
|
||||
patch(
|
||||
args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIGuildRoleJSONBody>,
|
||||
): Promise<RESTPatchAPIGuildRoleResult>;
|
||||
|
@ -21,6 +21,22 @@ export class RoleShorter extends BaseShorter {
|
||||
return Transformers.GuildRole(this.client, res, guildId);
|
||||
}
|
||||
|
||||
async fetch(guildId: string, roleId: string, force = false) {
|
||||
const role = await this.raw(guildId, roleId, force);
|
||||
return Transformers.GuildRole(this.client, role, guildId);
|
||||
}
|
||||
|
||||
async raw(guildId: string, roleId: string, force = false) {
|
||||
let role: APIRole | undefined;
|
||||
if (!force) {
|
||||
role = await this.client.cache.roles?.raw(roleId);
|
||||
if (role) return role;
|
||||
}
|
||||
role = await this.client.proxy.guilds(guildId).roles(roleId).get();
|
||||
await this.client.cache.roles?.set(roleId, guildId, role);
|
||||
return role;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a list of roles in the guild.
|
||||
* @param guildId The ID of the guild.
|
||||
|
@ -27,6 +27,10 @@ export class GuildRole extends DiscordBase {
|
||||
return this.client.guilds.fetch(this.guildId, force);
|
||||
}
|
||||
|
||||
fetch(force = false) {
|
||||
return this.client.roles.fetch(this.guildId, this.id, force);
|
||||
}
|
||||
|
||||
edit(body: RESTPatchAPIGuildRoleJSONBody, reason?: string) {
|
||||
return this.client.roles.create(this.guildId, body, reason);
|
||||
}
|
||||
|
@ -637,6 +637,11 @@ export interface RESTPostAPIGuildBulkBanResult {
|
||||
*/
|
||||
export type RESTGetAPIGuildRolesResult = APIRole[];
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/guild#get-guild-role
|
||||
*/
|
||||
export type RESTGetAPIGuildRoleResult = APIRole;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/resources/guild#create-guild-role
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user