feat: fixes to GuildMemberCache events
This commit is contained in:
parent
fa50110766
commit
baee6d2d45
3 changed files with 7 additions and 14 deletions
|
@ -1,15 +1,10 @@
|
|||
import { AuditLogEvent } from "discord.js";
|
||||
import { guildPluginEventListener } from "knub";
|
||||
import { updateMemberCacheForMember } from "../functions/updateMemberCacheForMember";
|
||||
import { GuildMemberCachePluginType } from "../types";
|
||||
|
||||
export const updateMemberCacheOnMemberUpdate = guildPluginEventListener<GuildMemberCachePluginType>()({
|
||||
event: "guildAuditLogEntryCreate",
|
||||
async listener({ pluginData, args: { auditLogEntry } }) {
|
||||
if (auditLogEntry.action !== AuditLogEvent.MemberUpdate) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateMemberCacheForMember(pluginData, auditLogEntry.targetId!);
|
||||
event: "guildMemberUpdate",
|
||||
async listener({ pluginData, args: { newMember } }) {
|
||||
updateMemberCacheForMember(pluginData, newMember.id);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -6,11 +6,10 @@ export const updateMemberCacheOnMessage = guildPluginEventListener<GuildMemberCa
|
|||
event: "messageCreate",
|
||||
listener({ pluginData, args }) {
|
||||
// Update each member once per guild load when we see a message from them
|
||||
const key = `${pluginData.guild.id}-${args.message.author.id}`;
|
||||
if (pluginData.state.initialUpdatedMembers.has(key)) {
|
||||
if (pluginData.state.initialUpdatedMembers.has(args.message.author.id)) {
|
||||
return;
|
||||
}
|
||||
updateMemberCacheForMember(pluginData, args.message.author.id);
|
||||
pluginData.state.initialUpdatedMembers.add(key);
|
||||
pluginData.state.initialUpdatedMembers.add(args.message.author.id);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -10,11 +10,10 @@ export const updateMemberCacheOnVoiceStateUpdate = guildPluginEventListener<Guil
|
|||
return;
|
||||
}
|
||||
// Update each member once per guild load when we see a message from them
|
||||
const key = `${pluginData.guild.id}-${memberId}`;
|
||||
if (pluginData.state.initialUpdatedMembers.has(key)) {
|
||||
if (pluginData.state.initialUpdatedMembers.has(memberId)) {
|
||||
return;
|
||||
}
|
||||
updateMemberCacheForMember(pluginData, memberId);
|
||||
pluginData.state.initialUpdatedMembers.add(key);
|
||||
pluginData.state.initialUpdatedMembers.add(memberId);
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue