diff --git a/src/Giveaway.js b/src/Giveaway.js index 39832c98..3e87d9b5 100644 --- a/src/Giveaway.js +++ b/src/Giveaway.js @@ -403,18 +403,18 @@ class Giveaway extends EventEmitter { /** * @param {Discord.User} user The user to check. - * @returns {Promise} The highest bonus entries the user should get or false. + * @returns {Promise} The highest bonus entries the user should get. */ async checkBonusEntries(user) { const member = await this.message.guild.members.fetch(user.id).catch(() => {}); - const entries = []; + const entries = [0]; const cumulativeEntries = []; if (this.bonusEntries.length) { for (const obj of this.bonusEntries) { if (typeof obj.bonus === 'function') { try { - const result = await obj.bonus(member); + const result = await obj.bonus.apply(this, [member]); if (Number.isInteger(result) && result > 0) { if (obj.cumulative) cumulativeEntries.push(result); else entries.push(result); @@ -427,8 +427,7 @@ class Giveaway extends EventEmitter { } if (cumulativeEntries.length) entries.push(cumulativeEntries.reduce((a, b) => a + b)); - if (entries.length) return Math.max.apply(Math, entries); - return false; + return Math.max(...entries); } /** diff --git a/typings/index.d.ts b/typings/index.d.ts index e55ecd9a..64c0f7f1 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -169,10 +169,12 @@ declare module 'discord-giveaways' { private ensureEndTimeout(): void; private fillInString(string: string): string | null; private fillInString(embed: MessageEmbed | MessageEmbedOptions): MessageEmbed | null; + private checkWinnerEntry(user: User): Promise; public exemptMembers(member: GuildMember): Promise; + public checkBonusEntries(user: User): Promise; + public fetchMessage(): Promise; public edit(options: GiveawayEditOptions): Promise; public end(noWinnerMessage?: string | MessageObject): Promise; - public fetchMessage(): Promise; public reroll(options?: GiveawayRerollOptions): Promise; public roll(winnerCount?: number): Promise; public pause(options?: PauseOptions): Promise;