Leave HypeSquad

This commit is contained in:
March 7th 2022-04-05 19:11:27 +07:00
parent 26d9e4cbb9
commit cddbe4f9bb
2 changed files with 7 additions and 3 deletions

View File

@ -142,6 +142,7 @@ class ClientUser extends User {
/**
* Set HyperSquad House
* @param {HypeSquadOptions<Number|String>} type
* `LEAVE`: 0
* `HOUSE_BRAVERY`: 1
* `HOUSE_BRILLIANCE`: 2
* `HOUSE_BALANCE`: 3
@ -149,13 +150,16 @@ class ClientUser extends User {
* @example
* // Set HyperSquad HOUSE_BRAVERY
* client.user.setHypeSquad(1); || client.user.setHypeSquad('HOUSE_BRAVERY');
* // Leave
* client.user.setHypeSquad(0);
*/
async setHypeSquad(type) {
const id = typeof type === 'string' ? HypeSquadOptions[type] : type;
if (!id) throw new Error('Invalid HypeSquad type.');
return await this.client.api.hypesquad.online.post({
if (!id && id !== 0) throw new Error('Invalid HypeSquad type.');
if (id !== 0) return await this.client.api.hypesquad.online.post({
data: { house_id: id },
});
else return await this.client.api.hypesquad.online.delete();
}
/**

View File

@ -1327,7 +1327,7 @@ exports.GuildScheduledEventStatuses = createEnum([null, 'SCHEDULED', 'ACTIVE', '
*/
exports.GuildScheduledEventEntityTypes = createEnum([null, 'STAGE_INSTANCE', 'VOICE', 'EXTERNAL']);
/* eslint-enable max-len */
exports.HypeSquadOptions = createEnum([null, 'HOUSE_BRAVERY', 'HOUSE_BRILLIANCE', 'HOUSE_BALANCE']);
exports.HypeSquadOptions = createEnum(['LEAVE', 'HOUSE_BRAVERY', 'HOUSE_BRILLIANCE', 'HOUSE_BALANCE']);
exports._cleanupSymbol = Symbol('djsCleanup');