From 29bbd1df209f6a2ead2412a7b41b647505de95cd Mon Sep 17 00:00:00 2001 From: Elysia <71698422+aiko-chan-ai@users.noreply.github.com> Date: Wed, 10 May 2023 19:04:05 +0700 Subject: [PATCH] feat: friend invite --- src/structures/ClientUser.js | 40 +++++++++++++++++++++++++++--------- typings/index.d.ts | 4 +++- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/src/structures/ClientUser.js b/src/structures/ClientUser.js index 1ab2fa2..e00be1c 100644 --- a/src/structures/ClientUser.js +++ b/src/structures/ClientUser.js @@ -463,28 +463,48 @@ class ClientUser extends User { /** * Create an invite [Friend Invites] - * maxAge: 86400 | maxUses: 0 + * maxAge: 604800 | maxUses: 1 * @returns {Promise} * @see {@link https://github.com/13-05/hidden-disc-docs#js-snippet-for-creating-friend-invites} * @example * // Options not working - * client.user.getInvite(); + * client.user.createFriendInvite(); * .then(console.log) * .catch(console.error); */ - async getInvite() { + async createFriendInvite() { const data = await this.client.api.users['@me'].invites.post({ - data: { - validate: null, - max_age: 86400, - max_uses: 0, - target_type: 2, - temporary: false, - }, + data: {}, }); return new Invite(this.client, data); } + /** + * Get all friend invites + * @returns {Promise>} + */ + async getAllFriendInvites() { + const data = await this.client.api.users['@me'].invites.get(); + const collection = new Collection(); + for (const invite of data) { + collection.set(invite.code, new Invite(this.client, invite)); + } + return collection; + } + + /** + * Revoke all friend invites + * @returns {Promise>} + */ + async revokeAllFriendInvites() { + const data = await this.client.api.users['@me'].invites.delete(); + const collection = new Collection(); + for (const invite of data) { + collection.set(invite.code, new Invite(this.client, invite)); + } + return collection; + } + /** * Get a collection of messages mentioning clientUser * @param {number} [limit=25] Maximum number of messages to get diff --git a/typings/index.d.ts b/typings/index.d.ts index 8a601ec..928f747 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1064,7 +1064,9 @@ export class ClientUser extends User { public deleteAccount(password: string): Promise; public setDeaf(status: boolean): Promise; public setMute(status: boolean): Promise; - public getInvite(options?: CreateInviteOptions): Promise; + public createFriendInvite(): Promise; + public getAllFriendInvites(): Promise>; + public revokeAllFriendInvites(): Promise>; public setSamsungActivity(packageName: string, type?: 'START' | 'UPDATE' | 'STOP'): Promise; public getMentions( limit?: number,