mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-04 22:16:08 +00:00
feat: final Guild endpoints
This commit is contained in:
parent
b4d5c236d8
commit
ea18fbc71d
@ -26,6 +26,14 @@ export interface CreateRole {
|
|||||||
mentionable?: boolean;
|
mentionable?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ModifyGuildRole {
|
||||||
|
name?: string;
|
||||||
|
color?: number;
|
||||||
|
hoist?: boolean;
|
||||||
|
mentionable?: boolean;
|
||||||
|
unicodeEmoji?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface CreateGuildEmoji {
|
export interface CreateGuildEmoji {
|
||||||
name: string;
|
name: string;
|
||||||
image: string;
|
image: string;
|
||||||
@ -138,7 +146,21 @@ export class Guild extends BaseGuild implements Model {
|
|||||||
await this.session.rest.runMethod<undefined>(this.session.rest, "DELETE", Routes.GUILD_ROLE(this.id, roleId));
|
await this.session.rest.runMethod<undefined>(this.session.rest, "DELETE", Routes.GUILD_ROLE(this.id, roleId));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: edit role
|
async editRole(roleId: Snowflake, options: ModifyGuildRole): Promise<Role> {
|
||||||
|
const role = await this.session.rest.runMethod<DiscordRole>(
|
||||||
|
this.session.rest,
|
||||||
|
"PATCH",
|
||||||
|
Routes.GUILD_ROLE(this.id, roleId),
|
||||||
|
{
|
||||||
|
name: options.name,
|
||||||
|
color: options.color,
|
||||||
|
hoist: options.hoist,
|
||||||
|
mentionable: options.mentionable,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return new Role(this.session, role, this.id);
|
||||||
|
}
|
||||||
|
|
||||||
async deleteInvite(inviteCode: string): Promise<void> {
|
async deleteInvite(inviteCode: string): Promise<void> {
|
||||||
await this.session.rest.runMethod<undefined>(
|
await this.session.rest.runMethod<undefined>(
|
||||||
@ -158,6 +180,16 @@ export class Guild extends BaseGuild implements Model {
|
|||||||
|
|
||||||
return new Invite(this.session, inviteMetadata);
|
return new Invite(this.session, inviteMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fetchInvites(): Promise<Invite[]> {
|
||||||
|
const invites = await this.session.rest.runMethod<DiscordInviteMetadata[]>(
|
||||||
|
this.session.rest,
|
||||||
|
"GET",
|
||||||
|
Routes.GUILD_INVITES(this.id),
|
||||||
|
);
|
||||||
|
|
||||||
|
return invites.map((invite) => new Invite(this.session, invite));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Guild;
|
export default Guild;
|
||||||
|
@ -4,7 +4,7 @@ import type { Session } from "../session/Session.ts";
|
|||||||
import { Snowflake } from "../util/Snowflake.ts";
|
import { Snowflake } from "../util/Snowflake.ts";
|
||||||
import { iconHashToBigInt } from "../util/hash.ts";
|
import { iconHashToBigInt } from "../util/hash.ts";
|
||||||
import Permissions from "./Permissions.ts";
|
import Permissions from "./Permissions.ts";
|
||||||
import Guild from "./Guild.ts";
|
import Guild, { ModifyGuildRole } from "./Guild.ts";
|
||||||
|
|
||||||
export class Role implements Model {
|
export class Role implements Model {
|
||||||
constructor(session: Session, data: DiscordRole, guildId: Snowflake) {
|
constructor(session: Session, data: DiscordRole, guildId: Snowflake) {
|
||||||
@ -52,6 +52,11 @@ export class Role implements Model {
|
|||||||
await Guild.prototype.deleteRole.call({ id: this.guildId, session: this.session }, this.id);
|
await Guild.prototype.deleteRole.call({ id: this.guildId, session: this.session }, this.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async edit(options: ModifyGuildRole) {
|
||||||
|
const role = await Guild.prototype.editRole.call({ id: this.guildId, session: this.session }, this.id, options);
|
||||||
|
return role;
|
||||||
|
}
|
||||||
|
|
||||||
toString() {
|
toString() {
|
||||||
switch (this.id) {
|
switch (this.id) {
|
||||||
case this.guildId:
|
case this.guildId:
|
||||||
|
@ -135,3 +135,7 @@ export function INVITE(inviteCode: string, options?: GetInvite) {
|
|||||||
|
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function GUILD_INVITES(guildId: Snowflake) {
|
||||||
|
return `/guilds/${guildId}/invites`;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user