From 512287c8ac0a5a9f452508b718e64485871b0cc2 Mon Sep 17 00:00:00 2001 From: Shubham Parihar Date: Sun, 13 Jun 2021 22:31:44 +0530 Subject: [PATCH] fix: make prop check correct and fix sticker format --- src/structures/Guild.js | 6 +++--- src/structures/Sticker.js | 2 +- src/util/Constants.js | 2 +- typings/index.d.ts | 4 +++- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/structures/Guild.js b/src/structures/Guild.js index d523677bfbe7..5769bc49956b 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -832,7 +832,7 @@ class Guild extends BaseGuild { edit(data, reason) { const _data = {}; if (data.name) _data.name = data.name; - if (data.verificationLevel) { + if (typeof data.verificationLevel !== 'undefined') { _data.verification_level = typeof data.verificationLevel === 'number' ? data.verificationLevel @@ -850,13 +850,13 @@ class Guild extends BaseGuild { if (data.splash) _data.splash = data.splash; if (data.discoverySplash) _data.discovery_splash = data.discoverySplash; if (data.banner) _data.banner = data.banner; - if (data.explicitContentFilter) { + if (typeof data.explicitContentFilter !== 'undefined') { _data.explicit_content_filter = typeof data.explicitContentFilter === 'number' ? data.explicitContentFilter : ExplicitContentFilterLevels[data.explicitContentFilter]; } - if (data.defaultMessageNotifications) { + if (typeof data.defaultMessageNotifications !== 'undefined') { _data.default_message_notifications = typeof data.defaultMessageNotifications === 'number' ? data.defaultMessageNotifications diff --git a/src/structures/Sticker.js b/src/structures/Sticker.js index bac20e1dbe96..941e28cbb1d0 100644 --- a/src/structures/Sticker.js +++ b/src/structures/Sticker.js @@ -31,7 +31,7 @@ class Sticker extends Base { /** * The format of the sticker - * @type {StickerFormatTypes} + * @type {StickerFormatType} */ this.format = StickerFormatTypes[sticker.format_type]; diff --git a/src/util/Constants.js b/src/util/Constants.js index b1694810350c..47df7fb14d0b 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -736,7 +736,7 @@ exports.WebhookTypes = createEnum([null, 'Incoming', 'Channel Follower']); * * PNG * * APNG * * LOTTIE - * @typedef {string} StickerFormatTypes + * @typedef {string} StickerFormatType */ exports.StickerFormatTypes = createEnum([null, 'PNG', 'APNG', 'LOTTIE']); diff --git a/typings/index.d.ts b/typings/index.d.ts index ae2dad3d1a49..bed762f35f23 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -3719,7 +3719,7 @@ declare module 'discord.js' { public readonly createdTimestamp: number; public readonly createdAt: Date; public description: string; - public format: StickerFormatTypes; + public format: StickerFormatType; public id: Snowflake; public name: string; public packID: Snowflake; @@ -3727,6 +3727,8 @@ declare module 'discord.js' { public readonly url: string; } + type StickerFormatType = keyof typeof StickerFormatTypes; + type SystemChannelFlagsString = | 'SUPPRESS_JOIN_NOTIFICATIONS' | 'SUPPRESS_PREMIUM_SUBSCRIPTIONS'