File tree 1 file changed +20
-3
lines changed
1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change 2
2
ChannelType ,
3
3
type ChatInputCommandInteraction ,
4
4
DMChannel ,
5
- type Message ,
5
+ Message ,
6
6
type NonThreadGuildBasedChannel ,
7
+ type PartialMessage ,
7
8
} from 'discord.js' ;
8
9
9
10
import { cache } from '../../core/cache' ;
@@ -62,8 +63,24 @@ export const reactOnEndWithQuoi = async (message: Message) => {
62
63
await reactWithFeur ( message ) ;
63
64
} ;
64
65
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
+ } ;
67
84
68
85
export const addQuoiFeurToChannel = async ( interaction : ChatInputCommandInteraction ) => {
69
86
const { channel } = interaction ;
You can’t perform that action at this time.
0 commit comments