summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Pignolet <matthieu@matthieu-dev.xyz>2024-07-09 14:21:58 +0400
committerMatthieu Pignolet <matthieu@matthieu-dev.xyz>2024-07-09 14:21:58 +0400
commit8960400eda94c27bb2af73df39df77c81c2a8847 (patch)
tree5b3fcafa9ec2cdc417ec8e7cf7ef1a27614ce064
parent63ea409e83f046fae1279688aaee312f02db0a3f (diff)
change response algorithm
-rw-r--r--discordjs/src/index.mjs25
1 files changed, 17 insertions, 8 deletions
diff --git a/discordjs/src/index.mjs b/discordjs/src/index.mjs
index 354d651..9a37a1f 100644
--- a/discordjs/src/index.mjs
+++ b/discordjs/src/index.mjs
@@ -47,20 +47,29 @@ const specialChannels = [
"1248226018406301696"
]
+let counter = 0;
const messageAction = async (message) => {
if (message.author.bot) return;
- const cleanText = sanitizeWord(message.cleanContent);
- if (countChars(cleanText) > 0) {
- let response = await completeWord(cleanText);
- // Ignore if there is no completion
- const shouldReply = (Math.random() > 0.995 || specialChannels.includes(message.channelId) || message.guild == null);
- if ((response || response === "") && shouldReply) {
- message.reply(response);
+ counter += 1;
+
+ let shouldReply = (counter >= 75 || specialChannels.includes(message.channelId) || message.guild == null);
+
+ if (shouldReply) {
+ const cleanText = sanitizeWord(message.cleanContent);
+ if (countChars(cleanText) > 0) {
+ let response = await completeWord(cleanText);
+
+ // Ignore if there is no completion
+ if ((response || response === "")) {
+ message.reply(response);
+ counter = 0;
+ }
}
}
- if ((message.content.includes("@everyone") && message.guild.id === "1055126989566124083") || specialChannels.includes(message.channelId)) {
+ let isEveryone = message.cleanContent.includes("@everyone") && message.guild.id === "1055126989566124083";
+ if (isEveryone) {
message.reply("https://cdn.mpgn.dev/pascontent-gabe.gif");
}
};