3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

Add locks to starboard and include example of level-only starring (#125)

This commit is contained in:
Nils 2020-12-20 17:32:24 +01:00 committed by GitHub
parent adc8959836
commit b2a53b0722
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View file

@ -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
~~~
`),
},

View file

@ -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();
}
},
});