fix(controllers): update cache with new value in gateway events (#433)

* fix(controllers): cache updated member

* fix(controllers): cache update guild

* fix(controllers): cache user update

* fix(controllers): cache voice state update

* refactor(controllers): message reaction add remove previousReactions

* refactor(controllers): message reaction remove remove previousReactions

* fix(controllers): cache message reaction remove all

* fix(controllers): cache message reaction remove emoji

* fix(controllers): cache guild role create

* fix(controllers): role delete event update cache and return eventHandler

* fix(controllers): cache role update

* don't return eventHandlers

* don't return eventHandlers
This commit is contained in:
ITOH
2021-01-22 16:20:33 +01:00
committed by GitHub
parent 8d5803c82a
commit 62af388820
5 changed files with 56 additions and 15 deletions
+8 -1
View File
@@ -16,7 +16,9 @@ export async function handleInternalGuildRoleCreate(data: DiscordPayload) {
const role = await structures.createRole(payload.role);
guild.roles = guild.roles.set(payload.role.id, role);
return eventHandlers.roleCreate?.(guild, role);
await cacheHandlers.set("guilds", payload.guild_id, guild);
eventHandlers.roleCreate?.(guild, role);
}
export async function handleInternalGuildRoleDelete(data: DiscordPayload) {
@@ -41,8 +43,11 @@ export async function handleInternalGuildRoleDelete(data: DiscordPayload) {
if (!g.roles.includes(payload.role_id)) return;
// Remove this role from the members cache
g.roles = g.roles.filter((id) => id !== payload.role_id);
cacheHandlers.set("members", member.id, member);
});
});
eventHandlers.roleDelete?.(guild, cachedRole);
}
export async function handleInternalGuildRoleUpdate(data: DiscordPayload) {
@@ -57,5 +62,7 @@ export async function handleInternalGuildRoleUpdate(data: DiscordPayload) {
const role = await structures.createRole(payload.role);
guild.roles.set(payload.role.id, role);
await cacheHandlers.set("guilds", guild.id, guild);
eventHandlers.roleUpdate?.(guild, role, cachedRole);
}