max 13 vteřin zvuk při příchodu
This commit is contained in:
parent
0a786106bd
commit
61f67a86f0
1335
package-lock.json
generated
1335
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "denim_3001",
|
||||
"version": "3001.54.0",
|
||||
"version": "3001.54.1",
|
||||
"description": "Toto je velmi kvalitní bot.",
|
||||
"repository": {
|
||||
"url": "https://github.com/Histmy/Denim-Bot/"
|
||||
@ -15,7 +15,7 @@
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@discordjs/voice": "^0.16.0",
|
||||
"discord.js": "^14.11.0",
|
||||
"discord.js": "^14.13.0",
|
||||
"js-levenshtein": "^1.1.6",
|
||||
"mysql": "^2.18.1",
|
||||
"node-fetch": "^2.6.1",
|
||||
@ -26,10 +26,10 @@
|
||||
"valibot": "^0.13.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.3",
|
||||
"@types/jest": "^29.5.4",
|
||||
"@types/js-levenshtein": "^1.1.1",
|
||||
"@types/mysql": "^2.15.21",
|
||||
"@types/node-fetch": "^2.6.4",
|
||||
"jest": "^29.6.1"
|
||||
"jest": "^29.6.4"
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ import { CUser, KomandNaExport, Komand, ListenerFunkce, Modul, SRecord, SuperLis
|
||||
import { adminLog, formatCas, oddiakritikovat, log, rand, prefix, nabidni } from "./utils/utils.js";
|
||||
import levenshtein from "js-levenshtein";
|
||||
import { emouty } from "./utils/emotes";
|
||||
import { lidiCoMajDenimPremium } from "./utils/denim-Spravce";
|
||||
import { lidiCoMajDenimPremium, setClient } from "./utils/denim-Spravce";
|
||||
|
||||
const ints = GatewayIntentBits;
|
||||
const client = new Client({
|
||||
@ -21,6 +21,7 @@ const helpServer: HelpServer = require("./utils/helpServer");
|
||||
|
||||
client.komandy = {};
|
||||
client.aliasy = {};
|
||||
setClient(client);
|
||||
|
||||
function getFirstArg(fn: KomandRaw["run"]) {
|
||||
if (typeof fn != "function") return;
|
||||
|
||||
@ -1,16 +1,22 @@
|
||||
import { getVoiceConnection } from "@discordjs/voice";
|
||||
import { Modul } from "../utils/types";
|
||||
import { rmSync, readdirSync, writeFileSync } from "fs";
|
||||
import { renameSync, rmSync, readdirSync, writeFileSync } from "fs";
|
||||
import { join } from "path";
|
||||
import { Priority, novejPlay } from "../utils/voice";
|
||||
import { lidiCoMajDenimPremium, semMiDejClienta } from "../utils/denim-Spravce";
|
||||
import { lidiCoMajDenimPremium } from "../utils/denim-Spravce";
|
||||
import fetch from "node-fetch";
|
||||
import { exec } from "child_process";
|
||||
import { log } from "../utils/utils";
|
||||
|
||||
// Extrémní fekál, jestli má někdo lepsí nápad, sem s ním
|
||||
semMiDejClienta.client = module.exports.client;
|
||||
const kmenovaCesta = join(__dirname, `../../zvuky/priVstupu`);
|
||||
const formaty = ["mp3", "wav", "ogg"];
|
||||
|
||||
function vymaz(path: string) {
|
||||
try {
|
||||
rmSync(path);
|
||||
} catch { }
|
||||
}
|
||||
|
||||
const exp: Modul = {
|
||||
more_komandy: {
|
||||
|
||||
@ -25,17 +31,40 @@ const exp: Modul = {
|
||||
if (!formaty.includes(soubor.name.slice(-3))) return "tuten format nechcy";
|
||||
if (soubor.size > 2e6) return "min nes dva mebagajyt pls";
|
||||
|
||||
const zaklad = `${kmenovaCesta}/${mes.author.id}`;
|
||||
for (const format of formaty) {
|
||||
try {
|
||||
rmSync(`${zaklad}.${format}`);
|
||||
} catch { }
|
||||
}
|
||||
// Stahnout dočasně
|
||||
const typ = soubor.name.slice(-3);
|
||||
const docasnaCesta = `${kmenovaCesta}/temp${Math.round(Math.random() * 1000)}.${typ}`;
|
||||
|
||||
const odpoved = await fetch(soubor.url).then(r => r.arrayBuffer());
|
||||
writeFileSync(`${zaklad}.${soubor.name.slice(-3)}`, new DataView(odpoved));
|
||||
writeFileSync(docasnaCesta, new DataView(odpoved));
|
||||
|
||||
return "ej tot am";
|
||||
// Zjistit running-time
|
||||
exec(`ffprobe -i ${docasnaCesta} -show_entries format=duration -v quiet -of csv="p=0"`, (error, stdout) => {
|
||||
if (error) {
|
||||
log("chyba pri ffprobe", error);
|
||||
|
||||
mes.channel.send("bohuzel chiba");
|
||||
vymaz(docasnaCesta);
|
||||
return;
|
||||
}
|
||||
|
||||
// Maximum
|
||||
if (Number(stdout) > 13) {
|
||||
mes.channel.send("13 se kund maks");
|
||||
vymaz(docasnaCesta);
|
||||
return;
|
||||
}
|
||||
|
||||
// Smazat starej (nevíme formát, tak musíme zkust všechny)
|
||||
const zaklad = `${kmenovaCesta}/${mes.author.id}`;
|
||||
for (const format of formaty) {
|
||||
vymaz(`${zaklad}.${format}`);
|
||||
}
|
||||
|
||||
renameSync(docasnaCesta, `${zaklad}.${typ}`);
|
||||
|
||||
mes.channel.send("ej tot am");
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -3,8 +3,8 @@ import { array, safeParse, string } from "valibot";
|
||||
import { adminLog, log } from "./utils";
|
||||
import { Client } from "discord.js";
|
||||
|
||||
// Extrémní fekál, jestli má někdo lepsí nápad, sem s ním
|
||||
export const semMiDejClienta: { client?: Client; } = {};
|
||||
let client: Client;
|
||||
export const setClient = (clnt: Client) => client = clnt;
|
||||
|
||||
export let lidiCoMajDenimPremium: string[] = [];
|
||||
|
||||
@ -31,7 +31,7 @@ async function sync() {
|
||||
if (result.success) {
|
||||
lidiCoMajDenimPremium = result.output;
|
||||
} else {
|
||||
adminLog(semMiDejClienta.client!, "nepovedlo se akutalizovat vlastnitele denim-");
|
||||
adminLog(client, "nepovedlo se akutalizovat vlastnitele denim-");
|
||||
}
|
||||
|
||||
naplanovat();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user