mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 20:35:02 +00:00
Migrate ReactionRoles to new Plugin structure
This commit is contained in:
parent
140ba84544
commit
c0b7bea35d
12 changed files with 512 additions and 0 deletions
|
@ -0,0 +1,20 @@
|
|||
import { ReactionRolesPluginType } from "../types";
|
||||
import { PluginData } from "knub";
|
||||
import { applyReactionRoleReactionsToMessage } from "./applyReactionRoleReactionsToMessage";
|
||||
|
||||
export async function refreshReactionRoles(
|
||||
pluginData: PluginData<ReactionRolesPluginType>,
|
||||
channelId: string,
|
||||
messageId: string,
|
||||
) {
|
||||
const pendingKey = `${channelId}-${messageId}`;
|
||||
if (pluginData.state.pendingRefreshes.has(pendingKey)) return;
|
||||
pluginData.state.pendingRefreshes.add(pendingKey);
|
||||
|
||||
try {
|
||||
const reactionRoles = await pluginData.state.reactionRoles.getForMessage(messageId);
|
||||
await applyReactionRoleReactionsToMessage(pluginData, channelId, messageId, reactionRoles);
|
||||
} finally {
|
||||
pluginData.state.pendingRefreshes.delete(pendingKey);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue