Skip to content

Commit

Permalink
sharding + custom db | important note in README
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico105 committed Jul 28, 2021
1 parent 2745869 commit e0ee063
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,8 @@ client.login(settings.token);

To make `discord-giveaways` working with shards, you will need to extend the `GiveawaysManager` class and update the `refreshStorage()` method. This method should call the `getAllGiveaways()` method for **every** shard, so all `GiveawaysManager` synchronize their cache with the updated database.

⚠️ **Note**: If you are using a [custom database](https://github.com/Androz2091/discord-giveaways#custom-database) then you must call (= add to code) `refreshStorage()` at the end of your extended `saveGiveaway`, `editGiveaway` and `deleteGiveaway` methods.

```js
const Discord = require('discord.js'),
client = new Discord.Client(),
Expand Down

4 comments on commit e0ee063

@Nico105
Copy link
Collaborator Author

@Nico105 Nico105 commented on e0ee063 Jul 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return client.shard.broadcastEval(() => this.giveawaysManager.getAllGiveaways());
Question: shouldn't this be return await client.shard.broadcastEval(async () => await this.giveawaysManager.getAllGiveaways()); ?
I don't have the option to test it (no sharding bot), so I don't really understand it.

Is it okay to not await the promise?
I'm bad at promises so I have no clue

@Dragonizedpizza
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is not.
https://discord.js.org/#/docs/main/master/class/ShardClientUtil?scrollTo=broadcastEval
it returns a promise, you must resolve the promise.

@Nico105
Copy link
Collaborator Author

@Nico105 Nico105 commented on e0ee063 Aug 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right and that was what confused me.
but i forgot: await this.manager.editGiveaway
we already await it in the packge code = so no problems. I think at least

@Dragonizedpizza
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right and that was what confused me.
but i forgot: await this.manager.editGiveaway
we already await it in the packge code = so no problems. I think at least

image
Nevermind, it is okay. When you call it with await, the promise is resolved either way.

Please sign in to comment.