diff --git a/packages/biscuit/Actions.ts b/packages/biscuit/Actions.ts index db5b49d..709f02a 100644 --- a/packages/biscuit/Actions.ts +++ b/packages/biscuit/Actions.ts @@ -58,6 +58,7 @@ import Integration from "./structures/Integration.ts"; import Guild from "./structures/guilds/Guild.ts"; import InteractionFactory from "./structures/interactions/InteractionFactory.ts"; import { InviteCreate, NewInviteCreate } from "./structures/Invite.ts"; +import { MessageReactionAdd, NewMessageReactionAdd } from "./structures/MessageReaction.ts"; export type RawHandler = (...args: [Session, number, T]) => void; export type Handler = (...args: T) => unknown; @@ -265,7 +266,7 @@ export const AUTO_MODERATION_ACTION_EXECUTE: RawHandler = (session, _shardId, reaction) => { - session.emit("messageReactionAdd", null); + session.emit("messageReactionAdd", NewMessageReactionAdd(session, reaction)); }; export const MESSAGE_REACTION_REMOVE: RawHandler = (session, _shardId, reaction) => { @@ -361,7 +362,7 @@ export interface Events { "messageCreate": Handler<[Message]>; "messageUpdate": Handler<[Partial]>; "messageDelete": Handler<[{ id: Snowflake, channelId: Snowflake, guildId?: Snowflake }]>; - "messageReactionAdd": Handler<[MessageReaction]>; + "messageReactionAdd": Handler<[MessageReactionAdd]>; "messageReactionRemove": Handler<[MessageReaction]>; "messageReactionRemoveAll": Handler<[MessageReaction]>; "messageReactionRemoveEmoji": Handler<[MessageReaction]>; diff --git a/packages/biscuit/structures/MessageReaction.ts b/packages/biscuit/structures/MessageReaction.ts index 9692d7b..9846f5f 100644 --- a/packages/biscuit/structures/MessageReaction.ts +++ b/packages/biscuit/structures/MessageReaction.ts @@ -1,6 +1,27 @@ import type { Session } from "../Session.ts"; -import type { DiscordReaction } from "../../discordeno/mod.ts"; +import type { DiscordMemberWithUser, DiscordMessageReactionAdd, DiscordReaction } from "../../discordeno/mod.ts"; import Emoji from "./Emoji.ts"; +import Member from "./Member.ts"; + +export interface MessageReactionAdd { + userId: string; + channelId: string; + messageId: string; + guildId?: string; + member?: Member; + emoji: Partial +} + +export function NewMessageReactionAdd(session: Session, data: DiscordMessageReactionAdd): MessageReactionAdd { + return { + userId: data.user_id, + channelId: data.channel_id, + messageId: data.message_id, + guildId: data.guild_id, + member: data.member ? new Member(session, (data.member as DiscordMemberWithUser), (data.guild_id || "")) : undefined, + emoji: new Emoji(session, data.emoji), + } +} /** * Represents a reaction