Skip to content

Commit a48a02f

Browse files
committed
fix(quoi-feur): prevent bot for re-reacting on edit
1 parent 9bacefb commit a48a02f

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

flake.nix

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
inputs = {
3+
nixpkgs.url = "github:NixOS/nixpkgs/23.11";
4+
utils.url = "github:numtide/flake-utils";
5+
};
6+
7+
outputs = {
8+
self,
9+
nixpkgs,
10+
utils,
11+
}:
12+
utils.lib.eachDefaultSystem (system: let
13+
pkgs = import nixpkgs {
14+
inherit system;
15+
};
16+
in {
17+
18+
# -7QJRXB1-nshZe7V-ub1Z4SVHn_tNwJW
19+
devShell = with pkgs;
20+
mkShell rec {
21+
buildInputs = [
22+
nodejs_20
23+
corepack_20
24+
docker-compose
25+
redis
26+
];
27+
28+
# https://github.com/nodejs/corepack#utility-commands
29+
shellHook = ''
30+
'';
31+
};
32+
33+
formatter = nixpkgs.legacyPackages.x86_64-linux.alejandra;
34+
});
35+
}

src/modules/quoiFeur/quoiFeur.helpers.ts

+11
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,17 @@ export const reactOnEndWithQuoiUpdated = async (
6868
newMessage: Message | PartialMessage,
6969
) => {
7070
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+
7182
await reactOnEndWithQuoi(newMessage);
7283
};
7384

0 commit comments

Comments
 (0)