Add locks to starboard and include example of level-only starring (#125)
This commit is contained in:
parent
adc8959836
commit
b2a53b0722
2 changed files with 21 additions and 0 deletions
|
@ -88,6 +88,25 @@ export const StarboardPlugin = zeppelinGuildPlugin<StarboardPluginType>()("starb
|
|||
basic:
|
||||
enabled: true
|
||||
~~~
|
||||
|
||||
### Limit starboard to a specific level (and above)
|
||||
This is identical to the basic starboard above, but only works for a specific level (>=50).
|
||||
|
||||
~~~yml
|
||||
starboard:
|
||||
config:
|
||||
boards:
|
||||
levelonly:
|
||||
enabled: false # The starboard starts disabled and is then enabled in a level override below
|
||||
channel_id: "604342689038729226"
|
||||
stars_required: 1
|
||||
overrides:
|
||||
- level: ">=50"
|
||||
config:
|
||||
boards:
|
||||
levelonly:
|
||||
enabled: true
|
||||
~~~
|
||||
`),
|
||||
},
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ export const StarboardReactionAddEvt = starboardEvt({
|
|||
});
|
||||
|
||||
for (const starboard of applicableStarboards) {
|
||||
const boardLock = await pluginData.locks.acquire(`starboards-channel-${starboard.channel_id}`);
|
||||
// Save reaction into the database
|
||||
await pluginData.state.starboardReactions.createStarboardReaction(msg.id, userId).catch(noop);
|
||||
|
||||
|
@ -73,6 +74,7 @@ export const StarboardReactionAddEvt = starboardEvt({
|
|||
if (reactionsCount >= starboard.stars_required) {
|
||||
await saveMessageToStarboard(pluginData, msg, starboard);
|
||||
}
|
||||
boardLock.unlock();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue