summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Pignolet <m@mpgn.dev>2025-01-30 19:03:29 +0400
committerMatthieu Pignolet <m@mpgn.dev>2025-01-30 19:03:29 +0400
commit3ba26023d0d8b2b033a02a731cb5985923ee73e7 (patch)
tree2de3c4c567e5776618235e8638b5ac5af154ce6b
parent3d5c4980a17b7635c34393006a5cc15ab128cec0 (diff)
fix wrong sanitization
-rw-r--r--discordjs/src/index.mjs29
1 files changed, 15 insertions, 14 deletions
diff --git a/discordjs/src/index.mjs b/discordjs/src/index.mjs
index f0a4bae..589d75a 100644
--- a/discordjs/src/index.mjs
+++ b/discordjs/src/index.mjs
@@ -7,13 +7,14 @@ const SYMBOL_FOR_CREATE = Symbol.for("CREATE");
const SYMBOL_FOR_UPDATE = Symbol.for("UPDATE");
// Create a new client instance
-const client = new Client({ intents:
- [
- GatewayIntentBits.Guilds,
- GatewayIntentBits.MessageContent,
- GatewayIntentBits.GuildMessages,
- GatewayIntentBits.DirectMessages
- ]
+const client = new Client({
+ intents:
+ [
+ GatewayIntentBits.Guilds,
+ GatewayIntentBits.MessageContent,
+ GatewayIntentBits.GuildMessages,
+ GatewayIntentBits.DirectMessages
+ ]
});
// `autofeur_db` service
@@ -40,13 +41,13 @@ export const completeWord = (grapheme) => {
*/
const sanitizeWord = (sentence) => {
let lastWord = sentence
- .trim()
- .split(" ")
- .slice(-1)[0]
.replaceAll(/(?:https?|ftp):\/\/[\n\S]+/g, "")
.replaceAll(/\:([a-z]|[A-Z])+\:/g, "")
.replaceAll(/(\?|\!|\.|\,|\;)/g, "")
- .replaceAll(/([^A-z])/g, "");
+ .replaceAll(/([^A-z])/g, "")
+ .trim()
+ .split(" ")
+ .slice(-1)[0];
return lastWord;
};
const anyTrivialCharRegex = /([a-z]|[A-Z])+/g;
@@ -74,11 +75,11 @@ const messageAction = async (message, ctx) => {
.messages
.fetch({
limit: 2,
- cache : false
+ cache: false
}))
.last()
.createdTimestamp;
-
+
let shouldReplyByTimestamp = currentTimestamp - lastMessageTimestamp >= 3600000;
let shouldReplyByCounter =
messageReplyCounter >= Math.floor(Math.random() * 75) + 35;
@@ -107,7 +108,7 @@ const messageAction = async (message, ctx) => {
messageReplyCounter = oldCounter;
}
}
-
+
if (message.content.includes("@everyone") && !ignoredChannels.includes(message.channelId)) {
message.reply("https://cdn.mpgn.dev/pascontent-gabe.gif");
}