Skip to content

Commit c0b6c6c

Browse files
author
Marwan ZOGHLAMI
committed
feat(quoi-feur): cumulative streak punishment and prevent mute evading
To improve fun:tm: and punish players in the most efficient way, the mute is now an accumulation of how many times "quoi" has been said since the last timeout. e.g.: An "akhy" spam "quoi" 10 times and didn't get a timeout, then another random try to say "quoi" and got chosen by the "pseudo-randomness": he will be muted for 11 minutes The second feature is to prevent cheat by muting before displaying "coubeh". Some users just delete their messages before they get muted by the bot.
1 parent cf4a36b commit c0b6c6c

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/core/cache.ts

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ interface Cache<Entries extends Record<string, any>> {
2323
interface CacheEntries {
2424
lobbyIds: string[];
2525
onDemandChannels: string[];
26+
quoiAccumulation: number;
2627
quoiFeurChannels: string[];
2728
recurringMessages: { id: string; channelId: string; frequency: Frequency; message: string }[];
2829
}

src/modules/quoiFeur/quoiFeur.helpers.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export const reactOnEndWithQuoi = async (message: Message) => {
3838
if (!endWithQuoi(message.content)) return;
3939

4040
const channelIds = await cache.get('quoiFeurChannels', []);
41+
const accumulation = await cache.get('quoiAccumulation', 1);
4142

4243
const messageParentId =
4344
message.channel.type === ChannelType.PublicThread ? message.channel.parentId : null;
@@ -51,14 +52,17 @@ export const reactOnEndWithQuoi = async (message: Message) => {
5152
const probability = 1 / 6;
5253

5354
if (Math.random() <= probability) {
54-
await reactWithCoubeh(message);
5555
await message.member?.timeout(
56-
ONE_MINUTE * 5,
56+
ONE_MINUTE * accumulation,
5757
`${message.member.displayName} have the cramptés`,
5858
);
59+
await cache.set('quoiAccumulation', 1);
60+
await reactWithCoubeh(message);
61+
5962
return;
6063
}
6164

65+
await cache.set('quoiAccumulation', accumulation + 1);
6266
await reactWithFeur(message);
6367
};
6468

0 commit comments

Comments
 (0)