Skip to content

Commit

Permalink
fix - return early if no message for regural case
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico105 committed Aug 31, 2021
1 parent 35f61f4 commit 4dc26e6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,13 +528,14 @@ class GiveawaysManager extends EventEmitter {
}

// Regular case: the giveaway is not ended and we need to update it
giveaway.message ??= await giveaway.fetchMessage().catch(() => {});
if (!giveaway.message) return;
const lastChanceEnabled = giveaway.lastChance.enabled && giveaway.remainingTime < giveaway.lastChance.threshold;
const updatedEmbed = this.generateMainEmbed(giveaway, lastChanceEnabled);
giveaway.message ??= await giveaway.fetchMessage().catch(() => {});
const needUpdate = !embedEqual(giveaway.message.embeds[0], updatedEmbed) || giveaway.message.content !== giveaway.fillInString(giveaway.messages.giveaway);

if (needUpdate || this.options.forceUpdateEvery) {
giveaway.message?.edit({
giveaway.message.edit({
content: giveaway.fillInString(giveaway.messages.giveaway),
embeds: [updatedEmbed],
allowedMentions: giveaway.allowedMentions
Expand Down

0 comments on commit 4dc26e6

Please sign in to comment.