mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-04 01:40:08 +00:00
Merge pull request #79 from Androz2091/presence-update
Add oldPresence to presenceUpdate event
This commit is contained in:
@@ -563,7 +563,10 @@ export async function handleDiscordPayload(
|
||||
}
|
||||
|
||||
if (data.t === "PRESENCE_UPDATE") {
|
||||
return eventHandlers.presenceUpdate?.(data.d as PresenceUpdatePayload);
|
||||
const payload = data.d as PresenceUpdatePayload;
|
||||
const oldPresence = cache.presences.get(payload.user.id);
|
||||
cache.presences.set(payload.user.id, payload);
|
||||
return eventHandlers.presenceUpdate?.(payload, oldPresence);
|
||||
}
|
||||
|
||||
if (data.t === "TYPING_START") {
|
||||
|
||||
@@ -105,7 +105,10 @@ export interface EventHandlers {
|
||||
nickname: string,
|
||||
oldNickname?: string,
|
||||
) => unknown;
|
||||
presenceUpdate?: (data: PresenceUpdatePayload) => unknown;
|
||||
presenceUpdate?: (
|
||||
presence: PresenceUpdatePayload,
|
||||
oldPresence?: PresenceUpdatePayload,
|
||||
) => unknown;
|
||||
raw?: (data: DiscordPayload) => unknown;
|
||||
ready?: () => unknown;
|
||||
reactionAdd?: (
|
||||
|
||||
@@ -3,12 +3,14 @@ import { Message } from "../structures/message.ts";
|
||||
import { Guild } from "../structures/guild.ts";
|
||||
import { Channel } from "../structures/channel.ts";
|
||||
import { delay } from "https://deno.land/std@0.61.0/async/delay.ts";
|
||||
import { PresenceUpdatePayload } from "../types/discord.ts";
|
||||
|
||||
export interface CacheData {
|
||||
guilds: Collection<string, Guild>;
|
||||
channels: Collection<string, Channel>;
|
||||
messages: Collection<string, Message>;
|
||||
unavailableGuilds: Collection<string, number>;
|
||||
presences: Collection<string, PresenceUpdatePayload>;
|
||||
}
|
||||
|
||||
export const cache: CacheData = {
|
||||
@@ -16,6 +18,7 @@ export const cache: CacheData = {
|
||||
channels: new Collection(),
|
||||
messages: new Collection(),
|
||||
unavailableGuilds: new Collection(),
|
||||
presences: new Collection(),
|
||||
};
|
||||
|
||||
async function cleanMessageCache() {
|
||||
|
||||
Reference in New Issue
Block a user