Merge pull request 'alias-args' (#1) from alias-args into main
Reviewed-on: #1
This commit is contained in:
commit
426c1ab7fc
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");
|
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!;
|
const akce = cmd.run ?? cmd.slashRun!;
|
||||||
|
|
||||||
if (typeof akce == "string") {
|
if (typeof akce == "string") {
|
||||||
const res = renderMessage(akce, arg?.split(" ") || []);
|
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);
|
return mesOrInt.reply(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,21 +291,25 @@ client.on("messageCreate", async mes => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const argString = args.join(" ");
|
const komandBez = oddiakritikovat(komandSDiakritikou).toLowerCase();
|
||||||
const komandBezDiakritiky = oddiakritikovat(komandSDiakritikou).toLowerCase();
|
// const cmdName = client.aliasy[komandBez] ?? komandBez;
|
||||||
const cmdName = client.aliasy[komandBezDiakritiky] ?? komandBezDiakritiky;
|
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;
|
if (await runEvent("messageCreate", [mes, cmdName])) return;
|
||||||
|
|
||||||
const komand = client.komandy[cmdName];
|
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.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) {
|
if (komand) return void runKomand(mes, komand, cmdName, celArgs);
|
||||||
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?
|
// neměl jsi na mysli?
|
||||||
const slova: string[] = [];
|
const slova: string[] = [];
|
||||||
@ -328,20 +326,18 @@ client.on("messageCreate", async mes => {
|
|||||||
channel: mes.channel,
|
channel: mes.channel,
|
||||||
zpravec: { content: "nemnel sy na misli:" },
|
zpravec: { content: "nemnel sy na misli:" },
|
||||||
onCollect: (i, lookupId, radek) => {
|
onCollect: (i, lookupId, radek) => {
|
||||||
if (i.member?.user.id != mes.author.id)
|
if (i.member?.user.id != mes.author.id) return;
|
||||||
return i.reply({ content: emouty.fu, ephemeral: true });
|
|
||||||
|
|
||||||
const komand = nabidka[lookupId];
|
const komand = nabidka[lookupId];
|
||||||
const cmdName = client.aliasy[komand] ?? komand;
|
const cmdName = client.aliasy[komand] ?? komand;
|
||||||
const cmd = client.komandy[cmdName];
|
const cmd = client.komandy[cmdName];
|
||||||
radek.components.forEach((btn, i) => btn.setDisabled() && (i == lookupId && btn.setStyle(ButtonStyle.Success)));
|
radek.components.forEach((btn, i) => btn.setDisabled() && (i == lookupId && btn.setStyle(ButtonStyle.Success)));
|
||||||
i.update({ content: `ok vole ${emouty.d3k}`, components: [radek] });
|
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"
|
konecnaZprava: "pozde"
|
||||||
});
|
});
|
||||||
|
|||||||
@ -9,7 +9,7 @@ const cesta = `${join(__dirname, "../../res/")}custom`;
|
|||||||
const helpServer: HelpServer = require("../utils/helpServer");
|
const helpServer: HelpServer = require("../utils/helpServer");
|
||||||
let zakladniKomandy: SRecord<Komand>;
|
let zakladniKomandy: SRecord<Komand>;
|
||||||
let zakladniAliasy: SRecord<string>;
|
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; }>;
|
let customAliasy: SRecord<{ cmd: string; owner: string; }>;
|
||||||
|
|
||||||
function spojit() {
|
function spojit() {
|
||||||
@ -17,7 +17,7 @@ function spojit() {
|
|||||||
const cKomandyForExport: KomandNaExport[] = [];
|
const cKomandyForExport: KomandNaExport[] = [];
|
||||||
|
|
||||||
for (const komand in customKomandy) {
|
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 });
|
cKomandyForExport.push({ name: komand, custom: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,34 +109,14 @@ const exp: Modul = {
|
|||||||
jmeno = customKomandy[args[1]] ? args[1] : customAliasy[args[1]].cmd;
|
jmeno = customKomandy[args[1]] ? args[1] : customAliasy[args[1]].cmd;
|
||||||
} else jmeno = zakladniKomandy[args[1]] ? args[1] : zakladniAliasy[args[1]];
|
} 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 };
|
customAliasy[args[0]] = { cmd: jmeno, owner: mes.author.id };
|
||||||
save();
|
save();
|
||||||
return "jo";
|
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: {
|
zapomen: {
|
||||||
arg: "název komandu nebo aliasu",
|
arg: "název komandu nebo aliasu",
|
||||||
run: (mes, arg) => {
|
run: (mes, arg) => {
|
||||||
|
|||||||
@ -9,9 +9,12 @@ createServer((_, res) => {
|
|||||||
const vsechnyKomandy: KomandNaExport[] = JSON.parse(JSON.stringify([...komandy, ...customKomandy]));
|
const vsechnyKomandy: KomandNaExport[] = JSON.parse(JSON.stringify([...komandy, ...customKomandy]));
|
||||||
|
|
||||||
for (const key in customAliasy) {
|
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;
|
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);
|
vsechnyKomandy.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
||||||
|
|||||||
@ -52,7 +52,6 @@ export type Komand = {
|
|||||||
cd?: number;
|
cd?: number;
|
||||||
DMUnsafe?: true;
|
DMUnsafe?: true;
|
||||||
premium?: true;
|
premium?: true;
|
||||||
bind?: true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface Spinkackar {
|
export interface Spinkackar {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user