Rewrite of modules
This commit is contained in:
parent
43528b5fef
commit
862e913445
52
app.js
52
app.js
@ -1,43 +1,47 @@
|
||||
const { Client } = require('discord.js');
|
||||
const fs = require("fs");
|
||||
|
||||
const client = new Client();
|
||||
require('dotenv').config();
|
||||
|
||||
const prefix = process.env.PREFIX || 'more';
|
||||
const modulFolder = "./modules/";
|
||||
const komand_handlery = [];
|
||||
const eventy = { on_message: [] };
|
||||
|
||||
const nazvyEventu = ["ready", "presenceUpdate", "voiceStateUpdate"];
|
||||
const modulFolder = "./moduly/";
|
||||
|
||||
const fs = require("fs");
|
||||
|
||||
let moduly = [];
|
||||
const runEvent = (name, args) => {
|
||||
eventy[name].forEach(listener => {
|
||||
listener(...args);
|
||||
});
|
||||
}
|
||||
|
||||
fs.readdirSync(modulFolder).forEach(function (soubor) {
|
||||
if (soubor.endsWith(".js")) {
|
||||
moduly.push(require(modulFolder + soubor));
|
||||
const modul = require(`${modulFolder}${soubor}`);
|
||||
Object.keys(modul).forEach(name => {
|
||||
if (name.startsWith('on_')) {
|
||||
if (!eventy[name]) {
|
||||
eventy[name] = [];
|
||||
if (name !== 'on_message') client.on(name.substring(3), (...args) => runEvent(name, args));
|
||||
}
|
||||
eventy[name].push(modul[name]);
|
||||
} else if (name === 'more_komand') komand_handlery.push(modul[name]);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
for (let i = 0; i < nazvyEventu.length; i++) {
|
||||
discord.on(nazvyEventu[i], function (...args) { udelejEvent(nazvyEventu[i], ...args); });
|
||||
}
|
||||
client.on("message", function (mes) {
|
||||
if (process.env.IGNORE_MESS) return;
|
||||
|
||||
discord.on("message", function (mes) {
|
||||
udelejEvent("message", mes);
|
||||
runEvent('on_message', [mes]);
|
||||
const [mes_prefix, komand, ...args] = mes.content.toLowerCase().split(' ');
|
||||
if (mes_prefix === prefix) {
|
||||
if (!udelejEvent("on_more_subkomand", komand, args)) mes.channel.send('co to znamena ti gadzovko');
|
||||
}
|
||||
});
|
||||
if (mes_prefix !== prefix) return;
|
||||
|
||||
function udelejEvent(nazev, ...args) {
|
||||
for (let i = 0; i < moduly.length; i++) {
|
||||
const funkce = moduly[i]["on_" + nazev];
|
||||
if (funkce) {
|
||||
if (funkce(...args)) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
const celArgs = args.join(' ');
|
||||
for (let i = 0; i < komand_handlery.length; i++) {
|
||||
if (komand_handlery[i](mes, komand, celArgs)) return;
|
||||
}
|
||||
mes.channel.send('co to znamena ti gadzovko');
|
||||
});
|
||||
|
||||
client.login(process.env.TOKEN);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
module.exports = (mes, komand) => {
|
||||
module.exports = {
|
||||
more_komand: (mes, komand) => {
|
||||
switch (komand) {
|
||||
|
||||
case 'pomoc':
|
||||
@ -122,4 +123,5 @@ module.exports = (mes, komand) => {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@ -1,7 +1,12 @@
|
||||
let nastavit = !0;
|
||||
const spinkacky = [];
|
||||
const spostece = ['mares', 'mareš', 'purfie', 'denim', '<@!639142938965704745>'];
|
||||
const emouty = ['purfiek3:616026189269696512', 'purfiek3:616026189269696512', 'purfiek3:616026189269696512', 'purfieUchyl:576487602203525138', 'bafW:574646319696576532', 'purfiek4:616026180889477258'];
|
||||
const zarizeni = { desktop: 'Počítač', mobile: 'Mobil', web: 'Web' };
|
||||
const statusy = { online: '🟢', idle: '🟡', dnd: '🔴' };
|
||||
const rand = max => Math.floor(Math.random() * max);
|
||||
|
||||
module.exports = (mes, komand, celArgs) => {
|
||||
module.exports = {
|
||||
more_komand: (mes, komand, celArgs) => {
|
||||
switch (komand) {
|
||||
|
||||
case 'vole':
|
||||
@ -54,8 +59,6 @@ module.exports = (mes, komand, celArgs) => {
|
||||
title: `Informace o statusech pro ${uzivatel.username}:`,
|
||||
color: 431075
|
||||
};
|
||||
const zarizeni = { desktop: 'Počítač', mobile: 'Mobil', web: 'Web' };
|
||||
const statusy = { online: '🟢', idle: '🟡', dnd: '🔴' };
|
||||
const presence = uzivatel.presence.clientStatus;
|
||||
if (!presence) {
|
||||
embed.description = '*Všude je offline*';
|
||||
@ -75,24 +78,11 @@ module.exports = (mes, komand, celArgs) => {
|
||||
mes.channel.send('<:delassibazny:643059863059955723>');
|
||||
break;
|
||||
}
|
||||
|
||||
if (spinkacky.includes(mes.author.id)) {
|
||||
mes.channel.send('nespis uz?????');
|
||||
break;
|
||||
}
|
||||
const datum = new Date();
|
||||
const hodiny = datum.getHours();
|
||||
if ((hodiny < 2 && datum.getMinutes() < 30) || (hodiny > 8)) {
|
||||
mes.channel.send('ickon neni cas na spink');
|
||||
break;
|
||||
}
|
||||
|
||||
if (nastavit) {
|
||||
mes.client.on('voiceStateUpdate', (bef, aft) => {
|
||||
if (!aft.channel || bef.channel) return;
|
||||
if (spinkacky.includes(aft.id)) aft.kick();
|
||||
});
|
||||
nastavit = !1;
|
||||
};
|
||||
|
||||
if (mes.member.voice.channel) mes.member.voice.kick('spinkacek');
|
||||
spinkacky.push(mes.author.id);
|
||||
@ -113,4 +103,18 @@ module.exports = (mes, komand, celArgs) => {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
on_voiceStateUpdate: (bef, aft) => {
|
||||
if (!aft.channel || bef.channel) return;
|
||||
if (spinkacky.includes(aft.id)) aft.kick();
|
||||
},
|
||||
|
||||
on_message: mes => {
|
||||
let sance = 0;
|
||||
spostece.forEach(sp => {
|
||||
if (mes.content.toLowerCase().includes(sp)) sance++;
|
||||
});
|
||||
if (rand(3) < sance) mes.react(emouty[rand(emouty.length)]);
|
||||
}
|
||||
};
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
const ftipy = ['Tož šimša si všimnul jednoho velkeho staveniště, tak večer se tam vydal z atobatekou na boku a flefinou vruce uříznul tu největší traverzu a uříznul ji pak si ji dal na záda a šel dom ale když šel zpět tak se všimul pitbula který hlýdal staveniště a on byl na železnem řetězu tak ten řetěz popat ale nedomyslel to že ten pitbull poběží za ním a tak utíkal ale pitbull byl rychlejší a tak se mu zakousnul do prdele a tak utíkal před policií aj z pitbulem.', 'tož šimša si řekl že se pujde okoupat ale nedošlomu že na koupání potřebuje vodu a ne močůvku <:DENIM3K_weSmart:627809296624779274>', 'tož šimšu zaměstnaly na praxi do pneu servisu ale když tam došli do druhý den tak tam nic nebylo jelikož to vše vybrakoval přes noc a pak pan hlavní pneusevisák to nevydržel a exnul', 'tož šimša šel z vaku a vykopal mareše tak mocně a vykopal ho tak protože byl je závislí na cigáru a potřeboval svo mocně nemocno dáku tak vyvinul tam mocně silu aby o vykopnul', 'tož šimša jednou šel a tak moc šel do velkooooobjemního kontejnetu pro noví komponenti do jeho mašiny a podkal tam cygani a ty to tam brali a von je podkal a šel jim rozbít drčku haby se už a řek jim haby se už nevokázali u jeho kontejmetu a kdyš čel cezto dom tak mu ti kombonendi zpadli do bláda a tak mu zpadli mo ze šel sy dát zlatou dávkou', 'tož šimša seděl ve 3kole a tadytámlecti haranti mu šimšakanovali a povidaly mu 6e je římšák a šiška a šimšalátor a on povidal aby to nepovidali ale oni to povidali a pověděli mu žeto nep5estanou povidat a on ze sač4al čerchmantit a tak zasedl do traktotu a jel vo ulycy a jak jel tak jel a jel a přeji6děl kraliki a kočki a koně a jin9 zvěrstva a tak mu cajti pošeli flastr a von platil velk9 prachy, protože m2l flastra, no nem2l tag moc chlastat'];
|
||||
|
||||
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 akce = { hraj: 'PLAYING', sleduj: 'WATCHING', poslouchej: 'LISTENING', soutez: 'COMPETING', soutěž: 'COMPETING', nedelej: '', nedělej: '' };
|
||||
const role = { online: '684443816383610916', idle: '684444083065978941', dnd: '684444020558135399', offline: '684443903759614049', onlinephone: '777989420728975390' };
|
||||
|
||||
const rand = max => Math.floor(Math.random() * max);
|
||||
|
||||
module.exports = (mes, komand, celArgs) => {
|
||||
module.exports = {
|
||||
more_komand: (mes, komand, celArgs) => {
|
||||
let corict;
|
||||
switch (komand) {
|
||||
|
||||
@ -105,4 +105,17 @@ module.exports = (mes, komand, celArgs) => {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
on_presenceUpdate: (bef, aft) => {
|
||||
if (aft.guild.id !== '555779161067749446' || process.env.IGNORE_PRESENCE) return;
|
||||
|
||||
if (!bef) bef = { status: 'offline', clientStatus: {} };
|
||||
if (bef.clientStatus.mobile === 'online' && bef.clientStatus.desktop !== 'online') bef.status = 'onlinephone';
|
||||
if (aft.clientStatus.mobile === 'online' && aft.clientStatus.desktop !== 'online') aft.status = 'onlinephone';
|
||||
if (bef.status === aft.status) return;
|
||||
|
||||
aft.member.roles.add(role[aft.status]);
|
||||
aft.member.roles.remove(role[bef.status]);
|
||||
}
|
||||
};
|
||||
|
||||
3
modules/onReady.js
Normal file
3
modules/onReady.js
Normal file
@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
on_ready: () => console.log('A jedeš!')
|
||||
};
|
||||
@ -1,4 +1,5 @@
|
||||
module.exports = (mes, komand) => {
|
||||
module.exports = {
|
||||
more_komand: (mes, komand) => {
|
||||
const c = mes.client.user;
|
||||
switch (komand) {
|
||||
|
||||
@ -35,4 +36,5 @@ module.exports = (mes, komand) => {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
const fs = require('fs');
|
||||
|
||||
function vypocitatCas(vojsl) {
|
||||
let c = new Date();
|
||||
let d = new Date();
|
||||
@ -58,7 +60,8 @@ const vytahnout = (clen, patro) => {
|
||||
|
||||
const timeouty = {};
|
||||
|
||||
module.exports = (mes, komand, celArgs) => {
|
||||
module.exports = {
|
||||
more_komand: (mes, komand, celArgs) => {
|
||||
switch (komand) {
|
||||
|
||||
case 'wojs':
|
||||
@ -131,4 +134,20 @@ module.exports = (mes, komand, celArgs) => {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
on_voiceStateUpdate: (bef, aft) => {
|
||||
if (!aft.channel || !aft.guild.voice || aft.member.user === aft.guild.client.user) return;
|
||||
|
||||
if (aft.selfMute && !aft.deaf) {
|
||||
if (!aft.guild.voice.connection) aft.setDeaf(true, 'otposlouchávala ta gadza');
|
||||
else {
|
||||
aft.guild.voice.connection.play('./zvuky/neodposlouchavej.ogg', { volume: 0.38 })
|
||||
.on('finish', () => { if (aft.selfMute) aft.setDeaf(true, 'otposlouchávala ta gadza') });
|
||||
}
|
||||
}
|
||||
|
||||
if (!bef.channel) return;
|
||||
if (bef.mute && bef.deaf && !aft.mute && aft.deaf) aft.setDeaf(false, 'us muze poslouchat gadza');
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user