Skip to content

Commit

Permalink
newLastChance edit option
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico105 committed Aug 7, 2021
1 parent c3cc70b commit cd49a75
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,10 @@ client.on('messageCreate', (message) => {
- **options.newPrize**: the new prize.
- **options.addTime**: the number of milliseconds to add to the giveaway duration.
- **options.setEndTimestamp**: the timestamp of the new end date (for example, for the giveaway to be ended in 1 hour, set it to `Date.now() + 60000`).
- **options.newMessages**: the new giveaway messages
- **options.newMessages**: the new giveaway messages. Will get merged with the existing object, if there.
- **options.newExtraData**: the new extra data value for the giveaway
- **options.newBonusEntries**: the new BonusEntry objects (for example, to change the amount of entries).
- **options.newLastChance**: the new options for the last chance system. Will get merged with the existing object, if there.

**Note**: to reduce giveaway time, define `addTime` with a negative number! For example `addTime: -5000` will reduce giveaway time by 5 seconds!

Expand Down
3 changes: 2 additions & 1 deletion src/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,11 @@ exports.GiveawayRerollOptions = {
* @property {string} [newPrize] The new giveaway prize.
* @property {number} [addTime] Number of milliseconds to add to the giveaway duration.
* @property {number} [setEndTimestamp] The timestamp of the new end date.
* @property {GiveawayMessages} [newMessages] The new giveaway messages.
* @property {GiveawayMessages} [newMessages] The new giveaway messages. Will get merged with the existing object, if there.
* @property {string} [newThumbnail] The new thumbnail url.
* @property {any} [newExtraData] The new extra data for this giveaway.
* @property {BonusEntry[]} [newBonusEntries] The new BonusEntry objects.
* @property {LastChanceOptions} [newLastChance] The new options for the last chance system. Will get merged with the existing object, if there.
*/
exports.GiveawayEditOptions = {};

Expand Down
1 change: 1 addition & 0 deletions src/Giveaway.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ class Giveaway extends EventEmitter {
if (typeof options.newThumbnail === 'string') this.thumbnail = options.newThumbnail;
if (Array.isArray(options.newBonusEntries)) this.options.bonusEntries = options.newBonusEntries.filter((elem) => typeof elem === 'object');
if (options.newExtraData) this.extraData = options.newExtraData;
if (options.newLastChance && typeof options.newLastChance === 'object') this.options.lastChance = merge(this.options.lastChance || {}, options.newLastChance);

await this.manager.editGiveaway(this.messageID, this.data);
if (this.remainingTime <= 0) this.manager.end(this.messageID).catch(() => {});
Expand Down
1 change: 1 addition & 0 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ declare module 'discord-giveaways' {
newThumbnail?: string;
newBonusEntries?: BonusEntry[];
newExtraData?: any;
newLastChance?: LastChanceOptions;
}
interface GiveawayRerollOptions {
winnerCount?: number;
Expand Down

0 comments on commit cd49a75

Please sign in to comment.