alias-args #1
40
src/app.ts
40
src/app.ts
@ -253,17 +253,11 @@ 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 (jeMes) return mesOrInt.channel.send(res);
|
||||
if (mesOrInt instanceof Message) return mesOrInt.channel.send(res);
|
||||
return mesOrInt.reply(res);
|
||||
}
|
||||
|
||||
@ -297,21 +291,25 @@ client.on("messageCreate", async mes => {
|
||||
return;
|
||||
}
|
||||
|
||||
const argString = args.join(" ");
|
||||
const komandBezDiakritiky = oddiakritikovat(komandSDiakritikou).toLowerCase();
|
||||
const cmdName = client.aliasy[komandBezDiakritiky] ?? komandBezDiakritiky;
|
||||
const komandBez = oddiakritikovat(komandSDiakritikou).toLowerCase();
|
||||
// const cmdName = client.aliasy[komandBez] ?? komandBez;
|
||||
let cmdName = komandBez;
|
||||
|
||||
const aliasCelej = client.aliasy[komandBez];
|
||||
if (aliasCelej) {
|
||||
const [aliasCmdName, ...aliasArgs] = aliasCelej.split(" ");
|
||||
cmdName = aliasCmdName;
|
||||
args.unshift(...aliasArgs);
|
||||
}
|
||||
|
||||
const celArgs = args.join(" ");
|
||||
|
||||
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 (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);
|
||||
if (komand) return void runKomand(mes, komand, cmdName, celArgs);
|
||||
|
||||
// neměl jsi na mysli?
|
||||
const slova: string[] = [];
|
||||
@ -328,20 +326,18 @@ 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 i.reply({ content: emouty.fu, ephemeral: true });
|
||||
|
||||
if (i.member?.user.id != mes.author.id) return;
|
||||
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 mes.channel.send("bohuzel negdo sy ze mi dela prel");
|
||||
if (!cmd) return void mes.channel.send("bohuzel negdo sy ze mi dela prel");
|
||||
|
||||
if (mes.channel.type == ChannelType.DM && cmd?.DMUnsafe) return mes.channel.send("tuten komand bohuzel v sz nefunkuje");
|
||||
if (mes.channel.type == ChannelType.DM && cmd?.DMUnsafe) return void mes.channel.send("tuten komand bohuzel v sz nefunkuje");
|
||||
|
||||
runKomand(mes, cmd, cmdName, argString);
|
||||
runKomand(mes, cmd, cmdName, celArgs);
|
||||
},
|
||||
konecnaZprava: "pozde"
|
||||
});
|
||||
|
||||
@ -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; bind?: true; }>;
|
||||
let customKomandy: SRecord<{ text: string; owner: string; }>;
|
||||
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, bind: customKomandy[komand].bind };
|
||||
cKomandyAsKomand[komand] = { run: customKomandy[komand].text };
|
||||
cKomandyForExport.push({ name: komand, custom: true });
|
||||
}
|
||||
|
||||
@ -109,34 +109,14 @@ const exp: Modul = {
|
||||
jmeno = customKomandy[args[1]] ? args[1] : customAliasy[args[1]].cmd;
|
||||
} else jmeno = zakladniKomandy[args[1]] ? args[1] : zakladniAliasy[args[1]];
|
||||
|
||||
if (args.length > 2) jmeno += " " + args.slice(2).join(" ");
|
||||
|
||||
customAliasy[args[0]] = { cmd: jmeno, owner: mes.author.id };
|
||||
save();
|
||||
return "jo";
|
||||
}
|
||||
},
|
||||
|
||||
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) => {
|
||||
|
||||
@ -9,9 +9,12 @@ createServer((_, res) => {
|
||||
const vsechnyKomandy: KomandNaExport[] = JSON.parse(JSON.stringify([...komandy, ...customKomandy]));
|
||||
|
||||
for (const key in customAliasy) {
|
||||
const i = vsechnyKomandy.findIndex(komand => komand.name == customAliasy[key]);
|
||||
const aliasParts = customAliasy[key].split(" ");
|
||||
const aliasCmd = aliasParts[0];
|
||||
|
||||
const i = vsechnyKomandy.findIndex(komand => komand.name == aliasCmd);
|
||||
if (i == -1) continue;
|
||||
(vsechnyKomandy[i].als ??= []).push(key);
|
||||
(vsechnyKomandy[i].als ??= []).push(aliasParts.length == 1 ? key : `${key} [${aliasParts.slice(1).join(" ")}]`);
|
||||
}
|
||||
|
||||
vsechnyKomandy.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
||||
|
||||
@ -52,7 +52,6 @@ export type Komand = {
|
||||
cd?: number;
|
||||
DMUnsafe?: true;
|
||||
premium?: true;
|
||||
bind?: true;
|
||||
};
|
||||
|
||||
export interface Spinkackar {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user