added fekal bind commands

This commit is contained in:
Histmy 2024-07-12 18:09:07 +02:00
parent 027f1516b1
commit 1cf0946bfd
Signed by: Histmy
GPG Key ID: AC2E43C463D8F329
3 changed files with 47 additions and 11 deletions

View File

@ -253,11 +253,17 @@ async function runKomand(mesOrInt: Message | CommandInteraction, cmd: Komand, cm
return mesOrInt.channel?.send("sorka bracho tuto je koamnd jenom pro curaki co platy");
}
// log(cmd);
if (cmd.bind) {
return (mesOrInt as Message).reply(`${prefix} ${cmd.run}`);
}
const akce = cmd.run ?? cmd.slashRun!;
if (typeof akce == "string") {
const res = renderMessage(akce, arg?.split(" ") || []);
if (mesOrInt instanceof Message) return mesOrInt.channel.send(res);
if (jeMes) return mesOrInt.channel.send(res);
return mesOrInt.reply(res);
}
@ -291,16 +297,21 @@ client.on("messageCreate", async mes => {
return;
}
const celArgs = args.join(" ");
const komandBez = oddiakritikovat(komandSDiakritikou).toLowerCase();
const cmdName = client.aliasy[komandBez] ?? komandBez;
const argString = args.join(" ");
const komandBezDiakritiky = oddiakritikovat(komandSDiakritikou).toLowerCase();
const cmdName = client.aliasy[komandBezDiakritiky] ?? komandBezDiakritiky;
if (await runEvent("messageCreate", [mes, cmdName])) return;
const komand = client.komandy[cmdName];
if (mes.channel.type == ChannelType.DM && komand?.DMUnsafe) return void mes.channel.send("tuten komand bohuzel v sz nefunkuje");
if (komand) return void runKomand(mes, komand, cmdName, celArgs);
if (mes.author.id == client.user!.id && mes.reference) {
await mes.channel.messages.fetch(mes.reference.messageId!);
mes.author = (await mes.channel.messages.fetch(mes.reference.messageId!)).author;
}
if (komand) return void runKomand(mes, komand, cmdName, argString);
// neměl jsi na mysli?
const slova: string[] = [];
@ -317,18 +328,20 @@ client.on("messageCreate", async mes => {
channel: mes.channel,
zpravec: { content: "nemnel sy na misli:" },
onCollect: (i, lookupId, radek) => {
if (i.member?.user.id != mes.author.id) return;
if (i.member?.user.id != mes.author.id)
return i.reply({ content: emouty.fu, ephemeral: true });
const komand = nabidka[lookupId];
const cmdName = client.aliasy[komand] ?? komand;
const cmd = client.komandy[cmdName];
radek.components.forEach((btn, i) => btn.setDisabled() && (i == lookupId && btn.setStyle(ButtonStyle.Success)));
i.update({ content: `ok vole ${emouty.d3k}`, components: [radek] });
if (!cmd) return void mes.channel.send("bohuzel negdo sy ze mi dela prel");
if (!cmd) return mes.channel.send("bohuzel negdo sy ze mi dela prel");
if (mes.channel.type == ChannelType.DM && cmd?.DMUnsafe) return void mes.channel.send("tuten komand bohuzel v sz nefunkuje");
if (mes.channel.type == ChannelType.DM && cmd?.DMUnsafe) return mes.channel.send("tuten komand bohuzel v sz nefunkuje");
runKomand(mes, cmd, cmdName, celArgs);
runKomand(mes, cmd, cmdName, argString);
},
konecnaZprava: "pozde"
});

View File

@ -9,7 +9,7 @@ const cesta = `${join(__dirname, "../../res/")}custom`;
const helpServer: HelpServer = require("../utils/helpServer");
let zakladniKomandy: SRecord<Komand>;
let zakladniAliasy: SRecord<string>;
let customKomandy: SRecord<{ text: string; owner: string; }>;
let customKomandy: SRecord<{ text: string; owner: string; bind?: true; }>;
let customAliasy: SRecord<{ cmd: string; owner: string; }>;
function spojit() {
@ -17,7 +17,7 @@ function spojit() {
const cKomandyForExport: KomandNaExport[] = [];
for (const komand in customKomandy) {
cKomandyAsKomand[komand] = { run: customKomandy[komand].text };
cKomandyAsKomand[komand] = { run: customKomandy[komand].text, bind: customKomandy[komand].bind };
cKomandyForExport.push({ name: komand, custom: true });
}
@ -115,6 +115,28 @@ const exp: Modul = {
}
},
naucsebind: {
arg: "<název nového bindu> <název existujícího komandu nebo aliasu> <text nového komandu>",
als: ["naucseb"],
run: (mes, arg) => {
const args = arg.split(/\s/).filter(v => v != "").map(e => oddiakritikovat(e).toLowerCase());
if (args.length == 0) return "a co se mam jako naucit";
if (args.length == 1) return "na jakej koamnd to ma bit????";
if (zakladniKomandy[args[0]] || customKomandy[args[0]]) return "tuto uz je ale komand";
if (zakladniAliasy[args[0]] || customAliasy[args[0]]) return "tuto uz je ale alijas";
if (!(zakladniKomandy[args[1]] || zakladniAliasy[args[1]] || customKomandy[args[1]] || customAliasy[args[1]]))
return `nejze "${args[1]}" neni realnej ani vlastni komand ani alias`;
customKomandy[args[0]] = { text: args.splice(1).join(" "), owner: mes.author.id, bind: true };
save();
return "jo";
}
},
zapomen: {
arg: "název komandu nebo aliasu",
run: (mes, arg) => {

View File

@ -52,6 +52,7 @@ export type Komand = {
cd?: number;
DMUnsafe?: true;
premium?: true;
bind?: true;
};
export interface Spinkackar {