diff --git a/package.json b/package.json index b34f2cc9..c914a83b 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "@vladfrangu/async_event_emitter": "^2.4.7", "json-with-bigint": "^3.4.4", "solid-js": "^1.9.14", - "stoat-api": "0.15.3", + "stoat-api": "0.16.0", "ulid": "^3.0.2" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8f9b0197..40904017 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -24,8 +24,8 @@ importers: specifier: ^1.9.14 version: 1.9.14 stoat-api: - specifier: 0.15.3 - version: 0.15.3 + specifier: 0.16.0 + version: 0.16.0 ulid: specifier: ^3.0.2 version: 3.0.2 @@ -832,8 +832,8 @@ packages: solid-js@1.9.14: resolution: {integrity: sha512-sAEXC0Kk0S1EDg+8ysEWJDbYhA3RRoEjwuySUGlKIemeo0I5YZfOyumNjNs9Sv3y2nmhD+0rW66ag2HsMuQiGQ==} - stoat-api@0.15.3: - resolution: {integrity: sha512-r08FplgeZWft4Hd2CK1tZ7EEzhocUyy/aeeOGBrKC6vy3ANsDhcMzGdJioYQ3jpzH+jFIPLQJzBaJK27Wf3Vug==} + stoat-api@0.16.0: + resolution: {integrity: sha512-HC5+UluvnmCPYacuJh3LUh6Lpfe0gLVpoEjRBpt4BzZUPlA7Pe5inuvEYo/a1MLwTmVpzxF4S9D+QFIADHroTg==} strip-json-comments@3.1.1: resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==} @@ -1685,7 +1685,7 @@ snapshots: seroval: 1.5.6 seroval-plugins: 1.5.6(seroval@1.5.6) - stoat-api@0.15.3: + stoat-api@0.16.0: dependencies: json-with-bigint: 3.4.4 diff --git a/src/classes/Channel.ts b/src/classes/Channel.ts index f7cc1d26..13bde778 100644 --- a/src/classes/Channel.ts +++ b/src/classes/Channel.ts @@ -7,6 +7,7 @@ import type { Member as APIMember, Message as APIMessage, User as APIUser, + DataCreateInvite, DataEditChannel, DataMessageSearch, DataMessageSend, @@ -709,12 +710,14 @@ export class Channel { /** * Create an invite to the channel + * @param data Invite options * @requires `TextChannel` * @returns Newly created invite code */ - async createInvite(): Promise { + async createInvite(data: DataCreateInvite = {}): Promise { return await this.#collection.client.api.post( `/channels/${this.id as ""}/invites`, + data, ); } diff --git a/src/classes/Invite.ts b/src/classes/Invite.ts index 4e579348..8f4f2103 100644 --- a/src/classes/Invite.ts +++ b/src/classes/Invite.ts @@ -52,6 +52,9 @@ export class ServerInvite extends ChannelInvite { readonly creatorId: string; readonly serverId: string; readonly channelId: string; + readonly uses?: number; + readonly maxUses?: number; + readonly expires?: Date; /** * Construct Server Invite @@ -65,6 +68,10 @@ export class ServerInvite extends ChannelInvite { this.creatorId = invite.creator; this.serverId = invite.server; this.channelId = invite.channel; + + this.uses = invite.uses; + this.maxUses = invite.max_uses ?? undefined; + this.expires = invite.expires ? new Date(invite.expires) : undefined; } /** diff --git a/src/classes/Server.ts b/src/classes/Server.ts index ca48bb9e..2fca20f3 100644 --- a/src/classes/Server.ts +++ b/src/classes/Server.ts @@ -457,12 +457,13 @@ export class Server { this.id, hydrate( "server", - await this.#collection.client.api.patch( + // Cast as APIServer because TypeScript matches both /roles/ranks and /roles/${role_id} in stoat-api routes + (await this.#collection.client.api.patch( `/servers/${this.id as ""}/roles/ranks`, { ranks: roleIds, }, - ), + )) as APIServer, this.#collection.client, false, ),