feat: setUsername with password

This commit is contained in:
Elysia 2024-01-15 18:08:11 +07:00
parent 7a8198841f
commit deab0d3440
2 changed files with 5 additions and 4 deletions

View File

@ -147,15 +147,16 @@ class ClientUser extends User {
* <info>Changing usernames in Discord is heavily rate limited, with only 2 requests * <info>Changing usernames in Discord is heavily rate limited, with only 2 requests
* every hour. Use this sparingly!</info> * every hour. Use this sparingly!</info>
* @param {string} username The new username * @param {string} username The new username
* @param {string} password Current Password
* @returns {Promise<ClientUser>} * @returns {Promise<ClientUser>}
* @example * @example
* // Set username * // Set username
* client.user.setUsername('discordjs') * client.user.setUsername('discordjs', 'passw@rd')
* .then(user => console.log(`My new username is ${user.username}`)) * .then(user => console.log(`My new username is ${user.username}`))
* .catch(console.error); * .catch(console.error);
*/ */
setUsername(username) { setUsername(username, password) {
return this.edit({ username }); return this.edit({ username, password });
} }
/** /**

2
typings/index.d.ts vendored
View File

@ -860,7 +860,7 @@ export class ClientUser extends User {
public setAvatar(avatar: BufferResolvable | Base64Resolvable | null): Promise<this>; public setAvatar(avatar: BufferResolvable | Base64Resolvable | null): Promise<this>;
public setPresence(data: PresenceData): ClientPresence; public setPresence(data: PresenceData): ClientPresence;
public setStatus(status: PresenceStatusData, shardId?: number | number[]): ClientPresence; public setStatus(status: PresenceStatusData, shardId?: number | number[]): ClientPresence;
public setUsername(username: string): Promise<this>; public setUsername(username: string, password: string): Promise<this>;
public purchasedFlags: PurchasedFlags; public purchasedFlags: PurchasedFlags;
public premiumUsageFlags: PremiumUsageFlags; public premiumUsageFlags: PremiumUsageFlags;
public phone: string | null; public phone: string | null;