diff --git a/src/Constants.js b/src/Constants.js index 95934eff..f6224a2d 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -157,7 +157,7 @@ exports.GiveawaysManagerOptions = { * The reroll method options. * @typedef GiveawayRerollOptions * - * @property {number} [winnerCount=this.winnerCount] The number of winners to pick. + * @property {number} [winnerCount=giveaway.winnerCount] The number of winners to pick. * @property {Object} [messages] The messages used in this method. * @property {string} [messages.congrat=':tada: New winner(s): {winners}! Congratulations, you won **{prize}**!\n{messageURL}'] The message used if there are new winners. * @property {string} [messages.error='No valid participations, no new winner(s) can be chosen!'] The message used if no new winner(s) could be chosen. diff --git a/src/Giveaway.js b/src/Giveaway.js index dbdd4b23..94bb917d 100644 --- a/src/Giveaway.js +++ b/src/Giveaway.js @@ -562,15 +562,17 @@ class Giveaway extends EventEmitter { /** * Rerolls the giveaway. - * @param {GiveawayRerollOptions} The reroll options. + * @param {GiveawayRerollOptions} [options] The reroll options. * @returns {Promise} */ - reroll(options) { + reroll(options = {}) { return new Promise(async (resolve, reject) => { if (!this.ended) return reject('Giveaway with message ID ' + this.messageID + ' is not ended.'); if (!this.channel) return reject('Unable to get the channel of the giveaway with message ID ' + this.messageID + '.'); await this.fetchMessage().catch(() => {}); if (!this.message) return reject('Unable to fetch message with ID ' + this.messageID + '.'); + if (!options || typeof options !== 'object') return reject(`Options is not an object (val=${options})`); + options = merge(GiveawayRerollOptions, options); if (options.winnerCount && (!Number.isInteger(options.winnerCount) || options.winnerCount < 1)) { return reject(`options.winnerCount is not a positive integer. (val=${options.winnerCount})`); } @@ -616,7 +618,7 @@ class Giveaway extends EventEmitter { /** * Pauses the giveaway. - * @param {PauseOptions} options The pause. + * @param {PauseOptions} options The pause options. * @returns {Promise} The paused giveaway. */ pause(options = {}) { diff --git a/src/Manager.js b/src/Manager.js index a427f12c..72a3b1c3 100644 --- a/src/Manager.js +++ b/src/Manager.js @@ -267,7 +267,6 @@ class GiveawaysManager extends EventEmitter { */ reroll(messageID, options = {}) { return new Promise(async (resolve, reject) => { - options = merge(GiveawayRerollOptions, options); const giveaway = this.giveaways.find((g) => g.messageID === messageID); if (!giveaway) return reject('No giveaway found with message ID ' + messageID + '.');