Skip to content

Commit

Permalink
change unPauseAfter to unpauseAfter (#438)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico105 authored Jul 24, 2022
1 parent 2ef9a6b commit 7015e39
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down Expand Up @@ -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`'
}
Expand All @@ -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).

<a href="https://zupimages.net/viewer.php?id=21/24/dxhk.png">
Expand Down
6 changes: 3 additions & 3 deletions src/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.<br>⚠ 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`'
Expand Down
16 changes: 8 additions & 8 deletions src/Giveaway.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions src/Manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -541,16 +541,16 @@ 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;
giveaway.endAt = Infinity;
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(() => {});
}
Expand Down
2 changes: 1 addition & 1 deletion typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7015e39

Please sign in to comment.