DENIM- LIDI!!!
This commit is contained in:
parent
0c2e64cf39
commit
0a700e6f94
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,3 +4,4 @@ out
|
||||
res/customKomandy.json
|
||||
res/customAliasy.json
|
||||
zaznamy.dlog
|
||||
zvuky/priVstupu
|
||||
|
||||
@ -4,6 +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";
|
||||
|
||||
const ints = GatewayIntentBits;
|
||||
const client = new Client({
|
||||
@ -87,7 +88,7 @@ readdirSync(modulFolder).forEach(soubor => {
|
||||
client.komandy[cmdName] = { run: value };
|
||||
toCoExportuju.arg = getFirstArg(value);
|
||||
} else {
|
||||
client.komandy[cmdName] = { run: value.run, slashRun: value.slashRun, cd: value.cd, DMUnsafe: value.DMUnsafe };
|
||||
client.komandy[cmdName] = { run: value.run, slashRun: value.slashRun, cd: value.cd, DMUnsafe: value.DMUnsafe, premium: value.premium };
|
||||
Object.assign(toCoExportuju, { als: value.als, arg: value.arg ?? getFirstArg(value.run) });
|
||||
hide = !!value.hidden;
|
||||
value.als?.forEach(al => client.aliasy[al] = cmdName);
|
||||
@ -231,6 +232,10 @@ async function runKomand(mesOrInt: Message | CommandInteraction, cmd: Komand, cm
|
||||
if (zbyva) return void mesOrInt.channel.send(`si kkt vole maz kuldan jeste ${formatCas(zbyva)}`);
|
||||
}
|
||||
|
||||
if (cmd.premium && !lidiCoMajDenimPremium.includes((mesOrInt instanceof Message) ? mesOrInt.author.id : mesOrInt.member?.user.id || "")) {
|
||||
return void mesOrInt.channel?.send("sorka bracho tuto je koamnd jenom pro curaki co platy");
|
||||
}
|
||||
|
||||
const akce = jeMes
|
||||
? cmd.run
|
||||
: cmd.slashRun!;
|
||||
|
||||
58
src/modules/denim-Dobroty.ts
Normal file
58
src/modules/denim-Dobroty.ts
Normal file
@ -0,0 +1,58 @@
|
||||
import { getVoiceConnection } from "@discordjs/voice";
|
||||
import { Modul } from "../utils/types";
|
||||
import { rmSync, readdirSync, writeFileSync } from "fs";
|
||||
import { join } from "path";
|
||||
import { Priority, novejPlay } from "../utils/voice";
|
||||
import { lidiCoMajDenimPremium, semMiDejClienta } from "../utils/denim-Spravce";
|
||||
|
||||
// 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"];
|
||||
|
||||
const exp: Modul = {
|
||||
more_komandy: {
|
||||
|
||||
zmenitvstupnizvuk: {
|
||||
premium: true,
|
||||
run: async mes => {
|
||||
|
||||
const soubor = mes.attachments.first();
|
||||
|
||||
if (!soubor) return "tak pico ael na co";
|
||||
|
||||
if (!formaty.includes(soubor.name.slice(-3))) return "tuten format nechcy";
|
||||
|
||||
const zaklad = `${kmenovaCesta}/${mes.author.id}`;
|
||||
for (const format of formaty) {
|
||||
try {
|
||||
rmSync(`${zaklad}.${format}`);
|
||||
} catch { }
|
||||
}
|
||||
|
||||
const odpoved = await fetch(soubor.url).then(r => r.arrayBuffer());
|
||||
writeFileSync(`${zaklad}.${soubor.name.slice(-3)}`, new DataView(odpoved));
|
||||
|
||||
return "ej tot am";
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
on_voiceStateUpdate: (bef, aft) => {
|
||||
const conn = getVoiceConnection(aft.guild.id);
|
||||
|
||||
// Jestli vůbec zvuk zahrát
|
||||
if (!conn || conn.joinConfig.channelId != aft.channelId || !lidiCoMajDenimPremium.includes(aft.id) || !aft.channelId || bef.channelId == aft.channelId) return;
|
||||
|
||||
// Najít zvuk k přehrání
|
||||
for (const soubor of readdirSync(kmenovaCesta)) {
|
||||
if (!soubor.startsWith(aft.id)) continue;
|
||||
|
||||
novejPlay(aft.guild.id, `${kmenovaCesta}/${soubor}`, Priority.Time);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = exp;
|
||||
40
src/utils/denim-Spravce.ts
Normal file
40
src/utils/denim-Spravce.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import fetch from "node-fetch";
|
||||
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 let semMiDejClienta: { client?: Client; } = {};
|
||||
|
||||
export let lidiCoMajDenimPremium: string[] = [];
|
||||
|
||||
const subscriptionsSchema = array(string());
|
||||
|
||||
function naplanovat() {
|
||||
const datum = new Date();
|
||||
|
||||
datum.setHours(24);
|
||||
datum.setMinutes(1);
|
||||
datum.setSeconds(0);
|
||||
|
||||
setTimeout(sync, Number(datum) - Date.now());
|
||||
}
|
||||
|
||||
async function sync() {
|
||||
log("synchronizace denim-");
|
||||
const res = await fetch("https://util.deadfish.cz/denim+/subscriptions.json")
|
||||
.then(r => r.json())
|
||||
.catch(log);
|
||||
|
||||
const result = safeParse(subscriptionsSchema, res);
|
||||
|
||||
if (result.success) {
|
||||
lidiCoMajDenimPremium = result.output;
|
||||
} else {
|
||||
adminLog(semMiDejClienta.client!, "nepovedlo se akutalizovat vlastnitele denim-");
|
||||
}
|
||||
|
||||
naplanovat();
|
||||
}
|
||||
|
||||
sync();
|
||||
@ -17,6 +17,7 @@ export type KomandRaw = BaseKomandProps &
|
||||
cd?: number;
|
||||
hidden?: true;
|
||||
DMUnsafe?: true;
|
||||
premium?: true;
|
||||
};
|
||||
|
||||
|
||||
@ -43,6 +44,7 @@ export type Komand = {
|
||||
slashRun?: InteractionRunFunkce;
|
||||
cd?: number;
|
||||
DMUnsafe?: true;
|
||||
premium?: true;
|
||||
};
|
||||
|
||||
export interface Spinkackar {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user