mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-20 00:05:04 +00:00
Knub 30 conversion base work; Work on Utility plugin Knub 30 conversion
This commit is contained in:
parent
a1b747f30e
commit
4653fc9bf7
18 changed files with 585 additions and 324 deletions
20
backend/src/plugins/Utility/refreshMembers.ts
Normal file
20
backend/src/plugins/Utility/refreshMembers.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
import { Guild } from "eris";
|
||||
import { MINUTES, noop } from "../../utils";
|
||||
|
||||
const MEMBER_REFRESH_FREQUENCY = 10 * MINUTES; // How often to do a full member refresh when using commands that need it
|
||||
const memberRefreshLog = new Map<string, { time: number, promise: Promise<void> }>();
|
||||
|
||||
export async function refreshMembersIfNeeded(guild: Guild) {
|
||||
const lastRefresh = memberRefreshLog.get(guild.id);
|
||||
if (lastRefresh && Date.now() < lastRefresh.time + MEMBER_REFRESH_FREQUENCY) {
|
||||
return lastRefresh.promise;
|
||||
}
|
||||
|
||||
const loadPromise = guild.fetchAllMembers().then(noop);
|
||||
memberRefreshLog.set(guild.id, {
|
||||
time: Date.now(),
|
||||
promise: loadPromise,
|
||||
});
|
||||
|
||||
return loadPromise;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue