Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/core/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ interface Cache<Entries extends Record<string, any>> {
interface CacheEntries {
lobbyIds: string[];
onDemandChannels: string[];
quoiAccumulation: number;
quoiFeurChannels: string[];
recurringMessages: { id: string; channelId: string; frequency: Frequency; message: string }[];
}
Expand Down
8 changes: 6 additions & 2 deletions src/modules/quoiFeur/quoiFeur.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
};

Expand Down