Skip to content

Commit

Permalink
more fetching because of "makeCache"
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico105 committed Aug 7, 2021
1 parent b8a75c1 commit c3cc70b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"homepage": "https://discord-giveaways.js.org",
"dependencies": {
"deepmerge": "^4.2.2",
"discord.js": "^13.0.0",
"discord.js": "^13.0.1",
"serialize-javascript": "^6.0.0"
},
"devDependencies": {
Expand Down
14 changes: 5 additions & 9 deletions src/Giveaway.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,7 @@ class Giveaway extends EventEmitter {
*/
async checkWinnerEntry(user) {
if (this.winnerIDs.includes(user.id)) return false;
const guild = this.message.guild;
const member = await guild.members.fetch(user.id).catch(() => {});
const member = await this.message.guild.members.fetch(user.id).catch(() => {});
if (!member) return false;
const exemptMember = await this.exemptMembers(member);
if (exemptMember) return false;
Expand All @@ -369,7 +368,7 @@ class Giveaway extends EventEmitter {
* @returns {Promise<number|boolean>} The highest bonus entries the user should get or false.
*/
async checkBonusEntries(user) {
const member = this.message.guild.members.cache.get(user.id);
const member = await this.message.guild.members.fetch(user.id).catch(() => {});
const entries = [];
const cumulativeEntries = [];

Expand All @@ -379,11 +378,8 @@ class Giveaway extends EventEmitter {
try {
const result = await obj.bonus(member);
if (Number.isInteger(result) && result > 0) {
if (obj.cumulative) {
cumulativeEntries.push(result);
} else {
entries.push(result);
}
if (obj.cumulative) cumulativeEntries.push(result);
else entries.push(result);
}
} catch (err) {
console.error(`Giveaway message ID: ${this.messageID}\n${serialize(obj.bonus)}\n${err}`);
Expand Down Expand Up @@ -471,7 +467,7 @@ class Giveaway extends EventEmitter {
}
}

return winners.map((user) => guild.members.cache.get(user.id));
return await Promise.all(winners.map(async (user) => await guild.members.fetch(user.id).catch(() => {})));
}

/**
Expand Down

0 comments on commit c3cc70b

Please sign in to comment.