Better type defs for OutputRunFunkce and Modul

& added type for module exports
& removed unnecessary function parameters in modules
This commit is contained in:
Histmy 2021-10-28 20:40:26 +02:00
parent 277fb6bcc2
commit feec9bd6ab
12 changed files with 99 additions and 70 deletions

View File

@ -1,6 +1,6 @@
import { Client, Intents } from "discord.js"; import { Client, Intents } from "discord.js";
import { readdirSync } from "fs"; import { readdirSync } from "fs";
import { Komand, ListenerFunkce, Modul, SuperListenerFunkce } from "./utils/types"; import { EventSOn, Komand, ListenerFunkce, Modul, SuperListenerFunkce } from "./utils/types";
import { formatCas, loadEnv, oddiakritikovat } from "./utils/utils.js"; import { formatCas, loadEnv, oddiakritikovat } from "./utils/utils.js";
const ints = Intents.FLAGS; const ints = Intents.FLAGS;
@ -13,7 +13,6 @@ const eventy: Record<string, ListenerFunkce[]> = {};
const superEventy: Record<string, SuperListenerFunkce[]> = {}; const superEventy: Record<string, SuperListenerFunkce[]> = {};
const komandy: Record<string, Komand> = {}; const komandy: Record<string, Komand> = {};
const aliasy: Record<string, string> = {}; const aliasy: Record<string, string> = {};
let spink = false;
const kuldan_log: Record<string, Record<string, number>> = {}; const kuldan_log: Record<string, Record<string, number>> = {};
const runEvent = (name: string, args: any[]) => { const runEvent = (name: string, args: any[]) => {
@ -41,16 +40,17 @@ readdirSync(modulFolder).forEach(soubor => {
ev[groups.h] = []; ev[groups.h] = [];
if (groups.h != "message") client.on(groups.h, (...args) => void runEvent(groups.h, args)); if (groups.h != "message") client.on(groups.h, (...args) => void runEvent(groups.h, args));
} }
const n = modul[name]; const n = modul[name as EventSOn]!;
if (typeof n == "object") { if (typeof n == "object") {
const prev = ev[groups.h][n.pos] as SuperListenerFunkce | undefined; const prev = ev[groups.h][n.pos];
ev[groups.h][n.pos] = n.fun; ev[groups.h][n.pos] = n.fun;
if (prev) ev[groups.h].push(prev); if (prev) ev[groups.h].push(prev);
} }
else ev[groups.h].push(n); else ev[groups.h].push(n);
} else if (name === "more_komandy") { } else if (name === "more_komandy") {
Object.keys(modul[name]).forEach(cmdName => { const n = modul[name]!;
const value = modul[name][cmdName]; Object.keys(n).forEach(cmdName => {
const value = n[cmdName];
if (typeof value !== "object") { if (typeof value !== "object") {
komandy[cmdName] = { run: value }; komandy[cmdName] = { run: value };
} else { } else {

View File

@ -1,36 +1,38 @@
// Komandy, který pošlou jenom celArgs a random hovno // Komandy, který pošlou jenom celArgs a random hovno
import { Message } from "discord.js";
import { emouty } from "../utils/emotes"; import { emouty } from "../utils/emotes";
import { Modul } from "../utils/types";
module.exports = { const exp: Modul = {
more_komandy: { more_komandy: {
rekni: (mes: Message, arg: string) => { rekni: (mes, arg) => {
if (mes.author.bot) return "ne"; if (mes.author.bot) return "ne";
const corict = arg ?? "co mam jako rict"; const corict = arg || `co mam jako rict ${mes.author}`;
mes.delete(); mes.delete();
return corict; return corict;
}, },
clap: (mes: Message, arg: string) => { clap: (mes, arg) => {
mes.delete(); mes.delete();
return `${arg} ${emouty.clap}`; return `${arg} ${emouty.clap}`;
}, },
clap2: (mes: Message, arg: string) => { clap2: (mes, arg) => {
mes.delete(); mes.delete();
return `${emouty.clap2} ${arg}`; return `${emouty.clap2} ${arg}`;
}, },
voliz: (mes: Message, arg: string) => { voliz: (mes, arg) => {
mes.delete(); mes.delete();
return `${emouty.lickL}${arg}${emouty.lickR}`; return `${emouty.lickL}${arg}${emouty.lickR}`;
}, },
pozdrav: (_: any, arg: string) => `zdravim ${arg}`, pozdrav: (_, arg) => `zdravim ${arg}`,
zhejti: (_: any, arg: string) => `${arg} je pycovina zasrana vimrdana`, zhejti: (_, arg) => `${arg} je pycovina zasrana vimrdana`,
uraz: (_: any, arg: string) => `${arg} , u suck` uraz: (_, arg) => `${arg} , u suck`
} }
}; };
module.exports = exp;

View File

@ -3,6 +3,7 @@
import { ActivityType, Message, PresenceStatusData } from "discord.js"; import { ActivityType, Message, PresenceStatusData } from "discord.js";
import { emouty } from "../utils/emotes"; import { emouty } from "../utils/emotes";
import { Modul } from "../utils/types";
const changeStatus = (mes: Message, status: PresenceStatusData) => { const changeStatus = (mes: Message, status: PresenceStatusData) => {
mes.client.user?.setStatus(status); mes.client.user?.setStatus(status);
@ -17,35 +18,35 @@ const changeActivity = (mes: Message, activity: ActivityType | undefined = undef
const ping = /^<@!?\d+>$/; const ping = /^<@!?\d+>$/;
module.exports = { const exp: Modul = {
more_komandy: { more_komandy: {
online: { online: {
als: ["onlajn", "zelenej"], als: ["onlajn", "zelenej"],
run: (mes: Message) => changeStatus(mes, "online") run: (mes) => changeStatus(mes, "online")
}, },
idle: { idle: {
als: ["zlutej", "afk", "idle", "nepritomnej"], als: ["zlutej", "afk", "idle", "nepritomnej"],
run: (mes: Message) => changeStatus(mes, "idle") run: (mes) => changeStatus(mes, "idle")
}, },
dnd: { dnd: {
als: ["nerusit", "cervenej"], als: ["nerusit", "cervenej"],
run: (mes: Message) => changeStatus(mes, "dnd") run: (mes) => changeStatus(mes, "dnd")
}, },
offline: { offline: {
als: ["oflajn", "neviditelnej"], als: ["oflajn", "neviditelnej"],
run: (mes: Message) => changeStatus(mes, "invisible") run: (mes) => changeStatus(mes, "invisible")
}, },
hraj: (mes: Message, arg: string) => changeActivity(mes, "PLAYING", arg), hraj: (mes, arg) => changeActivity(mes, "PLAYING", arg),
sleduj: (mes: Message, arg: string) => changeActivity(mes, "WATCHING", arg), sleduj: (mes, arg) => changeActivity(mes, "WATCHING", arg),
poslouchej: (mes: Message, arg: string) => changeActivity(mes, "LISTENING", arg), poslouchej: (mes, arg) => changeActivity(mes, "LISTENING", arg),
soutez: (mes: Message, arg: string) => changeActivity(mes, "COMPETING", arg), soutez: (mes, arg) => changeActivity(mes, "COMPETING", arg),
nedelej: (mes: Message) => changeActivity(mes), nedelej: (mes) => changeActivity(mes),
fight: { fight: {
als: ["figh", "fajt"], als: ["figh", "fajt"],
run: (mes: Message, arg: string) => { run: (mes, arg) => {
if (!ping.test(arg)) return "tak si kokot ti kokote"; if (!ping.test(arg)) return "tak si kokot ti kokote";
const vyherce = Math.random() < 0.5 ? mes.author : arg; const vyherce = Math.random() < 0.5 ? mes.author : arg;
@ -53,7 +54,7 @@ module.exports = {
} }
}, },
status: (mes: Message, arg: string) => { status: (mes, arg) => {
if (!ping.test(arg)) return "tak si kokot ti kokote"; if (!ping.test(arg)) return "tak si kokot ti kokote";
const uzivatel = mes.mentions.members!.first()!; const uzivatel = mes.mentions.members!.first()!;
@ -80,7 +81,7 @@ module.exports = {
zareaguj: { zareaguj: {
als: ["react"], als: ["react"],
run: async (mes: Message, arg: string) => { run: async (mes, arg) => {
const emouty = arg.match(/<a?:\w{1,32}:\d+>/g); const emouty = arg.match(/<a?:\w{1,32}:\d+>/g);
if (!emouty) return "retard"; if (!emouty) return "retard";
@ -97,7 +98,7 @@ module.exports = {
} }
}, },
odpocitej: (mes: Message) => { odpocitej: (mes) => {
const randomshit = (mes: Message, argument: string[]) => { const randomshit = (mes: Message, argument: string[]) => {
mes.edit(argument[0]); mes.edit(argument[0]);
argument.splice(0, 1); argument.splice(0, 1);
@ -115,3 +116,5 @@ module.exports = {
} }
} }
}; };
module.exports = exp;

View File

@ -1,5 +1,7 @@
// Komandy, který jenom pošlou random hovno a jsou nějakým způsobem ovlivněný RNG // Komandy, který jenom pošlou random hovno a jsou nějakým způsobem ovlivněný RNG
import { Modul } from "../utils/types";
const ftipy: string[] = require("../../res/ftipy.json"); const ftipy: string[] = require("../../res/ftipy.json");
const mista = ["na šroťák", "na vrakoviště", "na smetiště", "do kontejneru", "na skládku", "do kriminálu", "pod most", "do sběru", "do hospody", "do najt klubu", "na folmavu"]; const mista = ["na šroťák", "na vrakoviště", "na smetiště", "do kontejneru", "na skládku", "do kriminálu", "pod most", "do sběru", "do hospody", "do najt klubu", "na folmavu"];
const uz = ["ne", "jeste ne", "jiz brzy", "za chvili", "vubec", "nikdy", "za dlouho", "za 5 let", "zejtra", "davno", "jo", "mozna"]; const uz = ["ne", "jeste ne", "jiz brzy", "za chvili", "vubec", "nikdy", "za dlouho", "za 5 let", "zejtra", "davno", "jo", "mozna"];
@ -8,7 +10,7 @@ const rand = (max: number) => Math.floor(Math.random() * max);
const choose = (arr: any[]) => arr[rand(arr.length)]; const choose = (arr: any[]) => arr[rand(arr.length)];
module.exports = { const exp: Modul = {
more_komandy: { more_komandy: {
vtip: { vtip: {
@ -25,30 +27,30 @@ module.exports = {
ma: () => rand(2) ? "jo ma" : "ne nema", ma: () => rand(2) ? "jo ma" : "ne nema",
nazor: (_: any, arg: string) => rand(2) ? `mam rad ${arg}` : `${arg} je picovina`, nazor: (_, arg) => rand(2) ? `mam rad ${arg}` : `${arg} je picovina`,
si: { si: {
als: ["jsi"], als: ["jsi"],
run: (_: any, arg: string) => { run: (_, arg) => {
const corict = arg.replace(/\?/g, ""); const corict = arg.replace(/\?/g, "");
return rand(2) ? `jo sem ${corict}` : `ne nejsem ${corict}`; return rand(2) ? `jo sem ${corict}` : `ne nejsem ${corict}`;
} }
}, },
mas: (_: any, arg: string) => { mas: (_, arg) => {
const corict = arg.replace(/\?/g, ""); const corict = arg.replace(/\?/g, "");
return rand(2) ? `jo mam ${corict}` : `ne nemam ${corict}`; return rand(2) ? `jo mam ${corict}` : `ne nemam ${corict}`;
}, },
jakmoc: { jakmoc: {
cd: 1800, cd: 1800,
run: (_: any, arg: string) => `${arg} na ${rand(101)}%` run: (_, arg) => `${arg} na ${rand(101)}%`
}, },
jakmoc0: { jakmoc0: {
cd: 1800, cd: 1800,
run: (_: any, arg: string) => `${arg} na ${rand(1001)}` run: (_, arg) => `${arg} na ${rand(1001)}`
}, },
uz: { uz: {
@ -56,10 +58,12 @@ module.exports = {
run: () => choose(uz) run: () => choose(uz)
}, },
vyber: (_: any, arg: string) => { vyber: (_, arg) => {
if (!arg.length) return "co vole"; if (!arg.length) return "co vole";
const moznosti = arg.split(arg.indexOf("|") > -1 ? "|" : ",").filter(m => m.length); const moznosti = arg.split(arg.indexOf("|") > -1 ? "|" : ",").filter(m => m.length);
return choose(moznosti) || "kokot"; return choose(moznosti) || "kokot";
} }
} }
}; };
module.exports = exp;

View File

@ -1,8 +1,10 @@
// Sekce pro komandy, který jenom pošlou nějaký hovno bez a nevyžadují argumenty // Sekce pro komandy, který jenom pošlou nějaký hovno bez a nevyžadují argumenty
import { Modul } from "../utils/types";
const pomoc: [string[], {}] = require("../../res/pomoc.json"); const pomoc: [string[], {}] = require("../../res/pomoc.json");
module.exports = { const exp: Modul = {
more_komandy: { more_komandy: {
vole: "coe voe more gadzo", vole: "coe voe more gadzo",
@ -33,3 +35,5 @@ module.exports = {
navrh: "tadi mas prostor https://navrhy.denim3001.deadfish.cz/" navrh: "tadi mas prostor https://navrhy.denim3001.deadfish.cz/"
} }
}; };
module.exports = exp;

View File

@ -1,12 +1,12 @@
// Tady bude muzika, vole // Tady bude muzika, vole
import { Message } from "discord.js";
import * as ytdl from "ytdl-core"; import * as ytdl from "ytdl-core";
import { Modul } from "../utils/types";
import { joinVoice, play } from "../utils/utils"; import { joinVoice, play } from "../utils/utils";
module.exports = { const exp: Modul = {
more_komandy: { more_komandy: {
zahraj: async (mes: Message, url: string) => { zahraj: async (mes, url) => {
if (!ytdl.validateURL(url)) return "tuto neni validni youtube url a to je zatim jedini co hodlam hrat"; if (!ytdl.validateURL(url)) return "tuto neni validni youtube url a to je zatim jedini co hodlam hrat";
const kanel = mes.member?.voice.channel; const kanel = mes.member?.voice.channel;
if (!kanel) return "nejsi ve vojsu ty kkt"; if (!kanel) return "nejsi ve vojsu ty kkt";
@ -15,3 +15,5 @@ module.exports = {
} }
} }
}; };
module.exports = exp;

View File

@ -1,8 +1,9 @@
// Až se bot načte tak to napíše do konzole a jestli pošel, tak to oznámí adminovi // Až se bot načte tak to napíše do konzole a jestli pošel, tak to oznámí adminům
import { Client } from "discord.js"; import { Client } from "discord.js";
import { Modul } from "../utils/types";
module.exports = { const exp: Modul = {
on_ready: async () => { on_ready: async () => {
console.log("A jedeš!"); console.log("A jedeš!");
if (process.argv.length < 3) return; if (process.argv.length < 3) return;
@ -13,3 +14,5 @@ module.exports = {
if (channel && channel.isText()) channel.send("pošel jsem magoří"); if (channel && channel.isText()) channel.send("pošel jsem magoří");
} }
}; };
module.exports = exp;

View File

@ -3,7 +3,7 @@
import { GuildMember, Message, Role, VoiceState } from "discord.js"; import { GuildMember, Message, Role, VoiceState } from "discord.js";
import fetch from "node-fetch"; import fetch from "node-fetch";
import { emouty } from "../utils/emotes"; import { emouty } from "../utils/emotes";
import { Spinkackar } from "../utils/types"; import { Modul, Spinkackar } from "../utils/types";
import { formatCas, formatter } from "../utils/utils"; import { formatCas, formatter } from "../utils/utils";
let spinkacky: Record<string, Spinkackar>; let spinkacky: Record<string, Spinkackar>;
@ -41,12 +41,12 @@ const handleSpink = async (act: "spinkacek" | "vstavacek", member: GuildMember)
return ok.startsWith("OK") ? ok : false; return ok.startsWith("OK") ? ok : false;
}; };
module.exports = { const exp: Modul = {
more_komandy: { more_komandy: {
spinkacek: { spinkacek: {
als: ["spink", "spoink", "spinkake", "spoinkacek", "gn", "<:spinkacek:761652251966046208>", "<:gn:887124590583746590>"], als: ["spink", "spoink", "spinkake", "spoinkacek", "gn", "<:spinkacek:761652251966046208>", "<:gn:887124590583746590>"],
run: async (mes: Message) => { run: async (mes) => {
if (mes.author.bot) return `až někdy${emouty.kapp}`; if (mes.author.bot) return `až někdy${emouty.kapp}`;
if (await handleSpink("spinkacek", mes.member!)) { if (await handleSpink("spinkacek", mes.member!)) {
mes.react(emouty.spinkacek); mes.react(emouty.spinkacek);
@ -62,7 +62,7 @@ module.exports = {
vstavacek: { vstavacek: {
als: ["vstavcacek", "gm", "unspinkacek"], als: ["vstavcacek", "gm", "unspinkacek"],
run: async (mes: Message) => { run: async (mes) => {
if (mes.author.bot) return emouty.sjeta; if (mes.author.bot) return emouty.sjeta;
const odpoved = await handleSpink("vstavacek", mes.member!); const odpoved = await handleSpink("vstavacek", mes.member!);
@ -80,7 +80,7 @@ module.exports = {
} }
}, },
pgn: (mes: Message, kdy: string) => { pgn: (mes, kdy) => {
if (mes.author.bot) return emouty.sjeta; if (mes.author.bot) return emouty.sjeta;
const ted = new Date(); const ted = new Date();
@ -116,7 +116,7 @@ module.exports = {
ps: { ps: {
als: ["poslednispink"], als: ["poslednispink"],
run: (mes: Message) => { run: (mes) => {
const cas = Number(new Date()) - Number(new Date(spinkacky[mes.author.id].timeup)); const cas = Number(new Date()) - Number(new Date(spinkacky[mes.author.id].timeup));
return `uz jsi vzhuru ${formatCas(cas / 1000)}`; return `uz jsi vzhuru ${formatCas(cas / 1000)}`;
} }
@ -178,3 +178,5 @@ module.exports = {
} }
} }
}; };
module.exports = exp;

View File

@ -1,7 +1,7 @@
// Trekování statusů všech lidí o kterých bot ví // Trekování statusů všech lidí o kterých bot ví
import { Client, Guild, Presence, User } from "discord.js"; import { Client, Guild, Presence, User } from "discord.js";
import fetch from "node-fetch"; import fetch from "node-fetch";
import { FakePresence, StatusyINaFounu, UserChange, ZmenovejObjekt } from "../utils/types"; import { FakePresence, Modul, StatusyINaFounu, UserChange, ZmenovejObjekt } from "../utils/types";
const role = { online: "Online", idle: "Idle", dnd: "DND", offline: "Offline" }; const role = { online: "Online", idle: "Idle", dnd: "DND", offline: "Offline" };
const statusy = { Offline: "0", Online: "1", Idle: "2", DND: "3", OnlinePhone: "11", IdlePhone: "12", DNDPhone: "13" }; const statusy = { Offline: "0", Online: "1", Idle: "2", DND: "3", OnlinePhone: "11", IdlePhone: "12", DNDPhone: "13" };
@ -55,7 +55,7 @@ if (!process.env.ignorePresence) ziju();
const getRole = (status: StatusyINaFounu, server: Guild) => const getRole = (status: StatusyINaFounu, server: Guild) =>
server.roles.cache.find(role => role.name === `Status${status}`); server.roles.cache.find(role => role.name === `Status${status}`);
module.exports = { const exp: Modul = {
// Změna rolí podle statusu a odeslání statusu // Změna rolí podle statusu a odeslání statusu
on_presenceUpdate: (bef: Presence, aft: Presence) => { on_presenceUpdate: (bef: Presence, aft: Presence) => {
@ -108,3 +108,5 @@ module.exports = {
prepSend([{ ch: "user", user: aft }]); prepSend([{ ch: "user", user: aft }]);
} }
}; };
module.exports = exp;

View File

@ -1,9 +1,9 @@
// Cokoliv co má něco společnýho s vojsem // Cokoliv co má něco společnýho s vojsem
import { getVoiceConnection, VoiceConnection, VoiceConnectionStatus } from "@discordjs/voice"; import { getVoiceConnection, VoiceConnection, VoiceConnectionStatus } from "@discordjs/voice";
import { GuildMember, Message, VoiceChannel } from "discord.js"; import { GuildMember, VoiceChannel } from "discord.js";
import { emouty } from "../utils/emotes"; import { emouty } from "../utils/emotes";
import { MuzikaFace } from "../utils/types"; import { Modul, MuzikaFace } from "../utils/types";
import { handlePrevVoice, joinVoice, play } from "../utils/utils"; import { handlePrevVoice, joinVoice, play } from "../utils/utils";
const timeouty: Record<string, NodeJS.Timeout> = {}; const timeouty: Record<string, NodeJS.Timeout> = {};
@ -57,14 +57,14 @@ const vytahnout = (member: GuildMember, patro: number) => {
setTimeout(() => vytahnout(member, patro), 1e3); setTimeout(() => vytahnout(member, patro), 1e3);
}; };
module.exports = { const exp: Modul = {
more_komandy: { more_komandy: {
wojs: (mes: Message) => `vojs se pise s normalnim v ti kriple ${mes.author}`, wojs: (mes) => `vojs se pise s normalnim v ti kriple ${mes.author}`,
vojs: { vojs: {
cd: 1800, cd: 1800,
run: (mes: Message, arg: string) => { run: (mes, arg) => {
const channel = mes.member?.voice.channel; const channel = mes.member?.voice.channel;
if (!channel) return `di si tam sam ne ty gadzo ${mes.author}`; if (!channel) return `di si tam sam ne ty gadzo ${mes.author}`;
@ -89,7 +89,7 @@ module.exports = {
vypadni: { vypadni: {
als: ["odejdi", "disconnect", "leave", "odpoj", "votpoj", "vodpoj", "vodprejskni", "tahni"], als: ["odejdi", "disconnect", "leave", "odpoj", "votpoj", "vodpoj", "vodprejskni", "tahni"],
run: (mes: Message) => { run: (mes) => {
const vojs = getVoiceConnection(mes.guildId!); const vojs = getVoiceConnection(mes.guildId!);
if (!vojs) return 'nejsem ve vojsu'; if (!vojs) return 'nejsem ve vojsu';
@ -100,7 +100,7 @@ module.exports = {
vytah: { vytah: {
als: ["vitah"], als: ["vitah"],
run: (mes: Message, arg: string) => { run: (mes, arg) => {
if (!mes.member?.voice.channel) return `nejsi ve vojsu ty gadzo ${mes.author}`; if (!mes.member?.voice.channel) return `nejsi ve vojsu ty gadzo ${mes.author}`;
if (!arg) return `napis do jakiho patra ${mes.author}`; if (!arg) return `napis do jakiho patra ${mes.author}`;
@ -110,7 +110,7 @@ module.exports = {
krkacek: { krkacek: {
als: ["krk", "grg", "grgnisi", "krknisi", "grgacek"], als: ["krk", "grg", "grgnisi", "krknisi", "grgacek"],
run: async (mes: Message) => { run: async (mes) => {
const channel = mes.member?.voice.channel; const channel = mes.member?.voice.channel;
if (!channel) return "***grrrrrrrrg***"; if (!channel) return "***grrrrrrrrg***";
@ -122,7 +122,7 @@ module.exports = {
cas: { cas: {
cd: 5, cd: 5,
run: async (mes: Message) => { run: async (mes) => {
const date = new Date(); const date = new Date();
const h = date.getHours(); const h = date.getHours();
const m = date.getMinutes(); const m = date.getMinutes();
@ -163,3 +163,5 @@ module.exports = {
} }
} }
}; };
module.exports = exp;

View File

@ -4,18 +4,19 @@ import { getVoiceConnections } from "@discordjs/voice";
import { Client, Message } from "discord.js"; import { Client, Message } from "discord.js";
import { emouty } from "../utils/emotes"; import { emouty } from "../utils/emotes";
import { createServer } from "http"; import { createServer } from "http";
import { Modul } from "../utils/types";
let spim = false; let spim = false;
module.exports = { const exp: Modul = {
more_komandy: { more_komandy: {
debug_log: (_: any, arg: string) => { debug_log: (_, arg) => {
console.log("log: ", arg); console.log("log: ", arg);
return "je to v konzoli"; return "je to v konzoli";
}, },
update: (mes: Message) => { update: (mes) => {
if (mes.channel.id != process.env.adminChannel && mes.author.id != process.env.adminID) return "nato nemas prava kokote"; if (mes.channel.id != process.env.adminChannel && mes.author.id != process.env.adminID) return "nato nemas prava kokote";
getVoiceConnections().forEach(con => con.disconnect()); getVoiceConnections().forEach(con => con.disconnect());
@ -43,7 +44,7 @@ module.exports = {
mes.client.user?.setStatus("invisible"); mes.client.user?.setStatus("invisible");
spim = true; spim = true;
} }
else return; else return false;
} }
return true; return true;
} }
@ -75,3 +76,5 @@ module.exports = {
}).listen(1298); }).listen(1298);
} }
}; };
module.exports = exp;

View File

@ -1,13 +1,13 @@
import { Client, ClientPresenceStatusData, Message, MessageOptions, User } from "discord.js"; import { Client, ClientEvents, ClientPresenceStatusData, Message, MessageOptions, User } from "discord.js";
type OutputRunFunkce = string | MessageOptions | undefined; type OutputRunFunkce = string | MessageOptions | void;
type RunFunkce = (message: Message, argumenty: string) => OutputRunFunkce | Promise<OutputRunFunkce>; type RunFunkce = (message: Message, argumenty: string) => OutputRunFunkce | Promise<OutputRunFunkce>;
interface KomandRaw { interface KomandRaw {
als?: string[]; als?: string[];
cd?: number; cd?: number;
run: RunFunkce; run: string | RunFunkce;
}; };
export type ListenerFunkce = (...args: any[]) => void; export type ListenerFunkce = (...args: any[]) => void;
@ -19,10 +19,12 @@ interface SuperObject {
fun: SuperListenerFunkce; fun: SuperListenerFunkce;
} }
export type EventSOn = `on_${keyof ClientEvents}` | `super_on_${keyof ClientEvents}`;
export type Modul = { export type Modul = {
more_komandy: Record<string, RunFunkce | KomandRaw | string>; more_komandy?: Record<string, RunFunkce | KomandRaw | string>;
client: Client<boolean>; client?: Client<boolean>;
} & Record<string, ListenerFunkce | SuperObject | SuperListenerFunkce>; } & { [key in EventSOn]?: ListenerFunkce | SuperObject | SuperListenerFunkce; };
export interface Komand { export interface Komand {
run: RunFunkce | string; run: RunFunkce | string;