mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 11:28:15 +00:00
fix
This commit is contained in:
@@ -2,7 +2,11 @@ import { botId, eventHandlers } from "../../bot.ts";
|
||||
import { cacheHandlers } from "../../cache.ts";
|
||||
import { structures } from "../../structures/mod.ts";
|
||||
import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts";
|
||||
import { DiscordMessageReactionAdd } from "../../types/messages/message_reaction_add.ts";
|
||||
import {
|
||||
DiscordMessageReactionAdd,
|
||||
MessageReactionAdd,
|
||||
} from "../../types/messages/message_reaction_add.ts";
|
||||
import { snakeKeysToCamelCase } from "../../util/utils.ts";
|
||||
|
||||
export async function handleMessageReactionAdd(data: DiscordGatewayPayload) {
|
||||
const payload = data.d as DiscordMessageReactionAdd;
|
||||
@@ -41,17 +45,8 @@ export async function handleMessageReactionAdd(data: DiscordGatewayPayload) {
|
||||
}
|
||||
}
|
||||
|
||||
const uncachedOptions = {
|
||||
...payload,
|
||||
id: payload.message_id,
|
||||
channelId: payload.channel_id,
|
||||
guildId: payload.guild_id || "",
|
||||
};
|
||||
|
||||
eventHandlers.reactionAdd?.(
|
||||
uncachedOptions,
|
||||
payload.emoji,
|
||||
payload.user_id,
|
||||
snakeKeysToCamelCase<MessageReactionAdd>(payload),
|
||||
message,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import { eventHandlers } from "../../bot.ts";
|
||||
import { cacheHandlers } from "../../cache.ts";
|
||||
import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts";
|
||||
import { DiscordMessageReactionRemove } from "../../types/messages/message_reaction_remove.ts";
|
||||
import {
|
||||
DiscordMessageReactionRemove,
|
||||
MessageReactionRemove,
|
||||
} from "../../types/messages/message_reaction_remove.ts";
|
||||
import { snakeKeysToCamelCase } from "../../util/utils.ts";
|
||||
|
||||
export async function handleMessageReactionRemove(
|
||||
data: DiscordGatewayPayload,
|
||||
@@ -18,24 +22,17 @@ export async function handleMessageReactionRemove(
|
||||
|
||||
if (reaction) {
|
||||
reaction.count--;
|
||||
if (reaction.count === 0) message.reactions = message.reactions?.filter(r => r.count !== 0);
|
||||
if (reaction.count === 0) {
|
||||
message.reactions = message.reactions?.filter((r) => r.count !== 0);
|
||||
}
|
||||
if (!message.reactions?.length) message.reactions = undefined;
|
||||
|
||||
await cacheHandlers.set("messages", payload.message_id, message);
|
||||
}
|
||||
}
|
||||
|
||||
const uncachedOptions = {
|
||||
...payload,
|
||||
id: payload.message_id,
|
||||
channelId: payload.channel_id,
|
||||
guildId: payload.guild_id,
|
||||
};
|
||||
|
||||
eventHandlers.reactionRemove?.(
|
||||
uncachedOptions,
|
||||
payload.emoji,
|
||||
payload.user_id,
|
||||
snakeKeysToCamelCase<MessageReactionRemove>(payload),
|
||||
message,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import { eventHandlers } from "../../bot.ts";
|
||||
import { cacheHandlers } from "../../cache.ts";
|
||||
import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts";
|
||||
import { DiscordMessageReactionRemoveAll } from "../../types/messages/message_reaction_remove_all.ts";
|
||||
import {
|
||||
DiscordMessageReactionRemoveAll,
|
||||
MessageReactionRemoveAll,
|
||||
} from "../../types/messages/message_reaction_remove_all.ts";
|
||||
import { snakeKeysToCamelCase } from "../../util/utils.ts";
|
||||
|
||||
export async function handleMessageReactionRemoveAll(
|
||||
data: DiscordGatewayPayload,
|
||||
@@ -15,5 +19,8 @@ export async function handleMessageReactionRemoveAll(
|
||||
await cacheHandlers.set("messages", payload.message_id, message);
|
||||
}
|
||||
|
||||
eventHandlers.reactionRemoveAll?.(payload);
|
||||
eventHandlers.reactionRemoveAll?.(
|
||||
snakeKeysToCamelCase<MessageReactionRemoveAll>(payload),
|
||||
message,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -18,13 +18,16 @@ export async function handleMessageReactionRemoveEmoji(
|
||||
reaction.emoji.name === payload.emoji.name
|
||||
),
|
||||
);
|
||||
|
||||
if (!message.reactions.length) message.reactions = undefined
|
||||
|
||||
if (!message.reactions.length) message.reactions = undefined;
|
||||
|
||||
await cacheHandlers.set("messages", payload.message_id, message);
|
||||
}
|
||||
|
||||
eventHandlers.reactionRemoveEmoji?.(
|
||||
data.d,
|
||||
payload.emoji,
|
||||
payload.message_id,
|
||||
payload.channel_id,
|
||||
payload.guild_id,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,22 +9,13 @@ export async function handleMessageUpdate(data: DiscordGatewayPayload) {
|
||||
const channel = await cacheHandlers.get("channels", payload.channel_id);
|
||||
if (!channel) return;
|
||||
|
||||
const cachedMessage = await cacheHandlers.get("messages", payload.id);
|
||||
if (!cachedMessage) return;
|
||||
|
||||
const oldMessage = {
|
||||
attachments: cachedMessage.attachments,
|
||||
content: cachedMessage.content,
|
||||
embeds: cachedMessage.embeds,
|
||||
editedTimestamp: cachedMessage.editedTimestamp,
|
||||
tts: cachedMessage.tts,
|
||||
pinned: cachedMessage.pinned,
|
||||
};
|
||||
const oldMessage = await cacheHandlers.get("messages", payload.id);
|
||||
if (!oldMessage) return;
|
||||
|
||||
// Messages with embeds can trigger update but they wont have edited_timestamp
|
||||
if (
|
||||
!payload.edited_timestamp ||
|
||||
(cachedMessage.content === payload.content)
|
||||
(oldMessage.content === payload.content)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user