Fixed dum naucse err
added custom log with time and color random spink max 15 mins now
This commit is contained in:
parent
3af5607c1b
commit
26d7e8127d
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "denim_3001",
|
"name": "denim_3001",
|
||||||
"version": "3001.41.1",
|
"version": "3001.41.2",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "denim_3001",
|
"name": "denim_3001",
|
||||||
"version": "3001.41.1",
|
"version": "3001.41.2",
|
||||||
"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.1",
|
"version": "3001.41.2",
|
||||||
"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/"
|
||||||
|
|||||||
10
src/app.ts
10
src/app.ts
@ -1,7 +1,7 @@
|
|||||||
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChannelType, Client, GatewayIntentBits, Message, Partials } from "discord.js";
|
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChannelType, Client, GatewayIntentBits, Message, Partials } from "discord.js";
|
||||||
import { readdirSync } from "fs";
|
import { readdirSync } from "fs";
|
||||||
import { CUser, EventSOn, KomandNaExport, Komand, ListenerFunkce, Modul, SRecord, SuperListenerFunkce, CustomKomandy } from "./utils/types";
|
import { CUser, EventSOn, KomandNaExport, Komand, ListenerFunkce, Modul, SRecord, SuperListenerFunkce, CustomKomandy } from "./utils/types";
|
||||||
import { adminLog, getFirstArg, formatCas, loadEnv, oddiakritikovat, sortArr } from "./utils/utils.js";
|
import { adminLog, getFirstArg, formatCas, loadEnv, oddiakritikovat, sortArr, log } from "./utils/utils.js";
|
||||||
import levenshtein from "js-levenshtein";
|
import levenshtein from "js-levenshtein";
|
||||||
import { emouty } from "./utils/emotes";
|
import { emouty } from "./utils/emotes";
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ const runEvent = (name: string, args: unknown[]) => {
|
|||||||
if (listener(...args)) return true; // if listener returns true, it means, we shouldn't continue with execustion
|
if (listener(...args)) return true; // if listener returns true, it means, we shouldn't continue with execustion
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (process.env.dieOnError) throw e;
|
if (process.env.dieOnError) throw e;
|
||||||
console.log("error pri spusteni super listeneru", e);
|
log("error pri spusteni super listeneru", e as Error);
|
||||||
adminLog(client, "error pri supereventu");
|
adminLog(client, "error pri supereventu");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -60,7 +60,7 @@ const runEvent = (name: string, args: unknown[]) => {
|
|||||||
listener(...args);
|
listener(...args);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (process.env.dieOnError) throw e;
|
if (process.env.dieOnError) throw e;
|
||||||
console.log("error pri spousteni eventu", e);
|
log("error pri spousteni eventu", e as Error);
|
||||||
adminLog(client, "error pri eventu");
|
adminLog(client, "error pri eventu");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -70,7 +70,7 @@ const runEvent = (name: string, args: unknown[]) => {
|
|||||||
readdirSync(modulFolder).forEach(soubor => {
|
readdirSync(modulFolder).forEach(soubor => {
|
||||||
if (!soubor.endsWith(".js")) return;
|
if (!soubor.endsWith(".js")) return;
|
||||||
const modul: Modul = require(`${modulFolder}${soubor}`);
|
const modul: Modul = require(`${modulFolder}${soubor}`);
|
||||||
console.log(`Loaded: ${modulFolder}${soubor}`);
|
log(`Loaded: ${modulFolder}${soubor}`);
|
||||||
|
|
||||||
modul.client = client;
|
modul.client = client;
|
||||||
Object.keys(modul).forEach(name => {
|
Object.keys(modul).forEach(name => {
|
||||||
@ -144,7 +144,7 @@ async function runKomand(mes: Message, cmd: Komand, cmdName: string, arg: string
|
|||||||
if (result) mes.channel.send(result);
|
if (result) mes.channel.send(result);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (process.env.dieOnError) throw e;
|
if (process.env.dieOnError) throw e;
|
||||||
console.log("error pri spousteni akce", e);
|
log("error pri spousteni akce", e as Error);
|
||||||
const admin = process.env.adminID;
|
const admin = process.env.adminID;
|
||||||
mes.channel.send(`pri spousteni thohoto komandu nastala chyba ${admin ? `<@${admin}> uz?` : ""}`);
|
mes.channel.send(`pri spousteni thohoto komandu nastala chyba ${admin ? `<@${admin}> uz?` : ""}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -91,7 +91,6 @@ const exp: Modul = {
|
|||||||
naCo = await mes.channel.messages.fetch(mes.reference.messageId!);
|
naCo = await mes.channel.messages.fetch(mes.reference.messageId!);
|
||||||
} else {
|
} else {
|
||||||
const msgs = [...mes.channel.messages.cache.values()];
|
const msgs = [...mes.channel.messages.cache.values()];
|
||||||
console.log(msgs.length);
|
|
||||||
if (msgs.length < 2) {
|
if (msgs.length < 2) {
|
||||||
naCo = (await mes.channel.messages.fetch({ limit: 2 })).at(1)!;
|
naCo = (await mes.channel.messages.fetch({ limit: 2 })).at(1)!;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { Client, TextChannel } from "discord.js";
|
|||||||
import fetch from "node-fetch";
|
import fetch from "node-fetch";
|
||||||
import { emouty } from "../utils/emotes";
|
import { emouty } from "../utils/emotes";
|
||||||
import { Modul } from "../utils/types";
|
import { Modul } from "../utils/types";
|
||||||
|
import { log } from "../utils/utils";
|
||||||
|
|
||||||
let posledniDatum = "";
|
let posledniDatum = "";
|
||||||
let client: Client;
|
let client: Client;
|
||||||
@ -28,7 +29,7 @@ function hendelieren() {
|
|||||||
.then(r => r.text())
|
.then(r => r.text())
|
||||||
.then(txt => {
|
.then(txt => {
|
||||||
const tabule = txt.match(/<table width="100%" class="lista">(?<kontent>.+)<\/table>/is);
|
const tabule = txt.match(/<table width="100%" class="lista">(?<kontent>.+)<\/table>/is);
|
||||||
if (!tabule) return console.log("nenašel jsem tabuleho");
|
if (!tabule) return log(new Error("nenašel jsem tabuleho"));
|
||||||
|
|
||||||
const detaily = tabule.groups!.kontent.match(/<a href="d.+?&(?<odkaz>id=.+?)".+?Pridany (?<datum>\d\d\/\d\d\/\d{4})/is);
|
const detaily = tabule.groups!.kontent.match(/<a href="d.+?&(?<odkaz>id=.+?)".+?Pridany (?<datum>\d\d\/\d\d\/\d{4})/is);
|
||||||
const datum = detaily!.groups!.datum;
|
const datum = detaily!.groups!.datum;
|
||||||
|
|||||||
@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
import { Client } from "discord.js";
|
import { Client } from "discord.js";
|
||||||
import { Modul } from "../utils/types";
|
import { Modul } from "../utils/types";
|
||||||
import { adminLog } from "../utils/utils";
|
import { adminLog, log } from "../utils/utils";
|
||||||
|
|
||||||
const exp: Modul = {
|
const exp: Modul = {
|
||||||
on_ready: async () => {
|
on_ready: async () => {
|
||||||
console.log("A jedeš!");
|
log("A jedeš!");
|
||||||
if (process.argv.length < 3) return;
|
if (process.argv.length < 3) return;
|
||||||
const client: Client = module.exports.client;
|
const client: Client = module.exports.client;
|
||||||
adminLog(client, "pošel jsem");
|
adminLog(client, "pošel jsem");
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { ChannelType, Message, Presence, Role, TextBasedChannel, User, VoiceStat
|
|||||||
import fetch from "node-fetch";
|
import fetch from "node-fetch";
|
||||||
import { emouty } from "../utils/emotes";
|
import { emouty } from "../utils/emotes";
|
||||||
import { Modul, Spinkackar, SRecord } from "../utils/types";
|
import { Modul, Spinkackar, SRecord } from "../utils/types";
|
||||||
import { formatCas, formatter, oddiakritikovat, ping } from "../utils/utils";
|
import { formatCas, formatter, log, oddiakritikovat, ping } from "../utils/utils";
|
||||||
|
|
||||||
let spinkacky: SRecord<Spinkackar>;
|
let spinkacky: SRecord<Spinkackar>;
|
||||||
const budouciSpinky: SRecord<NodeJS.Timeout> = {};
|
const budouciSpinky: SRecord<NodeJS.Timeout> = {};
|
||||||
@ -105,8 +105,8 @@ const exp: Modul = {
|
|||||||
|
|
||||||
if (kdy == "random") {
|
if (kdy == "random") {
|
||||||
random = true;
|
random = true;
|
||||||
spink.setSeconds(Math.random() * 10740 + 60);
|
spink.setSeconds(Math.random() * 540 + 60);
|
||||||
console.log(`random spink pro ${oddiakritikovat(mes.member?.displayName || "neznamejmeno")} byl nastaven na ${formatter(spink)}`);
|
log(`random spink pro ${oddiakritikovat(mes.member?.displayName || "neznamejmeno")} byl nastaven na ${formatter(spink)}`);
|
||||||
} else if (/^\d+$/.test(kdy) || !kdy)
|
} else if (/^\d+$/.test(kdy) || !kdy)
|
||||||
spink.setTime(tedT + Number(kdy || 7200) * 1000);
|
spink.setTime(tedT + Number(kdy || 7200) * 1000);
|
||||||
else {
|
else {
|
||||||
@ -171,7 +171,7 @@ const exp: Modul = {
|
|||||||
on_voiceStateUpdate: (bef: VoiceState, aft: VoiceState) => {
|
on_voiceStateUpdate: (bef: VoiceState, aft: VoiceState) => {
|
||||||
if (!aft.channel || bef.channel) return;
|
if (!aft.channel || bef.channel) return;
|
||||||
if (spinkacky[aft.id]?.spinkacek) aft.disconnect("spinkacek")
|
if (spinkacky[aft.id]?.spinkacek) aft.disconnect("spinkacek")
|
||||||
.catch(err => console.log("spinkacek odpojit se nepovedlo nebo co:", err));
|
.catch(err => log("spinkacek odpojit se nepovedlo nebo co:", err));
|
||||||
},
|
},
|
||||||
|
|
||||||
super_on_messageCreate: (mes: Message, cmd?: string) => {
|
super_on_messageCreate: (mes: Message, cmd?: string) => {
|
||||||
@ -190,7 +190,7 @@ const exp: Modul = {
|
|||||||
const make = (akce: "a" | "r", role: Role) => {
|
const make = (akce: "a" | "r", role: Role) => {
|
||||||
const handle = (e: Error) => {
|
const handle = (e: Error) => {
|
||||||
if (e.message == "Missing Permissions") return;
|
if (e.message == "Missing Permissions") return;
|
||||||
console.log("chyba pri davani/odebirani role", e);
|
log("chyba pri davani/odebirani role", e);
|
||||||
};
|
};
|
||||||
if (akce == "a") member.roles.add(role).catch(handle);
|
if (akce == "a") member.roles.add(role).catch(handle);
|
||||||
else member.roles.remove(role).catch(handle);
|
else member.roles.remove(role).catch(handle);
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
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, Modul, SRecord, StatusyINaFounu, UserChange, ZmenovejObjekt } from "../utils/types";
|
import { FakePresence, Modul, SRecord, StatusyINaFounu, UserChange, ZmenovejObjekt } from "../utils/types";
|
||||||
import { adminLog } from "../utils/utils";
|
import { adminLog, log } from "../utils/utils";
|
||||||
|
|
||||||
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" };
|
||||||
@ -29,7 +29,7 @@ const poslatData = (data: SRecord<unknown>) => {
|
|||||||
data.pwd = process.env.statPass;
|
data.pwd = process.env.statPass;
|
||||||
fetch("http://deadfish.cz:4629/endpoint-pro-denimka/", { method: "POST", headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) })
|
fetch("http://deadfish.cz:4629/endpoint-pro-denimka/", { method: "POST", headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) })
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.log("err:", err);
|
log("err:", err);
|
||||||
const client: Client<boolean> = module.exports.client;
|
const client: Client<boolean> = module.exports.client;
|
||||||
adminLog(client, "stat nejede");
|
adminLog(client, "stat nejede");
|
||||||
});
|
});
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { getVoiceConnection, VoiceConnection, VoiceConnectionStatus } from "@dis
|
|||||||
import { ChannelType, GuildMember, VoiceChannel } from "discord.js";
|
import { ChannelType, GuildMember, VoiceChannel } from "discord.js";
|
||||||
import { emouty } from "../utils/emotes";
|
import { emouty } from "../utils/emotes";
|
||||||
import { Modul, MuzikaFace, SRecord } from "../utils/types";
|
import { Modul, MuzikaFace, SRecord } from "../utils/types";
|
||||||
import { canAnounceTime, handlePrevVoice, joinVoice, play } from "../utils/utils";
|
import { canAnounceTime, handlePrevVoice, joinVoice, log, play } from "../utils/utils";
|
||||||
|
|
||||||
const timeouty: SRecord<NodeJS.Timeout> = {};
|
const timeouty: SRecord<NodeJS.Timeout> = {};
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ const rekniCas = (guild: string, conn: VoiceConnection, cas: string) => {
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
vypocitatCas(guild, conn);
|
vypocitatCas(guild, conn);
|
||||||
})
|
})
|
||||||
.catch(err => { console.log("cas error:", err); });
|
.catch(err => { log("cas error:", err); });
|
||||||
else vypocitatCas(guild, conn);
|
else vypocitatCas(guild, conn);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { emouty } from "../utils/emotes";
|
|||||||
import { createServer } from "http";
|
import { createServer } from "http";
|
||||||
import { Modul } from "../utils/types";
|
import { Modul } from "../utils/types";
|
||||||
import fetch from "node-fetch";
|
import fetch from "node-fetch";
|
||||||
import { formatCas } from "../utils/utils";
|
import { formatCas, log } from "../utils/utils";
|
||||||
|
|
||||||
let spim = false;
|
let spim = false;
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ const exp: Modul = {
|
|||||||
debug_log: {
|
debug_log: {
|
||||||
hidden: true,
|
hidden: true,
|
||||||
run: (_, arg) => {
|
run: (_, arg) => {
|
||||||
console.log("log:", arg);
|
log("log:", arg);
|
||||||
return "je to v konzoli";
|
return "je to v konzoli";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -90,7 +90,7 @@ const exp: Modul = {
|
|||||||
res.end("OK");
|
res.end("OK");
|
||||||
}).catch((e: Error) => {
|
}).catch((e: Error) => {
|
||||||
if (e.message.search("2000 or fewer")) return res.end("content je moc dlouhej");
|
if (e.message.search("2000 or fewer")) return res.end("content je moc dlouhej");
|
||||||
console.log("error pri posilani upozorneni", e);
|
log("error pri posilani upozorneni", e);
|
||||||
res.statusCode = 500;
|
res.statusCode = 500;
|
||||||
res.end("neco se posralo");
|
res.end("neco se posralo");
|
||||||
});
|
});
|
||||||
|
|||||||
@ -38,10 +38,10 @@ function save(nesend?: true) {
|
|||||||
|
|
||||||
export const naucse: RunFunkce = (mes, arg) => {
|
export const naucse: RunFunkce = (mes, arg) => {
|
||||||
const args = arg.split(" ").filter(v => v != "");
|
const args = arg.split(" ").filter(v => v != "");
|
||||||
args[0] = oddiakritikovat(args[0].toLowerCase());
|
|
||||||
|
|
||||||
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 bich nato mnel rict????";
|
if (args.length == 1) return "a co bich nato mnel rict????";
|
||||||
|
|
||||||
|
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 (module.exports.realKomandy[args[0]] || customKomandi[args[0]] || module.exports.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 };
|
||||||
|
|||||||
@ -78,7 +78,7 @@ export async function joinVoice(channel: VoiceChannel | StageChannel | string, g
|
|||||||
await entersState(conn, VoiceConnectionStatus.Ready, 3e4)
|
await entersState(conn, VoiceConnectionStatus.Ready, 3e4)
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
conn!.destroy();
|
conn!.destroy();
|
||||||
console.log("pri pripojovani do vojsu nastala chyba:");
|
log("pri pripojovani do vojsu nastala chyba:");
|
||||||
throw err;
|
throw err;
|
||||||
});
|
});
|
||||||
return { conn, prev: true };
|
return { conn, prev: true };
|
||||||
@ -100,11 +100,11 @@ export async function joinVoice(channel: VoiceChannel | StageChannel | string, g
|
|||||||
|
|
||||||
if (!prev) {
|
if (!prev) {
|
||||||
const player = createAudioPlayer();
|
const player = createAudioPlayer();
|
||||||
player.on("error", e => console.log("chyba pri hrani", e));
|
player.on("error", e => log("chyba pri hrani", e));
|
||||||
pripojeni[guildId] = conn.subscribe(player)!;
|
pripojeni[guildId] = conn.subscribe(player)!;
|
||||||
conn.on("error", e => {
|
conn.on("error", e => {
|
||||||
if (e.message.startsWith("Cannot perform IP discovery")) return;
|
if (e.message.startsWith("Cannot perform IP discovery")) return;
|
||||||
console.log("error nekde v conn", e);
|
log("error nekde v conn", e);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,14 +204,18 @@ export function getFirstArg(fn: RunFunkce | string) {
|
|||||||
?.trim();
|
?.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCurrentPlayer(guildId: string) {
|
export const getCurrentPlayer = (guildId: string) => pripojeni[guildId]?.player;
|
||||||
return pripojeni[guildId]?.player;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function configureTimeAnouncment(guild: string, state: boolean) {
|
export const configureTimeAnouncment = (guild: string, state: boolean) => { timeAnouncability[guild] = state; };
|
||||||
timeAnouncability[guild] = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function canAnounceTime(guild: string) {
|
export const canAnounceTime = (guild: string) => timeAnouncability[guild] ?? true;
|
||||||
return (timeAnouncability[guild] ?? true);
|
|
||||||
|
export function log(...content: (string | Error)[]) {
|
||||||
|
const jo = content.map(h => {
|
||||||
|
if (typeof h == "string") return h;
|
||||||
|
return `\x1b[31m${h.stack || h}\x1b[0m`;
|
||||||
|
});
|
||||||
|
|
||||||
|
const d = new Date();
|
||||||
|
console.log(`[${d.getDate()}.${d.getMonth() + 1}. ${d.getHours()}:${d.getMinutes()}:${d.getSeconds()}]:`, ...jo);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user