diff --git a/src/core/cache.ts b/src/core/cache.ts index f84ecad..c3ebfd4 100644 --- a/src/core/cache.ts +++ b/src/core/cache.ts @@ -23,6 +23,7 @@ interface Cache> { interface CacheEntries { lobbyIds: string[]; onDemandChannels: string[]; + quoiAccumulation: number; quoiFeurChannels: string[]; recurringMessages: { id: string; channelId: string; frequency: Frequency; message: string }[]; } diff --git a/src/modules/quoiFeur/quoiFeur.helpers.ts b/src/modules/quoiFeur/quoiFeur.helpers.ts index b88af96..87c287e 100644 --- a/src/modules/quoiFeur/quoiFeur.helpers.ts +++ b/src/modules/quoiFeur/quoiFeur.helpers.ts @@ -39,6 +39,7 @@ export const reactOnEndWithQuoi = async (message: Message) => { if (!endWithQuoi(message.content)) return; const channelIds = await cache.get('quoiFeurChannels', []); + const accumulation = await cache.get('quoiAccumulation', 1); const messageParentId = message.channel.type === ChannelType.PublicThread ? message.channel.parentId : null; @@ -52,14 +53,17 @@ export const reactOnEndWithQuoi = async (message: Message) => { const probability = 1 / 6; if (Math.random() <= probability) { - await reactWithCoubeh(message); await message.member?.timeout( - ONE_MINUTE * 5, + ONE_MINUTE * accumulation, `${message.member.displayName} have the cramptés`, ); + await cache.set('quoiAccumulation', 1); + await reactWithCoubeh(message); + return; } + await cache.set('quoiAccumulation', accumulation + 1); await reactWithFeur(message); };