Skip to content

Commit

Permalink
fix comment flaws + reroll option merging
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico105 committed Jul 31, 2021
1 parent 73fe361 commit 58bd0d3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 5 additions & 3 deletions src/Giveaway.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,15 +562,17 @@ class Giveaway extends EventEmitter {

/**
* Rerolls the giveaway.
* @param {GiveawayRerollOptions} The reroll options.
* @param {GiveawayRerollOptions} [options] The reroll options.
* @returns {Promise<Discord.GuildMember[]>}
*/
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})`);
}
Expand Down Expand Up @@ -616,7 +618,7 @@ class Giveaway extends EventEmitter {

/**
* Pauses the giveaway.
* @param {PauseOptions} options The pause.
* @param {PauseOptions} options The pause options.
* @returns {Promise<Giveaway>} The paused giveaway.
*/
pause(options = {}) {
Expand Down
1 change: 0 additions & 1 deletion src/Manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 + '.');

Expand Down

0 comments on commit 58bd0d3

Please sign in to comment.