Skip to content

Commit 4f1415e

Browse files
committed
патом
1 parent 637e083 commit 4f1415e

File tree

2 files changed

+47
-52
lines changed

2 files changed

+47
-52
lines changed
File renamed without changes.

src/events/messageCreate.ts

Lines changed: 47 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import type { Message } from "discord.js";
22
import mentionCommands from "../handlers/mentionCommands";
33
import config from "../config";
4-
import fs from "fs";
5-
import path from "path";
4+
// import fs from "fs";
5+
// import path from "path";
66

7-
function escapeString(word: string) {
7+
export function escapeString(word: string) {
88
return word.replace(/"/g, '\\"');
99
}
1010

@@ -14,53 +14,48 @@ export async function run(message: Message<true>) {
1414
if (message.content.startsWith(`<@${message.client.user.id}> `) && config.admins.includes(message.author.id))
1515
return mentionCommands(message);
1616

17-
let counter = 0;
18-
19-
console.log(path.join("databases", `wordsdb_${message.guildId}.txt`));
20-
console.log(fs.existsSync(path.join("databases", `wordsdb_${message.guildId}.txt`)));
21-
22-
const filename = path.join("databases", `wordsdb_${message.guildId}.txt`);
23-
24-
if (!fs.existsSync("databases")) fs.mkdirSync("databases");
25-
if (!fs.existsSync(filename)) fs.writeFileSync(filename, "");
26-
27-
if (message.author.id !== "824379835262304257") {
28-
const words = message.content.split(" ");
29-
fs.appendFileSync(filename, words.map(escapeString).join(" ") + " ");
30-
}
31-
32-
const handleCounter = async () => {
33-
counter++;
34-
if (counter >= 25) {
35-
const wordsStr = fs.readFileSync(filename, "utf8");
36-
const words = wordsStr.split(" ");
37-
if (words.length > 0) {
38-
const numWords = Math.min(Math.floor(Math.random() * 10) + 1, words.length);
39-
const expression = words.slice(0, numWords).join(" ");
40-
await message.channel.send(expression);
41-
}
42-
43-
counter = 0;
44-
}
45-
};
46-
47-
if (message.guildId === "764178286233518100") {
48-
if (message.channel.id === "764179432147124304") {
49-
const wordsStr = fs.readFileSync(filename, "utf8");
50-
const words = wordsStr.split(" ");
51-
if (words.length > 0) {
52-
const numWords = Math.min(Math.floor(Math.random() * 15) + 1, words.length);
53-
const expression = words.slice(0, numWords).join(" ");
54-
await message.channel.send(expression);
55-
}
56-
57-
counter = 0;
58-
}
59-
60-
if (counter > 0) handleCounter();
61-
if (message.mentions.has("824379835262304257")) handleCounter();
62-
} else {
63-
if (counter > 0) handleCounter();
64-
if (message.mentions.has("824379835262304257")) handleCounter();
65-
}
17+
// let counter = 0;
18+
// const filename = path.join("databases", `wordsdb_${message.guildId}.txt`);
19+
20+
// if (!fs.existsSync(filename)) fs.writeFileSync(filename, "");
21+
22+
// if (message.author.id !== "824379835262304257") {
23+
// const words = message.content.split(" ");
24+
// fs.appendFileSync(filename, words.map(escapeString).join(" ") + " ");
25+
// }
26+
27+
// const handleCounter = async () => {
28+
// counter++;
29+
// if (counter >= 25) {
30+
// const wordsStr = fs.readFileSync(filename, "utf8");
31+
// const words = wordsStr.split(" ");
32+
// if (words.length > 0) {
33+
// const numWords = Math.min(Math.floor(Math.random() * 10) + 1, words.length);
34+
// const expression = words.slice(0, numWords).join(" ");
35+
// await message.channel.send(expression);
36+
// }
37+
38+
// counter = 0;
39+
// }
40+
// };
41+
42+
// if (message.guildId === "764178286233518100") {
43+
// if (message.channel.id === "764179432147124304") {
44+
// const wordsStr = fs.readFileSync(filename, "utf8");
45+
// const words = wordsStr.split(" ");
46+
// if (words.length > 0) {
47+
// const numWords = Math.min(Math.floor(Math.random() * 15) + 1, words.length);
48+
// const expression = words.slice(0, numWords).join(" ");
49+
// await message.channel.send(expression);
50+
// }
51+
52+
// counter = 0;
53+
// }
54+
55+
// if (counter > 0) handleCounter();
56+
// if (message.mentions.has("824379835262304257")) handleCounter();
57+
// } else {
58+
// if (counter > 0) handleCounter();
59+
// if (message.mentions.has("824379835262304257")) handleCounter();
60+
// }
6661
}

0 commit comments

Comments
 (0)