Skip to content

Commit d207c17

Browse files
committed
fix(quoi-feur): fix typing need PartialMessage
1 parent 8e69cb6 commit d207c17

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/modules/quoiFeur/quoiFeur.helpers.ts

+20-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import {
22
ChannelType,
33
type ChatInputCommandInteraction,
44
DMChannel,
5-
type Message,
5+
Message,
66
type NonThreadGuildBasedChannel,
7+
type PartialMessage,
78
} from 'discord.js';
89

910
import { cache } from '../../core/cache';
@@ -62,8 +63,24 @@ export const reactOnEndWithQuoi = async (message: Message) => {
6263
await reactWithFeur(message);
6364
};
6465

65-
export const reactOnEndWithQuoiUpdated = async (_oldMessage: Message, newMessage: Message) =>
66-
reactOnEndWithQuoi(newMessage);
66+
export const reactOnEndWithQuoiUpdated = async (
67+
_oldMessage: Message | PartialMessage,
68+
newMessage: Message | PartialMessage,
69+
) => {
70+
if (!(newMessage instanceof Message)) return;
71+
72+
// Both E and U are in feur and coubeh, that should be sufficient to detect if the bot has already reacted
73+
const feurCoubeh = new Set<string>([EMOJI.E, EMOJI.U]);
74+
75+
// Check if the old message already has a reaction
76+
const selfReactions = newMessage.reactions.cache.some((reaction) => {
77+
return reaction.me && reaction.emoji.name && feurCoubeh.has(reaction.emoji.name);
78+
});
79+
80+
if (selfReactions) return;
81+
82+
await reactOnEndWithQuoi(newMessage);
83+
};
6784

6885
export const addQuoiFeurToChannel = async (interaction: ChatInputCommandInteraction) => {
6986
const { channel } = interaction;

0 commit comments

Comments
 (0)