fix: send friend req

This commit is contained in:
Elysia 2023-06-18 10:00:24 +07:00
parent 0abc2f23e2
commit f9405a33c0
2 changed files with 3 additions and 3 deletions

View File

@ -159,14 +159,14 @@ class RelationshipManager {
/** /**
* Sends a friend request. * Sends a friend request.
* @param {string} username Username of the user to send the request to * @param {string} username Username of the user to send the request to
* @param {number} discriminator Discriminator of the user to send the request to * @param {?number} discriminator Discriminator of the user to send the request to
* @returns {Promise<boolean>} * @returns {Promise<boolean>}
*/ */
async sendFriendRequest(username, discriminator) { async sendFriendRequest(username, discriminator) {
await this.client.api.users('@me').relationships.post({ await this.client.api.users('@me').relationships.post({
data: { data: {
username, username,
discriminator: parseInt(discriminator), discriminator: discriminator == 0 ? null : parseInt(discriminator),
}, },
headers: { headers: {
'X-Context-Properties': Buffer.from(JSON.stringify({ location: 'Add Friend' }), 'utf8').toString('base64'), 'X-Context-Properties': Buffer.from(JSON.stringify({ location: 'Add Friend' }), 'utf8').toString('base64'),

2
typings/index.d.ts vendored
View File

@ -4410,7 +4410,7 @@ export class RelationshipManager {
public fetch(user: UserResolvable, options?: BaseFetchOptions): Promise<RelationshipTypes>; public fetch(user: UserResolvable, options?: BaseFetchOptions): Promise<RelationshipTypes>;
public deleteFriend(user: UserResolvable): Promise<boolean>; public deleteFriend(user: UserResolvable): Promise<boolean>;
public deleteBlocked(user: UserResolvable): Promise<boolean>; public deleteBlocked(user: UserResolvable): Promise<boolean>;
public sendFriendRequest(username: string, discriminator: number): Promise<boolean>; public sendFriendRequest(username: string, discriminator?: number): Promise<boolean>;
public cancelFriendRequest(user: UserResolvable): Promise<boolean>; public cancelFriendRequest(user: UserResolvable): Promise<boolean>;
public addFriend(user: UserResolvable): Promise<boolean>; public addFriend(user: UserResolvable): Promise<boolean>;
public addBlocked(user: UserResolvable): Promise<boolean>; public addBlocked(user: UserResolvable): Promise<boolean>;