diff --git a/README.md b/README.md index 3e0df5ca..bdba3237 100644 --- a/README.md +++ b/README.md @@ -243,9 +243,9 @@ client.on('interactionCreate', (interaction) => { ``` - **options.content**: the text of the embed when the giveaway is paused. You can [access giveaway properties](https://github.com/Androz2091/discord-giveaways#access-giveaway-properties-in-messages). -- **options.unPauseAfter**: the number of milliseconds after which the giveaway will automatically unpause. +- **options.unpauseAfter**: the number of milliseconds, or a timestamp in milliseconds, after which the giveaway will automatically unpause. - **options.embedColor**: the color of the embed when the giveaway is paused. -- **options.infiniteDurationText**: The text that gets displayed next to `GiveawayMessages#drawing` in the paused embed, when there is no `unPauseAfter`. +- **options.infiniteDurationText**: The text that gets displayed next to `GiveawayMessages#drawing` in the paused embed, when there is no `unpauseAfter`. ^^^ You can [access giveaway properties](https://github.com/Androz2091/discord-giveaways#access-giveaway-properties-in-messages). ⚠️ **Note**: the pause function overwrites/edits the [pauseOptions object property](https://github.com/Androz2091/discord-giveaways#pause-options) of a giveaway! @@ -361,7 +361,7 @@ client.giveawaysManager.start(interaction.channel, { pauseOptions: { isPaused: true, content: '⚠️ **THIS GIVEAWAY IS PAUSED !** ⚠️', - unPauseAfter: null, + unpauseAfter: null, embedColor: '#FFFF00', infiniteDurationText: '`NEVER`' } @@ -371,9 +371,9 @@ client.giveawaysManager.start(interaction.channel, { - **pauseOptions.isPaused**: if the giveaway is paused. - **pauseOptions.content**: the text of the embed when the giveaway is paused. ^^^ You can [access giveaway properties](https://github.com/Androz2091/discord-giveaways#access-giveaway-properties-in-messages). -- **pauseOptions.unPauseAfter**: the number of milliseconds, or a timestamp in milliseconds, after which the giveaway will automatically unpause. +- **pauseOptions.unpauseAfter**: the number of milliseconds, or a timestamp in milliseconds, after which the giveaway will automatically unpause. - **pauseOptions.embedColor**: the color of the embed when the giveaway is paused. -- **pauseOptions.infiniteDurationText**: The text that gets displayed next to `GiveawayMessages#drawing` in the paused embed, when there is no `unPauseAfter`. +- **pauseOptions.infiniteDurationText**: The text that gets displayed next to `GiveawayMessages#drawing` in the paused embed, when there is no `unpauseAfter`. ^^^ You can [access giveaway properties](https://github.com/Androz2091/discord-giveaways#access-giveaway-properties-in-messages). diff --git a/src/Constants.js b/src/Constants.js index ffc53c2b..50247009 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -124,15 +124,15 @@ exports.LastChanceOptions = { * * @property {boolean} [isPaused=false] If the giveaway is paused. * @property {string} [content='⚠️ **THIS GIVEAWAY IS PAUSED !** ⚠️'] The text of the embed when the giveaway is paused. - * @property {number} [unPauseAfter=null] The number of milliseconds, or a timestamp in milliseconds, after which the giveaway will automatically unpause. + * @property {number} [unpauseAfter=null] The number of milliseconds, or a timestamp in milliseconds, after which the giveaway will automatically unpause. * @property {Discord.ColorResolvable} [embedColor='#FFFF00'] The color of the embed when the giveaway is paused. * @private @property {number} [durationAfterPause=null|giveaway.remainingTime] The remaining duration after the giveaway is unpaused.
⚠ This property gets set by the manager so that the pause system works properly. It is not recommended to set it manually! - * @property {string} [infiniteDurationText='`NEVER`'] The text that gets displayed next to "GiveawayMessages#drawing" in the paused embed, when there is no "unPauseAfter". + * @property {string} [infiniteDurationText='`NEVER`'] The text that gets displayed next to "GiveawayMessages#drawing" in the paused embed, when there is no "unpauseAfter". */ exports.PauseOptions = { isPaused: false, content: '⚠️ **THIS GIVEAWAY IS PAUSED !** ⚠️', - unPauseAfter: null, + unpauseAfter: null, embedColor: '#FFFF00', durationAfterPause: null, infiniteDurationText: '`NEVER`' diff --git a/src/Giveaway.js b/src/Giveaway.js index 6b2419c2..ae1f654b 100644 --- a/src/Giveaway.js +++ b/src/Giveaway.js @@ -1048,16 +1048,16 @@ class Giveaway extends EventEmitter { // Update data const pauseOptions = this.options.pauseOptions || {}; if (typeof options.content === 'string') pauseOptions.content = options.content; - if (Number.isFinite(options.unPauseAfter)) { - if (options.unPauseAfter < Date.now()) { - pauseOptions.unPauseAfter = Date.now() + options.unPauseAfter; - this.endAt = this.endAt + options.unPauseAfter; + if (Number.isFinite(options.unpauseAfter)) { + if (options.unpauseAfter < Date.now()) { + pauseOptions.unpauseAfter = Date.now() + options.unpauseAfter; + this.endAt = this.endAt + options.unpauseAfter; } else { - pauseOptions.unPauseAfter = options.unPauseAfter; - this.endAt = this.endAt + options.unPauseAfter - Date.now(); + pauseOptions.unpauseAfter = options.unpauseAfter; + this.endAt = this.endAt + options.unpauseAfter - Date.now(); } } else { - delete pauseOptions.unPauseAfter; + delete pauseOptions.unpauseAfter; pauseOptions.durationAfterPause = this.remainingTime; this.endAt = Infinity; } @@ -1101,7 +1101,7 @@ class Giveaway extends EventEmitter { if (Number.isFinite(this.pauseOptions.durationAfterPause)) { this.endAt = Date.now() + this.pauseOptions.durationAfterPause; } - delete this.options.pauseOptions.unPauseAfter; + delete this.options.pauseOptions.unpauseAfter; this.options.pauseOptions.isPaused = false; this.ensureEndTimeout(); diff --git a/src/Manager.js b/src/Manager.js index ecc43c57..5fc6bee9 100644 --- a/src/Manager.js +++ b/src/Manager.js @@ -541,7 +541,7 @@ class GiveawaysManager extends EventEmitter { // Third case: the giveaway is paused and we should check whether it should be unpaused if (giveaway.pauseOptions.isPaused) { if ( - !Number.isFinite(giveaway.pauseOptions.unPauseAfter) && + !Number.isFinite(giveaway.pauseOptions.unpauseAfter) && !Number.isFinite(giveaway.pauseOptions.durationAfterPause) ) { giveaway.options.pauseOptions.durationAfterPause = giveaway.remainingTime; @@ -549,8 +549,8 @@ class GiveawaysManager extends EventEmitter { await this.editGiveaway(giveaway.messageId, giveaway.data); } if ( - Number.isFinite(giveaway.pauseOptions.unPauseAfter) && - Date.now() > giveaway.pauseOptions.unPauseAfter + Number.isFinite(giveaway.pauseOptions.unpauseAfter) && + Date.now() > giveaway.pauseOptions.unpauseAfter ) { return this.unpause(giveaway.messageId).catch(() => {}); } diff --git a/typings/index.d.ts b/typings/index.d.ts index 28bfec62..0fa0f3f2 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -85,7 +85,7 @@ export interface LastChanceOptions { export interface PauseOptions { isPaused?: boolean; content?: string; - unPauseAfter?: number | null; + unpauseAfter?: number | null; embedColor?: ColorResolvable; durationAfterPause?: number | null; infiniteDurationText?: string;