Update app.js
This commit is contained in:
parent
4ccd7940cf
commit
33204267ac
65
app.js
65
app.js
@ -4,59 +4,40 @@ const client = new Client();
|
||||
require('dotenv').config();
|
||||
|
||||
const prefix = process.env.PREFIX || 'more';
|
||||
const role = {online: '684443816383610916', idle: '684444083065978941', dnd: '684444020558135399', offline: '684443903759614049', onlinephone: '777989420728975390'};
|
||||
const spostece = ['mares', 'mareš', 'purfie', 'denim', '<@!639142938965704745>'];
|
||||
const emouty = ['purfiek3:616026189269696512', 'purfiek3:616026189269696512', 'purfiek3:616026189269696512', 'purfieUchyl:576487602203525138', 'bafW:574646319696576532', 'purfiek4:616026180889477258'];
|
||||
|
||||
const modules = [require('./modules/help'), require('./modules/hovna'), require('./modules/normal'), require('./modules/status'), require('./modules/vojs')];
|
||||
const nazvyEventu = ["ready", "presenceUpdate", "voiceStateUpdate"];
|
||||
const modulFolder = "./moduly/";
|
||||
|
||||
const rand = max => Math.floor(Math.random() * max);
|
||||
const fs = require("fs");
|
||||
|
||||
client.on('ready', () => console.log('A jedeš!'));
|
||||
let moduly = [];
|
||||
|
||||
client.on('message', mes => {
|
||||
if (process.env.IGNORE_MESS) return;
|
||||
fs.readdirSync(modulFolder).forEach(function (soubor) {
|
||||
if (soubor.endsWith(".js")) {
|
||||
moduly.push(require(modulFolder + soubor));
|
||||
}
|
||||
});
|
||||
|
||||
for (let i = 0; i < nazvyEventu.length; i++) {
|
||||
discord.on(nazvyEventu[i], function (...args) { udelejEvent(nazvyEventu[i], ...args); });
|
||||
}
|
||||
|
||||
discord.on("message", function (mes) {
|
||||
udelejEvent("message", mes);
|
||||
const [mes_prefix, komand, ...args] = mes.content.toLowerCase().split(' ');
|
||||
if (mes_prefix === prefix) {
|
||||
const celArgs = args.join(' ');
|
||||
for (let i = 0; i < modules.length; i++) {
|
||||
if (modules[i](mes, komand, celArgs)) break;
|
||||
if (i === modules.length - 1) mes.channel.send('co to znamena ti gadzovko');
|
||||
if (!udelejEvent("on_more_subkomand", komand, args)) mes.channel.send('co to znamena ti gadzovko');
|
||||
}
|
||||
}
|
||||
|
||||
let sance = 0;
|
||||
spostece.forEach(sp => {
|
||||
if (mes.content.toLowerCase().includes(sp)) sance++;
|
||||
});
|
||||
if (rand(3) < sance) mes.react(emouty[rand(emouty.length)]);
|
||||
});
|
||||
|
||||
client.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]);
|
||||
});
|
||||
|
||||
client.on('voiceStateUpdate', (bef, aft) => {
|
||||
if (!aft.channel || !aft.guild.voice || aft.member.user === client.user) return;
|
||||
if (aft.mute && !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.mute) aft.setDeaf(true, 'otposlouchávala ta gadza')});
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bef.channel) return;
|
||||
if (bef.mute && bef.deaf && !aft.mute && aft.deaf) aft.setDeaf(false, 'us muze poslouchat gadza');
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
client.login(process.env.TOKEN);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user