From 4be5656f3d433c87eff0d22ea008429c425f7311 Mon Sep 17 00:00:00 2001 From: March 7th <71698422+aiko-chan-ai@users.noreply.github.com> Date: Mon, 1 Aug 2022 12:31:18 +0700 Subject: [PATCH] fix(ClientUser): Method (require nitro) not work --- docs/logo.svg | 19 +++++++++++++++++++ src/structures/ClientUser.js | 13 +++++++------ src/structures/interfaces/TextBasedChannel.js | 9 +++++++++ src/util/Constants.js | 12 ++++++++++-- typings/enums.d.ts | 3 ++- typings/index.d.ts | 4 ++-- 6 files changed, 49 insertions(+), 11 deletions(-) create mode 100644 docs/logo.svg diff --git a/docs/logo.svg b/docs/logo.svg new file mode 100644 index 00000000..81feb17 --- /dev/null +++ b/docs/logo.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/structures/ClientUser.js b/src/structures/ClientUser.js index 34d7469..6c93c0f 100644 --- a/src/structures/ClientUser.js +++ b/src/structures/ClientUser.js @@ -5,7 +5,7 @@ const Invite = require('./Invite'); const { Message } = require('./Message'); const User = require('./User'); const { Util } = require('..'); -const { HypeSquadOptions, Opcodes, NitroType } = require('../util/Constants'); +const { Opcodes, NitroType, HypeSquadType } = require('../util/Constants'); const DataResolver = require('../util/DataResolver'); const PurchasedFlags = require('../util/PurchasedFlags'); /** @@ -43,7 +43,7 @@ class ClientUser extends User { * Nitro type of the client user. * @type {NitroType} */ - this.nitroType = nitro ?? `UNKNOWN`; + this.nitroType = nitro ?? `UNKNOWN_${data.premium_type}`; } if ('purchased_flags' in data) { /** @@ -172,7 +172,7 @@ class ClientUser extends User { * .catch(console.error); */ setBanner(banner) { - if (this.nitroType !== 2) { + if (this.nitroType !== 'NITRO_BOOST') { throw new Error('You must be a Nitro Boosted User to change your banner.'); } return this.edit({ banner }); @@ -180,7 +180,7 @@ class ClientUser extends User { /** * Set HyperSquad House - * @param {HypeSquadOptions} type + * @param {HypeSquadType} type * * `LEAVE`: 0 * * `HOUSE_BRAVERY`: 1 * * `HOUSE_BRILLIANCE`: 2 @@ -193,7 +193,7 @@ class ClientUser extends User { * client.user.setHypeSquad(0); */ async setHypeSquad(type) { - const id = typeof type === 'string' ? HypeSquadOptions[type] : type; + const id = typeof type === 'string' ? HypeSquadType[type] : type; if (!id && id !== 0) throw new Error('Invalid HypeSquad type.'); if (id !== 0) { const data = await this.client.api.hypesquad.online.post({ @@ -222,7 +222,8 @@ class ClientUser extends User { * @returns {Promise} */ setDiscriminator(discriminator, password) { - if (!this.nitro) throw new Error('You must be a Nitro User to change your discriminator.'); + if (this.nitroType == 'NONE') + throw new Error('You must be a Nitro User to change your discriminator.'); if (!password && !this.client.password) { throw new Error('A password is required to change a discriminator.'); } diff --git a/src/structures/interfaces/TextBasedChannel.js b/src/structures/interfaces/TextBasedChannel.js index 650a4ed..0d3c44d 100644 --- a/src/structures/interfaces/TextBasedChannel.js +++ b/src/structures/interfaces/TextBasedChannel.js @@ -398,6 +398,15 @@ class TextBasedChannel { * @param {string} commandName Command name * @param {...?string|string[]} args Command arguments * @returns {Promise} + * @example + * // Send Slash to this channel + * // Demo: + * // + BotID: "123456789012345678" + * // + CommandName: "embed" + * // + Args: "title", "description", "author", 'color' (Optional) + * channel.sendSlash('123456789012345678', 'embed', 'title', 'description', 'author', '#00ff00') + * // Send embed with Title and Color: + * channel.sendSlash('123456789012345678', 'embed', 'title', undefined, undefined, '#00ff00') */ async sendSlash(botId, commandName, ...args) { args = args.flat(2); diff --git a/src/util/Constants.js b/src/util/Constants.js index cdafa15..c968eb0 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -59,6 +59,16 @@ exports.stickerAnimationMode = createEnum(['ALWAYS', 'INTERACTION', 'NEVER']); */ exports.NitroType = createEnum(['NONE', 'NITRO_CLASSIC', 'NITRO_BOOST']); +/** + * All available HypeSquad types: + * * `LEAVE` - None + * * `HOUSE_BRAVERY` - HypeSquad Bravery + * * `HOUSE_BRILLIANCE` - HypeSquad Brilliance + * * `HOUSE_BALANCE` - HypeSquad Balance + * @typedef {string} HypeSquadType + */ +exports.HypeSquadType = createEnum(['LEAVE', 'HOUSE_BRAVERY', 'HOUSE_BRILLIANCE', 'HOUSE_BALANCE']); + exports.localeObject = { da: 'DANISH', de: 'GERMAN', @@ -1584,8 +1594,6 @@ exports.GuildScheduledEventEntityTypes = createEnum([null, 'STAGE_INSTANCE', 'VO */ exports.VideoQualityModes = createEnum([null, 'AUTO', 'FULL']); -exports.HypeSquadOptions = createEnum(['LEAVE', 'HOUSE_BRAVERY', 'HOUSE_BRILLIANCE', 'HOUSE_BALANCE']); - exports._cleanupSymbol = Symbol('djsCleanup'); function keyMirror(arr) { diff --git a/typings/enums.d.ts b/typings/enums.d.ts index 75c6be0..f5e20b4 100644 --- a/typings/enums.d.ts +++ b/typings/enums.d.ts @@ -166,7 +166,8 @@ export const enum GuildScheduledEventStatuses { CANCELED = 4, } -export const enum HypeSquadOptions { +export const enum HypeSquadType { + LEAVE = 0, HOUSE_BRAVERY = 1, HOUSE_BRILLIANCE = 2, HOUSE_BALANCE = 3, diff --git a/typings/index.d.ts b/typings/index.d.ts index ae5edcd..d0f026a 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -98,7 +98,7 @@ import { GuildScheduledEventEntityTypes, GuildScheduledEventStatuses, GuildScheduledEventPrivacyLevels, - HypeSquadOptions, + HypeSquadType, VideoQualityModes, } from './enums'; import { @@ -896,7 +896,7 @@ export class ClientUser extends User { public setPresence(data: PresenceData): ClientPresence; public setStatus(status: PresenceStatusData, shardId?: number | number[]): ClientPresence; public setUsername(username: string, password: string): Promise; - public setHypeSquad(type: HypeSquadOptions): Promise; + public setHypeSquad(type: HypeSquadType): Promise; public setAccentColor(color: ColorResolvable): Promise; public setDiscriminator(discriminator: string, password: string): Promise; public setAboutMe(bio: string): Promise;