mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
feat: add member cache; handle all role changes with RoleManagerPlugin; exit gracefully
This commit is contained in:
parent
fd60a09947
commit
fa50110766
48 changed files with 755 additions and 264 deletions
|
@ -0,0 +1,17 @@
|
|||
import { GuildPluginData } from "knub";
|
||||
import { GuildMemberCachePluginType } from "../types";
|
||||
|
||||
export async function updateMemberCacheForMember(
|
||||
pluginData: GuildPluginData<GuildMemberCachePluginType>,
|
||||
userId: string,
|
||||
) {
|
||||
const upToDateMember = await pluginData.guild.members.fetch(userId);
|
||||
const roles = Array.from(upToDateMember.roles.cache.keys())
|
||||
// Filter out @everyone role
|
||||
.filter((roleId) => roleId !== pluginData.guild.id);
|
||||
pluginData.state.memberCache.setCachedMemberData(upToDateMember.id, {
|
||||
username: upToDateMember.user.username,
|
||||
nickname: upToDateMember.nickname,
|
||||
roles,
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue