plno věcí, hlavně timouty pro zmrdy
This commit is contained in:
parent
b1c57e6a9e
commit
380d57cdb8
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "denim_3001",
|
||||
"version": "3001.49.0",
|
||||
"version": "3001.50.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "denim_3001",
|
||||
"version": "3001.49.0",
|
||||
"version": "3001.50.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@discordjs/voice": "^0.15.0",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "denim_3001",
|
||||
"version": "3001.49.0",
|
||||
"version": "3001.50.0",
|
||||
"description": "Toto je velmi kvalitní bot.",
|
||||
"repository": {
|
||||
"url": "https://github.com/Histmy/Denim-Bot/"
|
||||
|
||||
@ -255,13 +255,13 @@ async function runKomand(mesOrInt: Message | CommandInteraction, cmd: Komand, cm
|
||||
}
|
||||
|
||||
client.on("messageCreate", async mes => {
|
||||
if (process.env.ignoreMess || mes.author.id == client.user!.id) return;
|
||||
if (process.env.ignoreMess) return;
|
||||
|
||||
const [mesPrefix, komandSDiakritikou, ...args] = mes.content.split(" ");
|
||||
|
||||
const prefixDiff = levenshtein(oddiakritikovat(mesPrefix.toLowerCase()), prefix);
|
||||
if (prefixDiff > 0) {
|
||||
if (prefixDiff <= 2 && mes.author.id != client.user!.id) mes.channel.send(`${prefix}*`);
|
||||
if (prefixDiff <= 1 && mes.author.id != client.user!.id) mes.channel.send(`${prefix}*`);
|
||||
return void runEvent("messageCreate", [mes]);
|
||||
}
|
||||
|
||||
|
||||
@ -208,7 +208,7 @@ const exp: Modul = {
|
||||
|
||||
const make = (akce: "a" | "r", role: Role) => {
|
||||
const handle = (e: Error) => {
|
||||
if (["Missing Permissions", "DiscordAPIError[50001]: Missing Access"].includes(e.message)) return;
|
||||
if (["Missing Permissions", "Missing Access"].includes(e.message)) return;
|
||||
log("chyba pri davani/odebirani role", e);
|
||||
};
|
||||
if (akce == "a") member.roles.add(role).catch(handle);
|
||||
@ -238,7 +238,10 @@ const exp: Modul = {
|
||||
return true;
|
||||
}
|
||||
|
||||
mes.delete();
|
||||
mes.delete().catch((e: Error) => {
|
||||
if (e.name == "DiscordAPIError[5OO13]") return;
|
||||
log("chyba pri mazani", e);
|
||||
});
|
||||
sendDM(mes.author, "spis tak nepis");
|
||||
return true;
|
||||
}
|
||||
|
||||
35
src/modules/zapniVypniSe.ts
Normal file
35
src/modules/zapniVypniSe.ts
Normal file
@ -0,0 +1,35 @@
|
||||
import { getVoiceConnections } from "@discordjs/voice";
|
||||
import { Message } from "discord.js";
|
||||
import { emouty } from "../utils/emotes";
|
||||
import { Modul } from "../utils/types";
|
||||
import { prefix } from "../utils/utils";
|
||||
|
||||
let spim = false;
|
||||
|
||||
const exp: Modul = {
|
||||
super_on_messageCreate: {
|
||||
pos: 0,
|
||||
fun: (mes: Message) => {
|
||||
const cont = mes.content.toLowerCase();
|
||||
if (cont == `${prefix} zapni se`) {
|
||||
if (spim) {
|
||||
spim = false;
|
||||
mes.client.user?.setStatus("online");
|
||||
mes.channel.send("dobré ráno magoří");
|
||||
}
|
||||
else mes.channel.send("tak jsi kokot?");
|
||||
} else if (!spim) {
|
||||
if (cont == `${prefix} vypni se`) {
|
||||
mes.react(emouty.purfieRIP);
|
||||
getVoiceConnections().forEach(con => con.destroy());
|
||||
mes.client.user?.setStatus("invisible");
|
||||
spim = true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = exp;
|
||||
@ -2,13 +2,15 @@
|
||||
|
||||
import { getVoiceConnections } from "@discordjs/voice";
|
||||
import { Client, Message, Presence, TextChannel, User } from "discord.js";
|
||||
import { emouty } from "../utils/emotes";
|
||||
import { createServer } from "http";
|
||||
import { Modul } from "../utils/types";
|
||||
import fetch from "node-fetch";
|
||||
import { formatCas, log, prefix, sendDM } from "../utils/utils";
|
||||
import { formatCas, log, sendDM } from "../utils/utils";
|
||||
import { emouty } from "../utils/emotes";
|
||||
|
||||
let spim = false;
|
||||
const zpravy = new Map<string, number[]>();
|
||||
const dobaOmezení = 20_000;
|
||||
let client: Client;
|
||||
|
||||
const exp: Modul = {
|
||||
more_komandy: {
|
||||
@ -32,7 +34,6 @@ const exp: Modul = {
|
||||
}
|
||||
|
||||
getVoiceConnections().forEach(con => con.destroy());
|
||||
const client: Client = module.exports.client;
|
||||
client.user?.setStatus("invisible");
|
||||
mes.react("👋")
|
||||
.then(() => process.exit());
|
||||
@ -48,30 +49,41 @@ const exp: Modul = {
|
||||
},
|
||||
|
||||
super_on_messageCreate: {
|
||||
pos: 0,
|
||||
pos: 1,
|
||||
fun: (mes: Message) => {
|
||||
const cont = mes.content.toLowerCase();
|
||||
if (cont == `${prefix} zapni se`) {
|
||||
if (spim) {
|
||||
spim = false;
|
||||
mes.client.user?.setStatus("online");
|
||||
mes.channel.send("dobré ráno magoří");
|
||||
}
|
||||
else mes.channel.send("tak jsi kokot?");
|
||||
} else if (!spim) {
|
||||
if (cont == `${prefix} vypni se`) {
|
||||
mes.react(emouty.purfieRIP);
|
||||
getVoiceConnections().forEach(con => con.destroy());
|
||||
mes.client.user?.setStatus("invisible");
|
||||
spim = true;
|
||||
}
|
||||
else return false;
|
||||
const ted = Date.now();
|
||||
const timestampy = zpravy.get(mes.content) || [];
|
||||
|
||||
const aktualni = timestampy.filter(timestamp => ted - timestamp < dobaOmezení);
|
||||
aktualni.push(ted);
|
||||
zpravy.set(mes.content, aktualni);
|
||||
|
||||
const pocet = aktualni.length;
|
||||
if (pocet < 7) return false;
|
||||
|
||||
(async () => {
|
||||
if (mes.author.id == client.user?.id) return;
|
||||
const adminRole = mes.member?.roles.cache.find(r => r.name == "admin");
|
||||
if (adminRole) {
|
||||
await mes.member?.roles.remove(adminRole).catch(e => log("nejde odebrat admin", e));
|
||||
}
|
||||
|
||||
await mes.member?.timeout(60_000, "spamer zasranej").catch(e => log("nejde timeoutnout zmrd", e));
|
||||
if (adminRole) setTimeout(() => {
|
||||
mes.member?.roles.add(adminRole);
|
||||
}, 60_000);
|
||||
mes.channel.send(emouty.fu);
|
||||
})();
|
||||
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
on_ready: () => {
|
||||
// Nastavení clienta
|
||||
client = module.exports.client;
|
||||
|
||||
// Server na navrhy
|
||||
createServer((req, res) => {
|
||||
res.statusCode = 400;
|
||||
if (req.socket.remoteAddress != "::1") return res.end("di doprdele dyk ne more");
|
||||
@ -80,7 +92,6 @@ const exp: Modul = {
|
||||
const { userID, content } = Object.fromEntries(sp.entries());
|
||||
if (!userID || !content) return res.end("gde mas userID a content????");
|
||||
|
||||
const client: Client = module.exports.client;
|
||||
const user = client.users.cache.get(userID);
|
||||
if (!user) return res.end("takovyho kkta neznam");
|
||||
|
||||
@ -95,6 +106,15 @@ const exp: Modul = {
|
||||
res.end("neco se posralo");
|
||||
});
|
||||
}).listen(1298);
|
||||
|
||||
// Garbage-colector na `zpravy`
|
||||
setInterval(() => {
|
||||
const ted = Date.now();
|
||||
zpravy.forEach((val, key) => {
|
||||
const aktualni = val.filter(timestamp => ted - timestamp < dobaOmezení);
|
||||
if (!aktualni.length) zpravy.delete(key);
|
||||
});
|
||||
}, 60_000);
|
||||
},
|
||||
|
||||
on_userUpdate: (bef: User, aft: User) => {
|
||||
@ -106,8 +126,6 @@ const exp: Modul = {
|
||||
on_userPresenceUpdate: (bef: Presence | null, aft: Presence) => {
|
||||
if (aft.user?.id != "355053867265818635" || bef?.status == "online" || aft.status != "online") return;
|
||||
|
||||
const client = module.exports.client as Client;
|
||||
|
||||
(client.channels.cache.get("555779161067749448") as TextChannel)
|
||||
.send("https://tenor.com/view/pavel-is-online-gif-21604335");
|
||||
}
|
||||
|
||||
@ -10,5 +10,6 @@ export enum emouty {
|
||||
sjeta = "<:sjeta:623216247953424426>",
|
||||
gn = "<:gn:887124590583746590>",
|
||||
lajk = "<:lajk:851556768373932123>",
|
||||
lukiw = "<:lukiw:741057536181928107>"
|
||||
lukiw = "<:lukiw:741057536181928107>",
|
||||
fu = "<:FU:674649887090147355>"
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user