added support for aliases to custom commands
This commit is contained in:
parent
a40e9799e7
commit
e5aa5847e8
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "denim_3001",
|
"name": "denim_3001",
|
||||||
"version": "3001.41.2",
|
"version": "3001.42.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "denim_3001",
|
"name": "denim_3001",
|
||||||
"version": "3001.41.2",
|
"version": "3001.42.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discordjs/voice": "^0.11.0",
|
"@discordjs/voice": "^0.11.0",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "denim_3001",
|
"name": "denim_3001",
|
||||||
"version": "3001.41.2",
|
"version": "3001.42.0",
|
||||||
"description": "Toto je velmi kvalitní bot.",
|
"description": "Toto je velmi kvalitní bot.",
|
||||||
"repository": {
|
"repository": {
|
||||||
"url": "https://github.com/Histmy/Denim-Bot/"
|
"url": "https://github.com/Histmy/Denim-Bot/"
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import { readFileSync, writeFileSync } from "fs";
|
|||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
import { oddiakritikovat } from "./utils";
|
import { oddiakritikovat } from "./utils";
|
||||||
|
|
||||||
|
const ex = module.exports;
|
||||||
const cesta = join(__dirname, "../../res/");
|
const cesta = join(__dirname, "../../res/");
|
||||||
const customKomandi: SRecord<{ text: string; owner: string; }> = JSON.parse(readFileSync(`${cesta}komandi.json`).toString());
|
const customKomandi: SRecord<{ text: string; owner: string; }> = JSON.parse(readFileSync(`${cesta}komandi.json`).toString());
|
||||||
const customAliasy: SRecord<{ cmd: string; owner: string; }> = JSON.parse(readFileSync(`${cesta}aliasi.json`).toString());
|
const customAliasy: SRecord<{ cmd: string; owner: string; }> = JSON.parse(readFileSync(`${cesta}aliasi.json`).toString());
|
||||||
@ -42,7 +43,7 @@ export const naucse: RunFunkce = (mes, arg) => {
|
|||||||
if (args.length == 1) return "a co bich nato mnel rict????";
|
if (args.length == 1) return "a co bich nato mnel rict????";
|
||||||
|
|
||||||
args[0] = oddiakritikovat(args[0].toLowerCase());
|
args[0] = oddiakritikovat(args[0].toLowerCase());
|
||||||
if (module.exports.realKomandy[args[0]] || customKomandi[args[0]] || module.exports.realAliasy[args[0]] || customAliasy[args[0]]) return "tuten komand uz ale egzistuje";
|
if (ex.realKomandy[args[0]] || customKomandi[args[0]] || ex.realAliasy[args[0]] || customAliasy[args[0]]) return "tuten komand uz ale egzistuje";
|
||||||
|
|
||||||
customKomandi[args[0]] = { text: args.splice(1).join(" "), owner: mes.author.id };
|
customKomandi[args[0]] = { text: args.splice(1).join(" "), owner: mes.author.id };
|
||||||
save();
|
save();
|
||||||
@ -52,7 +53,7 @@ export const naucse: RunFunkce = (mes, arg) => {
|
|||||||
export const zapomen: RunFunkce = (mes, arg) => {
|
export const zapomen: RunFunkce = (mes, arg) => {
|
||||||
const com = oddiakritikovat(arg.toLowerCase());
|
const com = oddiakritikovat(arg.toLowerCase());
|
||||||
|
|
||||||
if (module.exports.realKomandy[com]) return "tuten komand se neda smazat ti smazko";
|
if (ex.realKomandy[com]) return "tuten komand se neda smazat ti smazko";
|
||||||
const cmd = customKomandi[com];
|
const cmd = customKomandi[com];
|
||||||
if (!cmd) return `komand "${arg}" neznam`;
|
if (!cmd) return `komand "${arg}" neznam`;
|
||||||
if (cmd.owner != mes.author.id) return "tuto ael neni tvuj komand toxikale zkurvenej";
|
if (cmd.owner != mes.author.id) return "tuto ael neni tvuj komand toxikale zkurvenej";
|
||||||
@ -76,10 +77,15 @@ export const naucsealias: RunFunkce = (mes, arg) => {
|
|||||||
|
|
||||||
if (args.length == 0) return "a co se mam jako naucit";
|
if (args.length == 0) return "a co se mam jako naucit";
|
||||||
if (args.length == 1) return "a co to ma znamenat????";
|
if (args.length == 1) return "a co to ma znamenat????";
|
||||||
if (module.exports.realKomandy[args[0]] || customKomandi[args[0]] || module.exports.realAliasy[args[0]] || customAliasy[args[0]]) return "tuto uz ale egzistuje";
|
if (ex.realKomandy[args[0]] || customKomandi[args[0]] || ex.realAliasy[args[0]] || customAliasy[args[0]]) return "tuto uz ale egzistuje";
|
||||||
if (!module.exports.realKomandy[args[1]] && !module.exports.realAliasy[args[1]]) return `nejze "${arg}" neni realnej komand ani alias`;
|
|
||||||
|
let jmeno: string;
|
||||||
|
if (!ex.realKomandy[args[1]] && !ex.realAliasy[args[1]]) {
|
||||||
|
if (!customKomandi[args[1]] && !customAliasy[args[1]]) return `nejze "${args[1]}" neni realnej ani vlastni komand ani alias`;
|
||||||
|
jmeno = customKomandi[args[1]] ? args[1] : customAliasy[args[1]].cmd;
|
||||||
|
}
|
||||||
|
else jmeno = (ex.realKomandy[args[1]]) ? args[1] : ex.realAliasy[args[1]];
|
||||||
|
|
||||||
const jmeno = (module.exports.realKomandy[args[1]]) ? args[1] : module.exports.realAliasy[args[1]];
|
|
||||||
customAliasy[args[0]] = { cmd: jmeno, owner: mes.author.id };
|
customAliasy[args[0]] = { cmd: jmeno, owner: mes.author.id };
|
||||||
save();
|
save();
|
||||||
return "jo";
|
return "jo";
|
||||||
@ -88,7 +94,7 @@ export const naucsealias: RunFunkce = (mes, arg) => {
|
|||||||
export const zapomenalias: RunFunkce = (mes, arg) => {
|
export const zapomenalias: RunFunkce = (mes, arg) => {
|
||||||
const al = oddiakritikovat(arg.toLowerCase());
|
const al = oddiakritikovat(arg.toLowerCase());
|
||||||
|
|
||||||
if (module.exports.realAliasy[al]) return "tutn alijas se ale neda smazat ty smazenice";
|
if (ex.realAliasy[al]) return "tutn alijas se ale neda smazat ty smazenice";
|
||||||
const als = customAliasy[al];
|
const als = customAliasy[al];
|
||||||
if (!als) return `alijas "${al}" neznam`;
|
if (!als) return `alijas "${al}" neznam`;
|
||||||
if (als.owner != mes.author.id) return "tuto ael neni tvuj alijas toxikale zkurvenej";
|
if (als.owner != mes.author.id) return "tuto ael neni tvuj alijas toxikale zkurvenej";
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user