diff --git a/.gitignore b/.gitignore
index 180baff..0443a87 100644
--- a/.gitignore
+++ b/.gitignore
@@ -109,7 +109,7 @@ dist
# FuseBox cache
.fusebox/
-
+
# DynamoDB Local files
.dynamodb/
@@ -129,6 +129,7 @@ dist
# Other
package-lock.json
.vscode/
+db/backup/
-# HTML
-*.html
\ No newline at end of file
+# Web
+web/
\ No newline at end of file
diff --git a/README.md b/README.md
index 5ae738f..53fe213 100644
--- a/README.md
+++ b/README.md
@@ -1,38 +1,49 @@
-#
LEA Bot
+
+

+
+# LEA-Bot
+
ℹ️ Formerly known as SAHP Bot. ℹ️
⚠️ Docs and most of the strings are primarily in the Czech language. ⚠️
+
+
## POPIS
-*Český Discord bot pro Law Enforcement Agencies na GTA V FiveM roleplay serveru RefreshRP.*
+*Český Discord bot pro Law Enforcement Agencies na GTA V FiveM roleplay serveru NoLimit | RefreshRP.*
-*Aktuálně podporuje sbory SAHP
a LSSD
.*
+*Aktuálně podporuje sbory LSPD
a LSSD
.*
Funkce:
- zápis služeb zaměstnanců
-- zápiu omluvenek zaměstnanců
-- zápis výpisů z CPZ
-- účast v eventech
+- zápis omluvenek zaměstnanců
- kontrola absence při událostech
+- zápis do blacklistu
+- webové tabulky *(HTML+JS+CSS s Express.js a API)*
+ - LSSD tabulky
+ - LSPD tabulky
+ - blacklist (ze seznamu v DB)
+ - divize (z rolí na Discord serverech)
- a další
## INFO
##### DOKUMENTY:
-[](/docs/usage.md) [](/docs/terms-of-use.md) [](/docs/privacy-policy.md)
+[](/docs/usage.md) [](/docs/terms-of-use.md) [](/docs/privacy-policy.md)
##### GITHUB:
[](https://github.com/Azator-Entertainment/LEA-bot/stargazers) [](https://github.com/Azator-Entertainment/LEA-bot/tree/master/) [](https://github.com/Azator-Entertainment/LEA-bot/blob/master/LICENSE.md)
-##### VYROBENO S:
+##### VYTVOŘENO POMOCÍ:
[]() []() []() []()
+   
## LICENCE
[](http://creativecommons.org/licenses/by-nc-nd/4.0/)
Toto dílo je licencováno pod [Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License](http://creativecommons.org/licenses/by-nc-nd/4.0/).
-Kód můžete volně kopírovat a dále distribuovat na jakémkoli médiu nebo formátu. Při sdílení musíte poskytnout náležitý kredit / zdroj. Materiál nemůžete použít pro komerční účely. Pokud materiál remixujete, modifikujete, transformujete nebo na něm stavíte další práci, nesmíte upravený materiál dále distribuovat.
\ No newline at end of file
+Kód můžete volně kopírovat a dále distribuovat na jakémkoli médiu nebo formátu. Při sdílení musíte poskytnout náležitý kredit. Materiál nemůžete použít pro komerční účely. Pokud materiál remixujete, modifikujete, transformujete nebo na něm zakládáte další práci, nesmíte upravený materiál dále distribuovat.
\ No newline at end of file
diff --git a/assets/cpz-embed.png b/assets/cpz-embed.png
deleted file mode 100644
index 2cb88a6..0000000
Binary files a/assets/cpz-embed.png and /dev/null differ
diff --git a/assets/cpz-modal.png b/assets/cpz-modal.png
deleted file mode 100644
index 2167f07..0000000
Binary files a/assets/cpz-modal.png and /dev/null differ
diff --git a/assets/event-faktura-embed.png b/assets/event-faktura-embed.png
deleted file mode 100644
index 827b5b9..0000000
Binary files a/assets/event-faktura-embed.png and /dev/null differ
diff --git a/assets/event-faktura-modal.png b/assets/event-faktura-modal.png
deleted file mode 100644
index 1036d06..0000000
Binary files a/assets/event-faktura-modal.png and /dev/null differ
diff --git a/db/SAHP/000000000000000001.json b/db/LSPD/000000000000000001.json
similarity index 97%
rename from db/SAHP/000000000000000001.json
rename to db/LSPD/000000000000000001.json
index 5e233ed..0d33f17 100644
--- a/db/SAHP/000000000000000001.json
+++ b/db/LSPD/000000000000000001.json
@@ -1,4 +1,5 @@
{
+ "active": true,
"badge": 1050,
"name": "Will Smith",
"radio": "Ocean-32",
@@ -27,6 +28,7 @@
"ic": "Zlomená ruka"
}
],
+ "cpz": [],
"rankups": [
{
"date": "5. 11. 2023",
diff --git a/db/LSSD/000000000000000001.json b/db/LSSD/000000000000000001.json
index 092b96e..9c156dd 100644
--- a/db/LSSD/000000000000000001.json
+++ b/db/LSSD/000000000000000001.json
@@ -1,4 +1,5 @@
{
+ "active": true,
"badge": 1050,
"name": "Will Smith",
"radio": "Ocean-32",
@@ -26,6 +27,7 @@
"ic": "Zlomená ruka"
}
],
+ "cpz": [],
"rankups": [
{
"date": "5. 11. 2023",
diff --git a/db/blacklist.json b/db/blacklist.json
new file mode 100644
index 0000000..ee328e9
--- /dev/null
+++ b/db/blacklist.json
@@ -0,0 +1,17 @@
+[
+ {
+ "name": "Will Smith",
+ "displayName": "William",
+ "username": "smith01",
+ "id": "0000000000000000001",
+ "from": {
+ "dep": "LSSD",
+ "name": "Dwayne Johnson",
+ "username": "dwayne02",
+ "displayName": "TheRock",
+ "id": "0000000000000000002",
+ "timestamp": "31. 12. 2020",
+ "reason": "corruption"
+ }
+ }
+]
\ No newline at end of file
diff --git a/db/event/0.txt b/db/event/0.txt
deleted file mode 100644
index e69de29..0000000
diff --git a/db/event/000000000000000001.json b/db/event/000000000000000001.json
deleted file mode 100644
index 6c5e8df..0000000
--- a/db/event/000000000000000001.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "name": "Will Smith",
- "stats": {
- "value": 15000,
- "invoices": 1
- },
- "invoices": [
- {
- "value": 15000,
- "shared": "31. 12. 2023",
- "reason": "Nelegální akce",
- "name": "John Wick",
- "id": 1
- }
- ]
-}
\ No newline at end of file
diff --git a/docs/privacy-policy.md b/docs/privacy-policy.md
index 910457e..96aea87 100644
--- a/docs/privacy-policy.md
+++ b/docs/privacy-policy.md
@@ -1,7 +1,7 @@
# LEA Bot | Zásady Ochrany Osobních Údajů
- Vytvořil **[@PetyXbron aka b1ngo](https://github.com/PetyXbron/)**
- Veřejně dostupné na platformě GitHub.
-- LEA Bot primárně slouží pouze **San Andreas Highway Patrol** a **Los Santos Sheriff Department** na FiveM serveru **RefreshRP**. Jeho jiné používání není doporučeno a je nutné se řídit podmínkami.
+- LEA Bot primárně slouží pouze pro smyšlené policejní sbory **Los Santos Police Department** a **Los Santos Sheriff Department** na FiveM serveru **NoLimit | RefreshRP**. Jeho jiné používání není doporučeno a je nutné se řídit podmínkami.
- Zkontroluj **[licenci](/LICENSE.md)** před používáním
[](http://creativecommons.org/licenses/by-nc-nd/4.0/)
diff --git a/docs/terms-of-use.md b/docs/terms-of-use.md
index 8530b95..63e7751 100644
--- a/docs/terms-of-use.md
+++ b/docs/terms-of-use.md
@@ -1,7 +1,7 @@
# LEA Bot | Podmínky Použití (TOS)
- Vytvořil **[@PetyXbron aka b1ngo](https://github.com/PetyXbron/)**
- Veřejně dostupné na platformě GitHub.
-- LEA Bot primárně slouží pouze **San Andreas Highway Patrol** a **Los Santos Sheriff Department** na FiveM serveru **RefreshRP**. Jeho jiné používání není doporučeno a je nutné se řídit podmínkami.
+- LEA Bot primárně slouží pouze pro smyšlené policejní sbory **Los Santos Police Department** a **Los Santos Sheriff Department** na FiveM serveru **NoLimit | RefreshRP**. Jeho jiné používání není doporučeno a je nutné se řídit podmínkami.
- Zkontroluj **[licenci](/LICENSE.md)** před používáním
[](http://creativecommons.org/licenses/by-nc-nd/4.0/)
diff --git a/docs/usage.md b/docs/usage.md
index b07277e..584ee87 100644
--- a/docs/usage.md
+++ b/docs/usage.md
@@ -1,7 +1,7 @@
# LEA Bot | JAK POUŽÍVAT
- Vytvořil **[@PetyXbron aka b1ngo](https://github.com/PetyXbron/)**
- Veřejně dostupné na platformě GitHub.
-- LEA Bot primárně slouží pouze **San Andreas Highway Patrol** a **Los Santos Sheriff Department** na FiveM serveru **RefreshRP**. Jeho jiné používání není doporučeno a je nutné se řídit podmínkami.
+- LEA Bot primárně slouží pouze pro smyšlené policejní sbory **Los Santos Police Department** a **Los Santos Sheriff Department** na FiveM serveru **NoLimit | RefreshRP**. Jeho jiné používání není doporučeno a je nutné se řídit podmínkami.
- Zkontroluj **[licenci](/LICENSE.md)** před používáním
[](http://creativecommons.org/licenses/by-nc-nd/4.0/)
@@ -12,12 +12,10 @@
3. [Používání funkcí](#3-používání-funkcí)
1. [Zápis duty](#1-zapsání-duty)
2. [Zápis omluvenky](#2-zapsání-omluvenky)
- 3. [Zápis CPZ](#3-zapsání-cpz)
- 4. [Event](#4-event)
### 1. Spuštění procesu
-Před spuštěním nezapomeň použít `npm install` pro instalaci balíčků (`discord.js`, `dotenv`, `fs`).
+Před spuštěním nezapomeň použít `npm install` pro instalaci balíčků (`discord.js`, `dotenv`, `express`, `node-fetch`).
- `npm start` pro zapnutí na dobu neurčitou
- `npm test` pro kontrolu bezproblémového zapnutí
@@ -36,22 +34,21 @@ Použitím pozvánky https://discord.com/oauth2/authorize?client_id=ID-APLIKACE&
### 3. Používání funkcí
Bot se hlavně zatím používá pomocí jednoduchých příkazů:
-- 👮✅ **`/admin`** - Obecná správa
-- 🫡✅ **`/cpz`** - Zápis CPZ
- 👮✅ **`/db`** - Správa databáze zaměstnanců
- 🫡✅ **`/duty`** - Zápis služby
-- 🫡✅ **`/event`** - Příkaz pro soutěže
-- 🫡✅ **`/profil`** - Vyhledat zaměstnance na základě různých parametrů
+- 👮✅ **`/leader`** - Obecná admin správa
- 🫡✅ **`/menu`** - Základní přehled / pomocné menu bota
- 🫡✅ **`/omluvenka`** - Zápis omluvenky
- 🫡✅ **`/online`** - Členi serveru, kteří aktuálně hrají na RefreshRP
+- 🫡✅ **`/profil`** - Vyhledat zaměstnance na základě různých parametrů
+- 🫡❌ **`/rep`** - Hodnocení, přidání reputace kolegům
####
- 🫡 značí příkaz pro **všechny / zaměstnance**
- 👮 značí příkaz pro **adminy**
- ✅ značí příkaz, který je v téhle verzi **funkční**
- ❌ značí příkaz, který je v téhle verzi **nefunkční / nedokončený**
-Zároveň nově hostuje stránky s **SAHP, LSSD tabulkami a jejich divizemi** na bázi Express.js, HTML+CSS+JS.
+Zároveň nově hostuje stránky s **LSPD, LSSD tabulkami, jejich divizemi a blacklistem** na bázi Express.js, HTML+CSS+JS.
Ty se aktualizují **přímo z databáze a Discord serverů** po každém načtení stránky.
#### 1. Zapsání duty
@@ -74,28 +71,4 @@ Ty se aktualizují **přímo z databáze a Discord serverů** po každém načte

-#### 3. Zapsání CPZ
-1. Použij příkaz **`/cpz`**.
-
-
-
-2. **Vyplň údaje** v tzv. pop-upu.
-3. **Potvrď odeslání** a zkontroluj výsledek.
-
-
-
-#### 4. Event
-Konání, průběh, a další určuje samotný server (jeho správci).
-Aktuálně je možné vyhodnotit event dle zadaých faktur.
-Jednotlivé příkazy:
-- **`/event faktura`** - samotný zápis faktury
-- **`/event souhrn`** - výpis faktur
-- **`/event žebříček`** - žebříček top soutěžících
-
-Zápis faktury:
-
-
-
-
-
Použivání každé funkce je omezené a tím pádem je nepochopení, či špatné použití skoro nemožné.
\ No newline at end of file
diff --git a/index.js b/index.js
index c2bf772..fbf1b03 100644
--- a/index.js
+++ b/index.js
@@ -26,6 +26,7 @@ let bot = new Client({
bot.slashes = new Collection();
bot.LEA = {
c: {
+ LEAbot: "#3a9a97",
LSPD: "#000c1e",
SAHP: "#457cc0",
LSSD: "#bd8131",
@@ -36,6 +37,7 @@ bot.LEA = {
event: "#Be25ab"
},
i: {
+ LEAbot: "https://i.imgur.com/EnZErOi.png",
LSPD: "https://i.imgur.com/gfL0fGf.png",
SAHP: "https://i.imgur.com/xgFoKuX.png",
LSSD: "https://i.imgur.com/X3cH2iu.png",
@@ -51,11 +53,11 @@ bot.LEA = {
LSSD: "<:LSSD:1178106303198011412>"
},
g: {
- SAHP: [
- "1139266097921675345", "1174843772446703718", "714147774299373629"
+ LSPD: [
+ "1154446248934387828", "1203275468544151583"
],
LSSD: [
- "1167182546853961860"
+ "1139266097921675345", "1174843772446703718", "714147774299373629"
]
}
};
@@ -64,6 +66,6 @@ import { events, commands } from "./src/functions/register.js";
events(bot);
commands(bot);
-bot.login(secret().parsed.token);
+bot.login(secret().parsed.botToken);
export { bot };
\ No newline at end of file
diff --git a/package.json b/package.json
index 57e5662..6df4756 100644
--- a/package.json
+++ b/package.json
@@ -1,12 +1,12 @@
{
"name": "lea-bot",
- "version": "3.0",
+ "version": "4.0",
"description": "RefreshRP (FiveM GTA V roleplay) Discord bot for LEA - making internal police department actions easier.",
"type": "module",
"main": "index.js",
"scripts": {
- "start": "node index.js start",
- "test": "node index.js test"
+ "start": "node --no-warnings index.js start",
+ "test": "node --no-warnings index.js test"
},
"keywords": [
"discord-bot",
@@ -29,8 +29,9 @@
"node": ">=16.11.0"
},
"dependencies": {
- "discord.js": "^14.14.1",
- "dotenv": "^16.4.1",
- "express": "^4.18.2"
+ "discord.js": "^14.15.2",
+ "dotenv": "^16.4.5",
+ "express": "^4.19.2",
+ "node-fetch": "^3.3.2"
}
}
diff --git a/src/commands/admin.js b/src/commands/admin.js
deleted file mode 100644
index a32314e..0000000
--- a/src/commands/admin.js
+++ /dev/null
@@ -1,150 +0,0 @@
-import { ActionRowBuilder, AttachmentBuilder, ModalBuilder, SlashCommandBuilder, TextInputBuilder, TextInputStyle } from "discord.js";
-import fs from "fs";
-import path from "path";
-import { checkDB } from "../../src/functions/db.js";
-
-export const slash = new SlashCommandBuilder()
- .setName("admin")
- .setDescription(`Obecná správa`)
- .addSubcommand(subcommand =>
- subcommand
- .setName('docházka')
- .setDescription("Kontrola absence")
- )
- .setDMPermission(false)
- .setNSFW(false);
-
-export default async function run(bot, i) {
- const sub = i.options._subcommand;
-
- let passed = false;
- await i.guild.fetch();
- const admin = await i.member;
- if (admin.id === "411436203330502658") passed = true; //PetyXbron / b1ngo
- if (bot.LEA.g.SAHP.includes(i.guild.id) && !passed) {
- if (admin.roles.cache.has("1145344761402765343")) passed = true; //Staff team Refresh
- if (admin.roles.cache.has("1139266408681844887")) passed = true; //.
- if (admin.id === "607915400604286997") passed = true; //Samus
- if (admin.id === "436180906533715969") passed = true; //Mičut
- } else if (bot.LEA.g.LSSD.includes(i.guild.id) && !passed) {
- if (admin.roles.cache.has("1167182546904293481")) passed = true; //Staff team Refresh
- if (admin.roles.cache.has("1167182546904293482")) passed = true; //*
- if (admin.roles.cache.has("1190825815596875829")) passed = true; //.
- if (admin.id === "798644986215661589") passed = true; //Smouky
- if (admin.id === "829978476701941781") passed = true; //Frexik
- }
-
- if (!passed) return i.reply({ content: "> 🛑 **K tomuhle má přístup jen admin.**", ephemeral: true });
-
- if (sub === "docházka") {
- const today = new Date();
- const modal = new ModalBuilder()
- .setCustomId("dochazkaModal")
- .setTitle("SAHP | Docházka");
-
- const idInput = new TextInputBuilder()
- .setCustomId("eventID")
- .setLabel("ID události")
- .setStyle(TextInputStyle.Short)
- .setPlaceholder("1")
- .setMaxLength(5)
- .setRequired(true);
-
- const dateInput = new TextInputBuilder()
- .setCustomId("date")
- .setLabel("Datum")
- .setStyle(TextInputStyle.Short)
- .setValue(today.getDate() + ". " + (parseInt(today.getMonth()) + 1) + ". " + today.getFullYear())
- .setPlaceholder(today.getDate() + ". " + (parseInt(today.getMonth()) + 1) + ". " + today.getFullYear())
- .setMinLength(10)
- .setMaxLength(12)
- .setRequired(true);
-
- const ignoreInput = new TextInputBuilder()
- .setCustomId("ignore")
- .setLabel("Čísla odznaků zaměstnanců, které ignorovat")
- .setStyle(TextInputStyle.Paragraph)
- .setPlaceholder("1012, 1035, 1036, 1037, 1050, 1061")
- .setRequired(false);
-
- const actionRow0 = new ActionRowBuilder().addComponents(idInput);
- const actionRow1 = new ActionRowBuilder().addComponents(dateInput);
- const actionRow2 = new ActionRowBuilder().addComponents(ignoreInput);
-
- modal.addComponents(actionRow0, actionRow1, actionRow2);
-
- await i.showModal(modal);
-
- let submit = await i.awaitModalSubmit({ filter: int => int.user.id === i.user.id, time: 600000 }).catch(e => {
- return null;
- });
-
- if (submit) {
- await submit.deferReply({ ephemeral: true });
-
- const id = parseInt(submit.fields.getTextInputValue("eventID"));
- const ignored = submit.fields.getTextInputValue("ignore").split(", ");
- const eventDateArr = submit.fields.getTextInputValue("date").split(". ");
- const eventDate = new Date(eventDateArr[1] + "/" + eventDateArr[0] + "/" + eventDateArr[2]);
-
- let users = [], db;
- if (bot.LEA.g.SAHP.includes(i.guild.id)) db = fs.readdirSync(path.resolve("./db/SAHP")).filter(file => file.endsWith(".json") && file !== "000000000000000001.json");
- else if (bot.LEA.g.LSSD.includes(i.guild.id)) db = fs.readdirSync(path.resolve("./db/LSSD")).filter(file => file.endsWith(".json") && file !== "000000000000000001.json");
- for (const file of db) {
- let worker;
- if (bot.LEA.g.SAHP.includes(i.guild.id)) worker = JSON.parse(fs.readFileSync((path.resolve("./db/SAHP") + "/" + file), "utf-8"));
- else if (bot.LEA.g.LSSD.includes(i.guild.id)) worker = JSON.parse(fs.readFileSync((path.resolve("./db/LSSD") + "/" + file), "utf-8"));
-
- let m;
- try {
- m = await i.guild.members.fetch(file.split(".")[0]);
- } catch (e) {
- m = false;
- }
-
- if (m) {
- const ap = worker.apologies;
- let apologized = false;
- if (worker.badge < 1015) apologized = true;
- if (ignored.includes(worker.badge.toString())) apologized = true;
- if (m.roles.cache.has("1139267137651884072")) apologized = true;
- if (!apologized) for (const a of ap) {
- if (a.eventID === id) {
- apologized = true;
- } else {
- const startDateArr = a.start.split(". ");
- const startDate = new Date(startDateArr[1] + "/" + startDateArr[0] + "/" + startDateArr[2]);
- const endDateArr = a.end.split(". ");
- const endDate = new Date(endDateArr[1] + "/" + endDateArr[0] + "/" + endDateArr[2]);
- if (eventDate.getTime() >= startDate.getTime() && eventDate <= endDate.getTime()) {
- apologized = true;
- }
- }
- }
-
- if (!apologized) {
- worker.id = file.split(".")[0];
- users.push(worker);
- }
- }
- }
-
- users.sort((a, b) => a.badge - b.badge);
- let mentions = [], list = [];
- for (const u of users) {
- mentions.push(`<@${u.id}>`);
- }
- const mentionsAtt = new AttachmentBuilder(Buffer.from(mentions.join(", ")), { name: "mentions.txt" });
-
- for (const u of users) {
- list.push(`[${u.radio}] ${u.name} [${u.badge}] | ${u.id}`);
- }
- const listAtt = new AttachmentBuilder(Buffer.from(list.join("\n")), { name: "list.txt" });
-
- await submit.editReply({
- files: [listAtt, mentionsAtt],
- ephemeral: true
- });
- }
- }
-};
\ No newline at end of file
diff --git a/src/commands/cpz.js b/src/commands/cpz.js
deleted file mode 100644
index a4f3549..0000000
--- a/src/commands/cpz.js
+++ /dev/null
@@ -1,84 +0,0 @@
-import { ActionRowBuilder, ModalBuilder, SlashCommandBuilder, TextInputBuilder, TextInputStyle } from "discord.js";
-
-export const slash = new SlashCommandBuilder()
- .setName("cpz")
- .setDescription(`Zapíše CPZ`)
- .setDMPermission(false)
- .setNSFW(false);
-
-export default async function run(bot, i) {
- if (bot.LEA.g.LSSD.includes(i.guild.id)) return i.reply({ content: "> 🛑 **Zápis __CPZ__ se nepoužívá v LSSD " + bot.LEA.e.LSSD + ".**", ephemeral: true });
-
- let passed = false;
- await i.guild.fetch();
- const admin = await i.member;
- if (admin.id === "411436203330502658") passed = true; //PetyXbron / b1ngo
- if (bot.LEA.g.SAHP.includes(i.guild.id) && !passed) {
- if (admin.roles.cache.has("1145344761402765343")) passed = true; //Staff team Refresh
- if (admin.roles.cache.has("1139266408681844887")) passed = true; //.
- if (admin.id === "607915400604286997") passed = true; //Samus
- if (admin.id === "436180906533715969") passed = true; //Mičut
- } else if (bot.LEA.g.LSSD.includes(i.guild.id) && !passed) {
- if (admin.roles.cache.has("1167182546904293481")) passed = true; //Staff team Refresh
- if (admin.roles.cache.has("1167182546904293482")) passed = true; //*
- if (admin.roles.cache.has("1190825815596875829")) passed = true; //.
- if (admin.id === "798644986215661589") passed = true; //Smouky
- if (admin.id === "829978476701941781") passed = true; //Frexik
- }
-
- if (!passed) {
- const ch = ["1139268053213917235", "1139268119391645756"];
- if (!ch.includes(i.channel.id)) return i.reply({ content: "> 🛑 **Zápis __CPZ__ je povolen pouze v <#1139268053213917235>.**", ephemeral: true });
- }
-
- const modal = new ModalBuilder()
- .setCustomId("cpzModal")
- .setTitle("SAHP | Zápis CPZ");
-
- const nameInput = new TextInputBuilder()
- .setCustomId("name")
- .setLabel("Jméno občana")
- .setStyle(TextInputStyle.Short)
- .setPlaceholder("Will Smith")
- .setRequired(true);
-
- const birthInput = new TextInputBuilder()
- .setCustomId("birth")
- .setLabel("Narození občana")
- .setStyle(TextInputStyle.Short)
- .setPlaceholder("12/31/1990")
- .setMinLength(10)
- .setMaxLength(10)
- .setRequired(true);
-
- const reasonInput = new TextInputBuilder()
- .setCustomId("reason")
- .setLabel("Důvod zadržení")
- .setStyle(TextInputStyle.Paragraph)
- .setPlaceholder("Nelegální akce")
- .setRequired(true);
-
- const moneyInput = new TextInputBuilder()
- .setCustomId("money")
- .setLabel("Výpis trestu / pokut")
- .setStyle(TextInputStyle.Paragraph)
- .setPlaceholder("15 000 $ + 1 rok odnětí svobody")
- .setRequired(true);
-
- const pdInput = new TextInputBuilder()
- .setCustomId("pd")
- .setLabel("Řešili")
- .setStyle(TextInputStyle.Short)
- .setPlaceholder("Chris Evans, Addam Sandler")
- .setRequired(true);
-
- const actionRow0 = new ActionRowBuilder().addComponents(nameInput);
- const actionRow1 = new ActionRowBuilder().addComponents(birthInput);
- const actionRow2 = new ActionRowBuilder().addComponents(reasonInput);
- const actionRow3 = new ActionRowBuilder().addComponents(moneyInput);
- const actionRow4 = new ActionRowBuilder().addComponents(pdInput);
-
- modal.addComponents(actionRow0, actionRow1, actionRow2, actionRow3, actionRow4);
-
- await i.showModal(modal);
-};
\ No newline at end of file
diff --git a/src/commands/db.js b/src/commands/db.js
index 2cb7cca..3d846a8 100644
--- a/src/commands/db.js
+++ b/src/commands/db.js
@@ -2,6 +2,7 @@ import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ModalBuilder, SlashComman
import fs from "fs";
import path from "path";
import { checkDB, getDB } from "../../src/functions/db.js";
+import { dcLog } from "../../src/functions/logSystem.js";
export const slash = new SlashCommandBuilder()
.setName("db")
@@ -14,6 +15,7 @@ export const slash = new SlashCommandBuilder()
{ name: "Registrovat", value: "p" },
{ name: "Zkontrolovat", value: "z" },
{ name: "Povýšit", value: "r" },
+ { name: "Upravit", value: "u" },
{ name: "Smazat", value: "s" }
))
.addUserOption(option =>
@@ -31,26 +33,27 @@ export default async function run(bot, i) {
await i.guild.fetch();
const admin = await i.member;
if (admin.id === "411436203330502658") passed = true; //PetyXbron / b1ngo
- if (bot.LEA.g.SAHP.includes(i.guild.id) && !passed) {
- if (admin.roles.cache.has("1145344761402765343")) passed = true; //Staff team Refresh
- if (admin.roles.cache.has("1139266408681844887")) passed = true; //.
- if (admin.id === "607915400604286997") passed = true; //Samus
- if (admin.id === "436180906533715969") passed = true; //Mičut
+ if (bot.LEA.g.LSPD.includes(i.guild.id) && !passed) {
+ if (admin.roles.cache.has("1154446249005690917")) passed = true; //Staff team Refresh
+ if (admin.roles.cache.has("1201813866548580443")) passed = true; //.
+ if (admin.roles.cache.has("1154446249005690916")) passed = true; //*
+ if (admin.id === "846451292388851722") passed = true; //aldix_eu
+ if (admin.id === "644571265725628437") passed = true; //griffin0s
} else if (bot.LEA.g.LSSD.includes(i.guild.id) && !passed) {
- if (admin.roles.cache.has("1167182546904293481")) passed = true; //Staff team Refresh
- if (admin.roles.cache.has("1167182546904293482")) passed = true; //*
- if (admin.roles.cache.has("1190825815596875829")) passed = true; //.
- if (admin.id === "798644986215661589") passed = true; //Smouky
- if (admin.id === "829978476701941781") passed = true; //Frexik
+ if (admin.roles.cache.has("1139267137651884072")) passed = true; //Leadership
+ if (admin.roles.cache.has("1139295201282764882")) passed = true; //FTO Commander
}
if (!passed) return i.reply({ content: "> 🛑 **K tomuhle má přístup jen admin.**", ephemeral: true });
if (choice === "p") {
- if (await checkDB(user.id)) return i.reply({ content: "> 🛑 <@" + user.id + "> **už je v DB.**", ephemeral: true });
+ if (await checkDB(user.id)) {
+ const gotDB = await getDB(user.id);
+ return i.reply({ content: `> 🛑 <@${user.id}> **už je v DB. (Členem ${gotDB.guildName}.)**`, ephemeral: true });
+ }
const modal = new ModalBuilder()
.setCustomId("loginModal")
- .setTitle("SAHP | Přihlášení");
+ .setTitle("LEA | Přihlášení");
const idInput = new TextInputBuilder()
.setCustomId("id")
@@ -102,13 +105,13 @@ export default async function run(bot, i) {
if (!(await checkDB(user.id))) return i.reply({ content: "> 🛑 <@" + user.id + "> **není v DB.**", ephemeral: true });
let log, sbor;
- if (bot.LEA.g.SAHP.includes(i.guild.id)) log = path.resolve("./db/SAHP") + "/" + user.id + ".json", sbor = "SAHP";
+ if (bot.LEA.g.LSPD.includes(i.guild.id)) log = path.resolve("./db/LSPD") + "/" + user.id + ".json", sbor = "LSPD";
else if (bot.LEA.g.LSSD.includes(i.guild.id)) log = path.resolve("./db/LSSD") + "/" + user.id + ".json", sbor = "LSSD";
else return i.reply({ content: "> 🛑 **Tenhle server není uveden a seznamu.**\nKontaktuj majitele (viz. ).", ephemeral: true });
if (!fs.existsSync(log)) {
- if (bot.LEA.g.SAHP.includes(i.guild.id)) log = path.resolve("./db/LSSD") + "/" + user.id + ".json", sbor = "LSSD";
- else if (bot.LEA.g.LSSD.includes(i.guild.id)) log = path.resolve("./db/SAHP") + "/" + user.id + ".json", sbor = "SAHP";
+ if (bot.LEA.g.LSPD.includes(i.guild.id)) log = path.resolve("./db/LSSD") + "/" + user.id + ".json", sbor = "LSSD";
+ else if (bot.LEA.g.LSSD.includes(i.guild.id)) log = path.resolve("./db/LSPD") + "/" + user.id + ".json", sbor = "LSPD";
}
console.log(" < [CMD/DB] > " + i.member.displayName + ` zobrazil(a) DB záznam ${user.id}.json`);
@@ -122,7 +125,7 @@ export default async function run(bot, i) {
const modal = new ModalBuilder()
.setCustomId("rankUpModal")
- .setTitle("SAHP | Povýšení");
+ .setTitle("LEA | Povýšení");
const idInput = new TextInputBuilder()
.setCustomId("id")
@@ -154,18 +157,72 @@ export default async function run(bot, i) {
.setPlaceholder("Trooper II")
.setRequired(true);
- const reasonInput = new TextInputBuilder()
- .setCustomId("reason")
- .setLabel("Důvod")
- .setStyle(TextInputStyle.Paragraph)
- .setPlaceholder("Úspěšná hodnocená patrola")
- .setRequired(true);
-
const actionRow0 = new ActionRowBuilder().addComponents(idInput);
const actionRow1 = new ActionRowBuilder().addComponents(callInput);
const actionRow2 = new ActionRowBuilder().addComponents(badgeInput);
const actionRow3 = new ActionRowBuilder().addComponents(rankInput);
- const actionRow4 = new ActionRowBuilder().addComponents(reasonInput);
+
+ modal.addComponents(actionRow0, actionRow1, actionRow2, actionRow3);
+
+ await i.showModal(modal);
+ } else if (choice === "u") {
+ if (!(await checkDB(user.id))) return i.reply({ content: "> 🛑 <@" + user.id + "> **už není v DB.**", ephemeral: true });
+
+ const gotDB = await getDB(user.id);
+ const data = gotDB.data;
+ if (!bot.LEA.g[gotDB.guildName].includes(i.guild.id)) return i.reply({ content: `> 🛑 **<@${user.id}> je členem \`${gotDB.guildName}\`!** (Nemůžeš ho upravit)`, ephemeral: true });
+
+ const modal = new ModalBuilder()
+ .setCustomId("editModal")
+ .setTitle("LEA | Úprava DB");
+
+ const idInput = new TextInputBuilder()
+ .setCustomId("id")
+ .setLabel("ID Discord člena")
+ .setStyle(TextInputStyle.Short)
+ .setPlaceholder(user.id)
+ .setValue(user.id)
+ .setRequired(true);
+
+ const nameInput = new TextInputBuilder()
+ .setCustomId("name")
+ .setLabel("Jméno")
+ .setStyle(TextInputStyle.Short)
+ .setPlaceholder(data.name)
+ .setValue(data.name)
+ .setRequired(true);
+
+ const callInput = new TextInputBuilder()
+ .setCustomId("call")
+ .setLabel("Volačka")
+ .setStyle(TextInputStyle.Short)
+ .setPlaceholder(data.radio)
+ .setValue(data.radio)
+ .setRequired(true);
+
+ const badgeInput = new TextInputBuilder()
+ .setCustomId("badge")
+ .setLabel("Číslo odznaku")
+ .setStyle(TextInputStyle.Short)
+ .setPlaceholder(data.badge === 0 ? "0000" : data.badge.toString())
+ .setValue(data.badge === 0 ? "0000" : data.badge.toString())
+ .setMinLength(4)
+ .setMaxLength(4)
+ .setRequired(true);
+
+ const rankInput = new TextInputBuilder()
+ .setCustomId("rank")
+ .setLabel("Hodnost")
+ .setStyle(TextInputStyle.Short)
+ .setPlaceholder(data.rank)
+ .setValue(data.rank)
+ .setRequired(true);
+
+ const actionRow0 = new ActionRowBuilder().addComponents(idInput);
+ const actionRow1 = new ActionRowBuilder().addComponents(nameInput);
+ const actionRow2 = new ActionRowBuilder().addComponents(callInput);
+ const actionRow3 = new ActionRowBuilder().addComponents(badgeInput);
+ const actionRow4 = new ActionRowBuilder().addComponents(rankInput);
modal.addComponents(actionRow0, actionRow1, actionRow2, actionRow3, actionRow4);
@@ -173,14 +230,14 @@ export default async function run(bot, i) {
} else if (choice === "s") {
if (!(await checkDB(user.id))) return i.reply({ content: "> 🛑 <@" + user.id + "> **už není v DB.**", ephemeral: true });
- let loc;
- if (bot.LEA.g.SAHP.includes(i.guild.id)) loc = path.resolve("./db/SAHP") + "/" + user.id + ".json";
+ let loc, worker;
+ if (bot.LEA.g.LSPD.includes(i.guild.id)) loc = path.resolve("./db/LSPD") + "/" + user.id + ".json";
else if (bot.LEA.g.LSSD.includes(i.guild.id)) loc = path.resolve("./db/LSSD") + "/" + user.id + ".json";
else return i.reply({ content: "> 🛑 **Tenhle server není uveden a seznamu.**\nKontaktuj majitele (viz. ).", ephemeral: true });
const admins = [
- "411436203330502658"/*b1ngo*/, "607915400604286997"/*samus*/, "436180906533715969",/*micut*/
- "829978476701941781"/*frexikk*/, "798644986215661589"/*smouky*/
+ "411436203330502658"/*b1ngo*/, "607915400604286997"/*samus*/, "436180906533715969"/*micut*/,
+ "846451292388851722"/*aldix_eu*/, "644571265725628437"/*griffin0s*/
];
if (!fs.existsSync(loc)) {
@@ -203,17 +260,29 @@ export default async function run(bot, i) {
});
collector.on('collect', async i => {
- if (bot.LEA.g.SAHP.includes(i.guild.id)) loc = path.resolve("./db/LSSD") + "/" + user.id + ".json";
- else if (bot.LEA.g.LSSD.includes(i.guild.id)) loc = path.resolve("./db/SAHP") + "/" + user.id + ".json";
+ if (bot.LEA.g.LSPD.includes(i.guild.id)) loc = path.resolve("./db/LSSD") + "/" + user.id + ".json", worker = JSON.parse(fs.readFileSync(loc, "utf-8"));
+ else if (bot.LEA.g.LSSD.includes(i.guild.id)) loc = path.resolve("./db/LSPD") + "/" + user.id + ".json", worker = JSON.parse(fs.readFileSync(loc, "utf-8"));
+
+ await rpl.edit({ content: `**Tenhle záznam (<@${user.id}>) byl vymazán z DB!**`, files: [loc], components: [] });
+
+ await dcLog(bot, i.guild.id, i.member,
+ {
+ title: "Smazání z DB",
+ description:
+ `**<@${i.user.id}> smazal <@${user.id}> z DB.**`
+ + `\n> **Jméno:** \`${worker.name}\``
+ + `\n> **Volačka:** \`${worker.radio}\``
+ + `\n> **Odznak:** \`${worker.badge}\``,
+ color: "#ff0000",
+ file: loc
+ }
+ );
fs.unlinkSync(loc);
- console.log(" < [CMD/DB] > " + i.member.displayName + ` smazal(a) DB záznam ${user.id}.json`);
-
- return await rpl.edit({ content: `**Tenhle záznam (<@${user.id}>) byl vymazán z DB!**`, files: [loc], components: [] });
+ return console.log(" < [CMD/DB] > " + i.member.displayName + ` smazal(a) DB záznam ${user.id}.json`);
});
collector.on('error', async () => {
-
return await rpl.edit({ content: "> 🛑 **Čas vypršel. Záznam nebyl smazán.**", components: [] });
});
@@ -221,8 +290,25 @@ export default async function run(bot, i) {
if (collected.size === 0) return await rpl.edit({ content: "> 🛑 **Čas vypršel. Záznam nebyl smazán.**", components: [] });
});
} else {
- i.reply({ content: `**Tenhle záznam (<@${user.id}>) byl vymazán z DB!**`, files: [loc], ephemeral: true });
+ worker = JSON.parse(fs.readFileSync(loc, "utf-8"));
+ if (bot.LEA.g.LSPD.includes(i.guild.id)) {
+ const oldFolder = await i.guild.channels.fetch(worker.folder);
+ await oldFolder.delete();
+ }
+ await i.reply({ content: `**Tenhle záznam (<@${user.id}>) byl vymazán z DB!**`, files: [loc], ephemeral: true });
console.log(" < [CMD/DB] > " + i.member.displayName + ` smazal(a) DB záznam ${user.id}.json`);
+ await dcLog(bot, i.guild.id, i.member,
+ {
+ title: "Smazání z DB",
+ description:
+ `**<@${i.user.id}> smazal <@${user.id}> z DB.**`
+ + `\n> **Jméno:** \`${worker.name}\``
+ + `\n> **Volačka:** \`${worker.radio}\``
+ + `\n> **Odznak:** \`${worker.badge}\``,
+ color: "#ff0000",
+ file: loc
+ }
+ );
return fs.unlinkSync(loc);
}
}
diff --git a/src/commands/duty.js b/src/commands/duty.js
index 42a8184..57b3487 100644
--- a/src/commands/duty.js
+++ b/src/commands/duty.js
@@ -10,7 +10,7 @@ export const slash = new SlashCommandBuilder()
export default async function run(bot, i) {
if (!(await checkDB(i.user.id))) return i.reply({ content: "> 🛑 **Před zadáváním __duties__ a __omluvenek__ tě musí admin přilásit do DB.**\nZalož si vlastní složku a počkej na správce DB.", ephemeral: true });
- const folders = ["1188146028440997948", "1193340608971018382"];
+ const folders = ["1203743211000963082", "1213984576100241419"];
let folder;
if (getServer(i.guild.id).id === 1) folder = folders[0];
else if (getServer(i.guild.id).id === 2) folder = folders[1];
@@ -20,7 +20,7 @@ export default async function run(bot, i) {
const modal = new ModalBuilder()
.setCustomId("dutyModal")
- .setTitle("SAHP | Zápis služby");
+ .setTitle("LEA | Zápis služby");
const today = new Date();
diff --git a/src/commands/event.js b/src/commands/event.js
deleted file mode 100644
index f6189cb..0000000
--- a/src/commands/event.js
+++ /dev/null
@@ -1,170 +0,0 @@
-import { SlashCommandBuilder } from "discord.js";
-import { ActionRowBuilder, AttachmentBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder, InteractionType, ModalBuilder, TextInputBuilder, TextInputStyle } from "discord.js";
-import fs from "fs";
-import path from "path";
-import { checkDB, checkEVENT, getServer } from "../../src/functions/db.js";
-
-export const slash = new SlashCommandBuilder()
- .setName("event")
- .setDescription(`Správa a informace o eventu`)
- .addSubcommand(subcommand =>
- subcommand
- .setName('faktura')
- .setDescription("Zápis faktury do eventu")
- )
- .addSubcommand(subcommand =>
- subcommand
- .setName('souhrn')
- .setDescription("Souhrn účastníka eventu")
- .addUserOption(option =>
- option.setName("účastník")
- .setDescription("Vyber účastníka")
- .setRequired(true))
- )
- .addSubcommand(subcommand =>
- subcommand
- .setName('žebříček')
- .setDescription("Žěbříček účastníků eventu")
- )
- .setDMPermission(false)
- .setNSFW(false);
-
-export default async function run(bot, i) {
- return i.reply({ content: "> 🛑 **Aktuálně žádný event neprobíhá!**", ephemeral: true });
- const sub = i.options._subcommand;
- const user = i.options.getUser("účastník");
-
- let passed = false;
- await i.guild.fetch();
- const admin = await i.member;if (admin.id === "411436203330502658") passed = true; //PetyXbron / b1ngo
- if (bot.LEA.g.SAHP.includes(i.guild.id) && !passed) {
- if (admin.roles.cache.has("1145344761402765343")) passed = true; //Staff team Refresh
- if (admin.roles.cache.has("1139266408681844887")) passed = true; //.
- if (admin.id === "607915400604286997") passed = true; //Samus
- if (admin.id === "436180906533715969") passed = true; //Mičut
- } else if (bot.LEA.g.LSSD.includes(i.guild.id) && !passed) {
- if (admin.roles.cache.has("1167182546904293481")) passed = true; //Staff team Refresh
- if (admin.roles.cache.has("1167182546904293482")) passed = true; //*
- if (admin.roles.cache.has("1190825815596875829")) passed = true; //.
- if (admin.id === "798644986215661589") passed = true; //Smouky
- if (admin.id === "829978476701941781") passed = true; //Frexik
- }
-
- if (bot.LEA.g.LSSD.includes(i.guild.id)) return i.reply({
- content: "> 🛑 **Příkazy , a nejsou aktuálně dostupné pro " + i.guild.name + ".**",
- ephemeral: true
- });
-
- if (sub === "faktura") { //Faktura
- const modal = new ModalBuilder()
- .setCustomId("fakturaModal")
- .setTitle("SAHP EVENT | Zápis faktury");
-
- const nameInput = new TextInputBuilder()
- .setCustomId("name")
- .setLabel("Jméno občana")
- .setStyle(TextInputStyle.Short)
- .setPlaceholder("Will Smith")
- .setRequired(true);
-
- const birthInput = new TextInputBuilder()
- .setCustomId("reason")
- .setLabel("Popis faktury")
- .setStyle(TextInputStyle.Paragraph)
- .setPlaceholder("Nelegální akce")
- .setRequired(true);
-
- const moneyInput = new TextInputBuilder()
- .setCustomId("money")
- .setLabel("Čáska faktury")
- .setStyle(TextInputStyle.Short)
- .setPlaceholder("15 000")
- .setMinLength(4)
- .setRequired(true);
-
- const actionRow0 = new ActionRowBuilder().addComponents(nameInput);
- const actionRow1 = new ActionRowBuilder().addComponents(birthInput);
- const actionRow2 = new ActionRowBuilder().addComponents(moneyInput);
-
- modal.addComponents(actionRow0, actionRow1, actionRow2);
-
- await i.showModal(modal);
- } else if (sub === "souhrn") { //Souhrn
- if (user.id !== i.user.id && !passed) return i.reply({ content: "> 🛑 **Můžeš zobrazit pouze svoje faktury.**", ephemeral: true });
- if (!(await checkEVENT(user.id))) return i.reply({ content: "> 🛑 **<@" + user.id + "> ještě nesoutěží.**", ephemeral: true });
-
- const eventer = JSON.parse(fs.readFileSync((path.resolve("./db/event") + "/" + user.id + ".json"), "utf-8"));
- const member = await i.guild.members.fetch(user.id);
-
- let invoices = [], values = [];
- for (const inv of eventer.invoices) {
- invoices.push(`ID: ${inv.id}\nDate: ${inv.shared}\nValue: ${inv.value} $`);
- values.push(inv.value);
- }
-
- const summaryEmbed = new EmbedBuilder()
- .setAuthor({ name: member.displayName, iconURL: member.displayAvatarURL() })
- .setTitle("EVENT | Souhrn " + eventer.name)
- .addFields([
- {
- name: "Statistika", inline: false,
- value:
- `> **Dohromady faktur:** \`${eventer.invoices.length.toLocaleString()}\`\n`
- + `> **Dohromady zadáno:** \`${eventer.stats.value.toLocaleString()} $\`\n`
- + `> **Průměrně zadáno:** \`${Math.trunc(values.reduce((a, c) => a + c, 0) / values.length).toLocaleString()} $\``
- },
- {
- name: "Faktury", inline: false,
- value:
- `Kvůli vysokému počtu dostupné v \`txt\` příloze.`
- }
- ])
- .setThumbnail("https://i.imgur.com/bGCFY6I.png")
- .setColor(bot.LEA.c.event)
- .setFooter(getServer(i.guild.id).footer);
- const listAtt = new AttachmentBuilder(Buffer.from(invoices.join("\n\n")), { name: "faktury.txt" });
-
- console.log(" < [EVE/Souhrn] > " + i.member.displayName + " zobrazil(a) souhrn " + member.displayName);
-
- return i.reply({ embeds: [summaryEmbed], files: [listAtt], ephemeral: true });
- } else if (sub === "žebříček") { //Žěbříček
- if (!passed) return i.reply({ content: "> 🛑 **Žebříček je už skrytý! To je napětí...**", ephemeral: true });
-
- let users = [];
- const eventDB = fs.readdirSync(path.resolve("./db/event")).filter(file => file.endsWith(".json") && file !== "000000000000000001.json");
- for (const file of eventDB) {
- const eventer = JSON.parse(fs.readFileSync((path.resolve("./db/event") + "/" + file), "utf-8"));
- const user = {
- id: file.split(".")[0],
- name: eventer.name,
- invoices: eventer.invoices.length,
- value: eventer.stats.value
- };
- users.push(user);
- }
- users = users.sort((a, b) => b.value - a.value);
- users = users.slice(0, 10);
-
- users.forEach((user, i) => {
- users[i] = `> ### ${i + 1}. <@${user.id}>\n> **Faktur:** \`${user.invoices.toLocaleString()}\`\n> **Hodnota:** \`${user.value.toLocaleString()} $\``;
- });
-
- const firstEmbed = new EmbedBuilder()
- .setTitle("EVENT | Žebříček (Top 1-5)")
- .setDescription(users.slice(0, 5).join("\n\n"))
- .setThumbnail("https://i.imgur.com/bGCFY6I.png")
- .setColor(bot.LEA.c.event)
- .setFooter(getServer(i.guild.id).footer);
-
- const secondEmbed = new EmbedBuilder()
- .setTitle("EVENT | Žebříček (Top 5-10)")
- .setDescription(users.slice(5, 10).join("\n\n"))
- .setThumbnail("https://i.imgur.com/bGCFY6I.png")
- .setColor(bot.LEA.c.event)
- .setFooter(getServer(i.guild.id).footer);
-
- console.log(" < [EVE/Žěbříček] > " + i.member.displayName + " zobrazil(a) žebříček");
-
- return i.reply({ embeds: [firstEmbed, secondEmbed], ephemeral: true });
- }
-};
\ No newline at end of file
diff --git a/src/commands/leader.js b/src/commands/leader.js
new file mode 100644
index 0000000..6f7abf2
--- /dev/null
+++ b/src/commands/leader.js
@@ -0,0 +1,301 @@
+import { ActionRowBuilder, AttachmentBuilder, EmbedBuilder, ModalBuilder, SlashCommandBuilder, TextInputBuilder, TextInputStyle } from "discord.js";
+import fs from "fs";
+import path from "path";
+import { checkDB, getServer } from "../functions/db.js";
+import bl from "../../db/blacklist.json" assert { type: "json" };
+import { dcLog } from "../../src/functions/logSystem.js";
+
+export const slash = new SlashCommandBuilder()
+ .setName("leader")
+ .setDescription(`Různé příkazy obecné správy pro Leadership`)
+ .addSubcommand(subcommand =>
+ subcommand
+ .setName('docházka')
+ .setDescription("Kontrola absence")
+ )
+ .addSubcommand(subcommand =>
+ subcommand
+ .setName('blacklist')
+ .setDescription("Správa blacklistu")
+ .addStringOption(option =>
+ option.setName("reason")
+ .setDescription("Důvod přidání na blacklist")
+ .setRequired(true))
+ .addUserOption(option =>
+ option.setName("discord")
+ .setDescription("Přidat Discord uživatele")
+ .setRequired(false))
+ )
+ .setDMPermission(false)
+ .setNSFW(false);
+
+export default async function run(bot, i) {
+ const sub = i.options._subcommand;
+
+ let passed = false;
+ await i.guild.fetch();
+ const admin = await i.member;
+ if (admin.id === "411436203330502658") passed = true; //PetyXbron / b1ngo
+ if (bot.LEA.g.LSPD.includes(i.guild.id) && !passed) {
+ if (admin.roles.cache.has("1154446249005690917")) passed = true; //Staff team Refresh
+ if (admin.roles.cache.has("1201813866548580443")) passed = true; //.
+ if (admin.roles.cache.has("1154446249005690916")) passed = true; //*
+ if (admin.id === "846451292388851722") passed = true; //aldix_eu
+ if (admin.id === "644571265725628437") passed = true; //griffin0s
+ } else if (bot.LEA.g.LSSD.includes(i.guild.id) && !passed) {
+ if (admin.roles.cache.has("1139267137651884072")) passed = true; //Leadership
+ if (admin.roles.cache.has("1139295201282764882")) passed = true; //FTO Commander
+ }
+
+ if (!passed) return i.reply({ content: "> 🛑 **K tomuhle má přístup jen admin.**", ephemeral: true });
+
+ if (sub === "docházka") {
+ const today = new Date();
+ const modal = new ModalBuilder()
+ .setCustomId("dochazkaModal")
+ .setTitle("LEA | Docházka");
+
+ const idInput = new TextInputBuilder()
+ .setCustomId("eventID")
+ .setLabel("ID události")
+ .setStyle(TextInputStyle.Short)
+ .setPlaceholder("1")
+ .setMaxLength(5)
+ .setRequired(true);
+
+ const dateInput = new TextInputBuilder()
+ .setCustomId("date")
+ .setLabel("Datum")
+ .setStyle(TextInputStyle.Short)
+ .setValue(today.getDate() + ". " + (parseInt(today.getMonth()) + 1) + ". " + today.getFullYear())
+ .setPlaceholder(today.getDate() + ". " + (parseInt(today.getMonth()) + 1) + ". " + today.getFullYear())
+ .setMinLength(10)
+ .setMaxLength(12)
+ .setRequired(true);
+
+ const ignoreInput = new TextInputBuilder()
+ .setCustomId("ignore")
+ .setLabel("Čísla odznaků zaměstnanců, které ignorovat")
+ .setStyle(TextInputStyle.Paragraph)
+ .setPlaceholder("1012, 1035, 1036, 1037, 1050, 1061")
+ .setRequired(false);
+
+ const actionRow0 = new ActionRowBuilder().addComponents(idInput);
+ const actionRow1 = new ActionRowBuilder().addComponents(dateInput);
+ const actionRow2 = new ActionRowBuilder().addComponents(ignoreInput);
+
+ modal.addComponents(actionRow0, actionRow1, actionRow2);
+
+ await i.showModal(modal);
+
+ let submit = await i.awaitModalSubmit({ filter: int => int.user.id === i.user.id, time: 600000 }).catch(e => {
+ return null;
+ });
+
+ if (submit) {
+ await submit.deferReply({ ephemeral: true });
+
+ const id = parseInt(submit.fields.getTextInputValue("eventID"));
+ const ignored = submit.fields.getTextInputValue("ignore").split(", ");
+ const eventDateArr = submit.fields.getTextInputValue("date").split(". ");
+ const eventDate = new Date(eventDateArr[1] + "/" + eventDateArr[0] + "/" + eventDateArr[2]);
+
+ let users = [], db;
+ if (bot.LEA.g.LSPD.includes(i.guild.id)) db = fs.readdirSync(path.resolve("./db/LSPD")).filter(file => file.endsWith(".json") && file !== "000000000000000001.json");
+ else if (bot.LEA.g.LSSD.includes(i.guild.id)) db = fs.readdirSync(path.resolve("./db/LSSD")).filter(file => file.endsWith(".json") && file !== "000000000000000001.json");
+ for (const file of db) {
+ let worker;
+ if (bot.LEA.g.LSPD.includes(i.guild.id)) worker = JSON.parse(fs.readFileSync((path.resolve("./db/LSPD") + "/" + file), "utf-8"));
+ else if (bot.LEA.g.LSSD.includes(i.guild.id)) worker = JSON.parse(fs.readFileSync((path.resolve("./db/LSSD") + "/" + file), "utf-8"));
+
+ let m;
+ try {
+ m = await i.guild.members.fetch(file.split(".")[0]);
+ } catch (e) {
+ m = false;
+ }
+
+ if (m) {
+ const ap = worker.apologies;
+ let apologized = false;
+ if (worker.badge < 1015) apologized = true;
+ if (ignored.includes(worker.badge.toString())) apologized = true;
+ if (m.roles.cache.has("1139267137651884072")) apologized = true;
+ if (!apologized) for (const a of ap) {
+ if (a.eventID === id) {
+ apologized = true;
+ } else {
+ const startDateArr = a.start.split(". ");
+ const startDate = new Date(startDateArr[1] + "/" + startDateArr[0] + "/" + startDateArr[2]);
+ const endDateArr = a.end.split(". ");
+ const endDate = new Date(endDateArr[1] + "/" + endDateArr[0] + "/" + endDateArr[2]);
+ if (eventDate.getTime() >= startDate.getTime() && eventDate <= endDate.getTime()) {
+ apologized = true;
+ }
+ }
+ }
+
+ if (!apologized) {
+ worker.id = file.split(".")[0];
+ users.push(worker);
+ }
+ }
+ }
+
+ users.sort((a, b) => a.badge - b.badge);
+ let mentions = [], list = [];
+ for (const u of users) {
+ mentions.push(`<@${u.id}>`);
+ }
+ const mentionsAtt = new AttachmentBuilder(Buffer.from(mentions.join(", ")), { name: "mentions.txt" });
+
+ for (const u of users) {
+ list.push(`[${u.radio}] ${u.name} [${u.badge}] | ${u.id}`);
+ }
+ const listAtt = new AttachmentBuilder(Buffer.from(list.join("\n")), { name: "list.txt" });
+
+ await submit.editReply({
+ files: [listAtt, mentionsAtt],
+ ephemeral: true
+ });
+ }
+ }
+
+ if (sub === "blacklist") {
+ //return i.reply({ content: "co zkousis?? to myslis vazne???", ephemeral: true });
+
+ let record, blUser, blMember, blReason, blDate;
+ blUser = i.options.getUser("discord"),
+ blReason = i.options.getString("reason"),
+ blDate = new Date();
+
+ if (blUser) {
+ await i.deferReply();
+ blMember = await i.guild.members.fetch(blUser.id).then(() => true).catch(() => false);
+ record = {
+ "name": blMember?.displayName || "",
+ "displayName": blUser.displayName,
+ "username": blUser.username,
+ "id": blUser.id,
+ "from": {
+ "dep": getServer(i.guild.id).name,
+ "name": i.member.displayName,
+ "username": i.user.username,
+ "displayName": i.user.displayName,
+ "id": i.user.id,
+ "timestamp": (blDate.getDate() + ". " + (parseInt(blDate.getMonth()) + 1) + ". " + blDate.getFullYear()),
+ "reason": blReason
+ }
+ };
+ } else {
+ const modal = new ModalBuilder()
+ .setCustomId("blModal")
+ .setTitle("LEA | Blacklist");
+
+ /*const idInput = new TextInputBuilder()
+ .setCustomId("discordID")
+ .setLabel("Discord ID pachatele")
+ .setStyle(TextInputStyle.Short)
+ .setPlaceholder("83886770768314368")
+ .setMinLength(15)
+ .setRequired(false);*/
+
+ const usernameInput = new TextInputBuilder()
+ .setCustomId("discordUsername")
+ .setLabel("Discord username pachatele")
+ .setStyle(TextInputStyle.Short)
+ .setPlaceholder("petyxbron")
+ .setMinLength(3)
+ .setRequired(false);
+
+ const displaynameInput = new TextInputBuilder()
+ .setCustomId("discordDisplayname")
+ .setLabel("Discord displayname pachatele")
+ .setStyle(TextInputStyle.Short)
+ .setPlaceholder("PetyXbron")
+ .setMinLength(3)
+ .setRequired(false);
+
+ const ICnameInput = new TextInputBuilder()
+ .setCustomId("ICname")
+ .setLabel("IC jméno pachatele")
+ .setStyle(TextInputStyle.Short)
+ .setPlaceholder("Tyler Pierce")
+ .setRequired(false);
+
+ const dateInput = new TextInputBuilder()
+ .setCustomId("date")
+ .setLabel("Datum blacklistu")
+ .setStyle(TextInputStyle.Short)
+ .setPlaceholder("24. 12. 2024")
+ .setMinLength(10)
+ .setMaxLength(12)
+ .setRequired(false);
+
+ /*const actionRow0 = new ActionRowBuilder().addComponents(idInput);*/
+ const actionRow0 = new ActionRowBuilder().addComponents(usernameInput);
+ const actionRow1 = new ActionRowBuilder().addComponents(displaynameInput);
+ const actionRow2 = new ActionRowBuilder().addComponents(ICnameInput);
+ const actionRow3 = new ActionRowBuilder().addComponents(dateInput);
+
+ modal.addComponents(actionRow0, actionRow1, actionRow2, actionRow3);
+
+ await i.showModal(modal);
+
+ var submit = await i.awaitModalSubmit({ filter: int => int.user.id === i.user.id, time: 600000 }).catch(e => {
+ return null;
+ });
+
+ if (submit) {
+ await submit.deferReply();
+ var /*bl_discordID = submit.fields.getTextInputValue("discordID"),*/
+ bl_discordUsername = submit.fields.getTextInputValue("discordUsername"),
+ bl_discordDisplayname = submit.fields.getTextInputValue("discordDisplayname"),
+ bl_ICname = submit.fields.getTextInputValue("ICname");
+
+ var bl_date = submit.fields.getTextInputValue("date")
+
+ record = {
+ "name": bl_ICname,
+ "displayName": bl_discordDisplayname,
+ "username": bl_discordUsername,
+ "id": "",
+ "from": {
+ "dep": getServer(i.guild.id).name,
+ "name": i.member.displayName,
+ "username": i.user.username,
+ "displayName": i.user.displayName,
+ "id": i.user.id,
+ "timestamp": bl_date,
+ "reason": blReason
+ }
+ };
+ }
+ }
+
+ bl.push(record);
+
+ fs.writeFileSync(path.resolve("./db/blacklist.json"), JSON.stringify(bl, null, 4), "utf-8");
+
+ const blEmbed = new EmbedBuilder()
+ .setTitle("Blacklist upraven!")
+ .setDescription(
+ `${blUser ? `<@${blUser.id}>` : `\`${bl_discordUsername}\``} byl(a) přidán(a) na blacklist.`
+ )
+ .setColor(getServer(i.guild.id).color)
+ .setFooter(getServer(i.guild.id).footer);
+
+ await dcLog(bot, i.guild.id, i.member,
+ {
+ title: "Úprava blacklistu",
+ description:
+ `**<@${i.user.id}> přidal(a) ${blUser ? `<@${blUser.id}>` : `\`${bl_discordUsername}\``} na BL.**`
+ + `\`\`\`json\n${JSON.stringify(record, null, 4)}\`\`\``,
+ color: "#000000"
+ }
+ );
+
+ if (submit) return await submit.editReply({ embeds: [blEmbed] });
+ else return await i.editReply({ embeds: [blEmbed] });
+ }
+};
\ No newline at end of file
diff --git a/src/commands/menu.js b/src/commands/menu.js
index 8cb122c..46f63de 100644
--- a/src/commands/menu.js
+++ b/src/commands/menu.js
@@ -49,7 +49,6 @@ export default async function run(bot, i) {
console.log(" < [CMD/Menu] > " + (i.member.displayName || i.user.displayName) + ` zobrazil(a) menu`);
const commands = fs.readdirSync(path.resolve("./src/commands")).filter(file => file.endsWith(".js"));
- const events = fs.readdirSync(path.resolve("./src/events")).filter(file => file.endsWith(".js"));
let helpEmbed = new EmbedBuilder()
.setTitle("Bot Menu")
.setFields([
@@ -63,14 +62,13 @@ export default async function run(bot, i) {
name: `Analytika`, inline: true,
value:
`> **Příkazů**: \`${commands.length}\``
- + `\n> **Eventů**: \`${events.length}\``
},
{
name: `Info`, inline: false,
value:
`> **Autor:** <@411436203330502658> ([web](https://petyxbron.cz/cs/p))
- > **Sloužím:** SAHP <:SAHP:1174876044570931210> a LSSD <:LSSD:1178106303198011412>
- > **FiveM:** RefreshRP 🌴
+ > **Sloužím:** LSPD <:LSPD:1178108366514565181> a LSSD <:LSSD:1178106303198011412>
+ > **FiveM:** NoLimit | RefreshRP 🌴
> **GitHub**: [petyxbron.cz/lea-bot](https://petyxbron.cz/lea-bot)`
},
{
@@ -81,12 +79,12 @@ export default async function run(bot, i) {
> **Jak Používat:** [/docs/usage.md](https://github.com/Azator-Entertainment/LEA-bot/blob/master/docs/usage.md)`
}
])
- .setColor(bot.LEA.c.LSPD)
- .setThumbnail(bot.LEA.i.LSPD)
+ .setColor(bot.LEA.c.LEAbot)
+ .setThumbnail(bot.user.avatarURL())
.setFooter({ text: `LEA Bot v${process.env.version} | Vytvořil b1ngo ✌️`, iconURL: bot.user.avatarURL() });
let group;
- if (bot.LEA.g.SAHP.includes(i.guild.id)) group = "**SAHP** " + bot.LEA.e.SAHP;
+ if (bot.LEA.g.LSPD.includes(i.guild.id)) group = "**LSPD** " + bot.LEA.e.LSPD;
else if (bot.LEA.g.LSSD.includes(i.guild.id)) group = "**LSSD** " + bot.LEA.e.LSSD;
else group = false;
diff --git a/src/commands/omluvenka.js b/src/commands/omluvenka.js
index 2db8a53..28e5754 100644
--- a/src/commands/omluvenka.js
+++ b/src/commands/omluvenka.js
@@ -10,7 +10,7 @@ export const slash = new SlashCommandBuilder()
export default async function run(bot, i) {
if (!(await checkDB(i.user.id))) return i.reply({ content: "> 🛑 **Před zadáváním __duties__ a __omluvenek__ tě musí admin přilásit do DB.**\nZalož si vlastní složku a počkej na správce DB.", ephemeral: true });
- const folders = ["1188146028440997948", "1193340608971018382"];
+ const folders = ["1203743211000963082", "1213984576100241419"];
let folder;
if (getServer(i.guild.id).id === 1) folder = folders[0];
else if (getServer(i.guild.id).id === 2) folder = folders[1];
@@ -20,7 +20,7 @@ export default async function run(bot, i) {
const modal = new ModalBuilder()
.setCustomId("apologyModal")
- .setTitle("SAHP | Zápis omluvenky");
+ .setTitle("LEA | Zápis omluvenky");
const today = new Date();
diff --git a/src/commands/online.js b/src/commands/online.js
index 7fef192..630632b 100644
--- a/src/commands/online.js
+++ b/src/commands/online.js
@@ -16,14 +16,14 @@ export default async function run(bot, i) {
ms = await ms.filter(m => !m.user.bot && m.presence);
let n = 0, on = [];
ms.forEach(m => {
- if (m.presence.activities.find(a => a.name === "RefreshRP")) {
+ if (m.presence.activities.find(a => a.name.includes("Nolimit RefreshRP"))) {
n++;
on.push(`<@${m.id}>`);
}
});
const onlineEmbed = new EmbedBuilder()
- .setAuthor({ name: "Online na RefreshRP", iconURL: "https://servers-live.fivem.net/servers/icon/994ldb/-1804725016.png" })
- .setDescription(`Členi **${i.guild.name}** hrající **RefreshRP** právě teď.`)
+ .setAuthor({ name: "Právě ve službě", iconURL: "https://servers-live.fivem.net/servers/icon/994ldb/-1386532708.png" })
+ .setDescription(`Členi **${getServer(i.guild.id).name}** hrající **NoLimit | RefreshRP** právě teď.`)
.addFields([
{
name: `Seznam`, inline: false,
diff --git a/src/commands/profil.js b/src/commands/profil.js
index 36f847c..d5aaa6a 100644
--- a/src/commands/profil.js
+++ b/src/commands/profil.js
@@ -42,7 +42,7 @@ export default async function run(bot, i) {
if (await checkDB(discord.id)) found = true, worker.id = discord.id;
}
if (!found) {
- db = fs.readdirSync(path.resolve("./db/SAHP")).filter(file => file.endsWith(".json") && file !== "000000000000000001.json");
+ db = fs.readdirSync(path.resolve("./db/LSPD")).filter(file => file.endsWith(".json") && file !== "000000000000000001.json");
db = db.concat(fs.readdirSync(path.resolve("./db/LSSD")).filter(file => file.endsWith(".json") && file !== "000000000000000001.json"));
for (const log of db) {
const gotDB = await getDB(log.split(".")[0]);
diff --git a/src/commands/rep.js b/src/commands/rep.js
new file mode 100644
index 0000000..240887b
--- /dev/null
+++ b/src/commands/rep.js
@@ -0,0 +1,17 @@
+import { EmbedBuilder, SlashCommandBuilder } from "discord.js";
+import { getServer } from "../../src/functions/db.js";
+
+export const slash = new SlashCommandBuilder()
+ .setName("rep")
+ .setDescription(`Přidat reputaci členovi LEA`)
+ .setDMPermission(false)
+ .setNSFW(false);
+
+//TODO:
+// - Jeden report za den (.lastRep) (date)
+// - Výběr +rep -rep
+// - Přidat do jeho db
+
+export default async function run(bot, i) {
+ return i.reply({ content: "> 🛑 **Tato funkce ještě nebyla dokončena! (ID rep.js)**", ephemeral: true });
+}
diff --git a/src/commands/u_profilZDB.js b/src/commands/u_profilZDB.js
new file mode 100644
index 0000000..b997531
--- /dev/null
+++ b/src/commands/u_profilZDB.js
@@ -0,0 +1,25 @@
+import { ContextMenuCommandBuilder, ApplicationCommandType } from "discord.js";
+import { checkDB } from "../functions/db.js";
+import { getProfile } from "../functions/profiles.js";
+
+export const context = new ContextMenuCommandBuilder()
+ .setName('Profil z DB')
+ .setType(ApplicationCommandType.User)
+ .setDMPermission(false);
+
+export default async function run(bot, i) {
+ const discord = i.targetUser;
+
+ let found = false, db = [], worker = { id: undefined, name: undefined, radio: undefined, badge: undefined };
+
+ if (await checkDB(discord.id)) found = true, worker.id = discord.id;
+ if (!found) return i.reply({ content: "> 🛑 **Nikdo ze zadaných parametrů nebyl nalezen.**", ephemeral: true });
+
+ const profile = await getProfile(bot, worker.id);
+
+ if (!profile) return i.reply({ content: "> 🛑 **Chyba!**", ephemeral: true });
+
+ console.log(" < [CMD/Profil] > " + i.user.tag + ` zobrazil(a) profil ${worker.id}.json`);
+
+ await i.reply({ embeds: [profile], ephemeral: true });
+};
\ No newline at end of file
diff --git a/src/commands/u_registrovatDoDB.js b/src/commands/u_registrovatDoDB.js
new file mode 100644
index 0000000..13976ef
--- /dev/null
+++ b/src/commands/u_registrovatDoDB.js
@@ -0,0 +1,87 @@
+import { ActionRowBuilder, ApplicationCommandType, ButtonBuilder, ButtonStyle, ContextMenuCommandBuilder, ModalBuilder, SlashCommandBuilder, TextInputBuilder, TextInputStyle } from "discord.js";
+import fs from "fs";
+import path from "path";
+import { checkDB, getDB } from "../functions/db.js";
+import { dcLog } from "../functions/logSystem.js";
+
+export const context = new ContextMenuCommandBuilder()
+ .setName('Registrovat do DB')
+ .setType(ApplicationCommandType.User)
+ .setDMPermission(false);
+
+export default async function run(bot, i) {
+ const user = i.targetUser;
+
+ let passed = false;
+ await i.guild.fetch();
+ const admin = await i.member;
+ if (admin.id === "411436203330502658") passed = true; //PetyXbron / b1ngo
+ if (bot.LEA.g.LSPD.includes(i.guild.id) && !passed) {
+ if (admin.roles.cache.has("1154446249005690917")) passed = true; //Staff team Refresh
+ if (admin.roles.cache.has("1201813866548580443")) passed = true; //.
+ if (admin.roles.cache.has("1154446249005690916")) passed = true; //*
+ if (admin.id === "846451292388851722") passed = true; //aldix_eu
+ if (admin.id === "644571265725628437") passed = true; //griffin0s
+ } else if (bot.LEA.g.LSSD.includes(i.guild.id) && !passed) {
+ if (admin.roles.cache.has("1139267137651884072")) passed = true; //Leadership
+ if (admin.roles.cache.has("1139295201282764882")) passed = true; //FTO Commander
+ }
+
+ if (!passed) return i.reply({ content: "> 🛑 **K tomuhle má přístup jen admin.**", ephemeral: true });
+
+ if (await checkDB(user.id)) {
+ const gotDB = await getDB(user.id);
+ return i.reply({ content: `> 🛑 <@${user.id}> **už je v DB. (Členem ${gotDB.guildName}.)**`, ephemeral: true });
+ }
+
+ const modal = new ModalBuilder()
+ .setCustomId("loginModal")
+ .setTitle("LEA | Přihlášení");
+
+ const idInput = new TextInputBuilder()
+ .setCustomId("id")
+ .setLabel("ID Discord člena")
+ .setStyle(TextInputStyle.Short)
+ .setValue(user.id.toString())
+ .setRequired(true);
+
+ const nameInput = new TextInputBuilder()
+ .setCustomId("name")
+ .setLabel("Jméno")
+ .setStyle(TextInputStyle.Short)
+ .setPlaceholder("Will Smith")
+ .setRequired(true);
+
+ const callInput = new TextInputBuilder()
+ .setCustomId("call")
+ .setLabel("Volačka")
+ .setStyle(TextInputStyle.Short)
+ .setPlaceholder("Heaven-2")
+ .setRequired(true);
+
+ const badgeInput = new TextInputBuilder()
+ .setCustomId("badge")
+ .setLabel("Číslo odznaku")
+ .setStyle(TextInputStyle.Short)
+ .setPlaceholder("1033")
+ .setMinLength(4)
+ .setMaxLength(4)
+ .setRequired(true);
+
+ const rankInput = new TextInputBuilder()
+ .setCustomId("rank")
+ .setLabel("Hodnost")
+ .setStyle(TextInputStyle.Short)
+ .setPlaceholder("Trooper II")
+ .setRequired(true);
+
+ const actionRow0 = new ActionRowBuilder().addComponents(idInput);
+ const actionRow1 = new ActionRowBuilder().addComponents(nameInput);
+ const actionRow2 = new ActionRowBuilder().addComponents(callInput);
+ const actionRow3 = new ActionRowBuilder().addComponents(badgeInput);
+ const actionRow4 = new ActionRowBuilder().addComponents(rankInput);
+
+ modal.addComponents(actionRow0, actionRow1, actionRow2, actionRow3, actionRow4);
+
+ await i.showModal(modal);
+};
\ No newline at end of file
diff --git a/src/commands/u_smazatZDB.js b/src/commands/u_smazatZDB.js
new file mode 100644
index 0000000..af91407
--- /dev/null
+++ b/src/commands/u_smazatZDB.js
@@ -0,0 +1,111 @@
+import { ActionRowBuilder, ApplicationCommandType, ButtonBuilder, ButtonStyle, ContextMenuCommandBuilder, ModalBuilder, SlashCommandBuilder, TextInputBuilder, TextInputStyle } from "discord.js";
+import fs from "fs";
+import path from "path";
+import { checkDB, getDB } from "../functions/db.js";
+import { dcLog } from "../functions/logSystem.js";
+
+export const context = new ContextMenuCommandBuilder()
+ .setName('Smazat z DB')
+ .setType(ApplicationCommandType.User)
+ .setDMPermission(false);
+
+export default async function run(bot, i) {
+ const user = i.targetUser;
+
+ let passed = false;
+ await i.guild.fetch();
+ const admin = await i.member;
+ if (admin.id === "411436203330502658") passed = true; //PetyXbron / b1ngo
+ if (bot.LEA.g.LSPD.includes(i.guild.id) && !passed) {
+ if (admin.roles.cache.has("1154446249005690917")) passed = true; //Staff team Refresh
+ if (admin.roles.cache.has("1201813866548580443")) passed = true; //.
+ if (admin.roles.cache.has("1154446249005690916")) passed = true; //*
+ if (admin.id === "846451292388851722") passed = true; //aldix_eu
+ if (admin.id === "644571265725628437") passed = true; //griffin0s
+ } else if (bot.LEA.g.LSSD.includes(i.guild.id) && !passed) {
+ if (admin.roles.cache.has("1139267137651884072")) passed = true; //Leadership
+ if (admin.roles.cache.has("1139295201282764882")) passed = true; //FTO Commander
+ }
+
+ if (!passed) return i.reply({ content: "> 🛑 **K tomuhle má přístup jen admin.**", ephemeral: true });
+
+ if (!(await checkDB(user.id))) return i.reply({ content: "> 🛑 <@" + user.id + "> **už není v DB.**", ephemeral: true });
+
+ let loc, worker;
+ if (bot.LEA.g.LSPD.includes(i.guild.id)) loc = path.resolve("./db/LSPD") + "/" + user.id + ".json";
+ else if (bot.LEA.g.LSSD.includes(i.guild.id)) loc = path.resolve("./db/LSSD") + "/" + user.id + ".json";
+ else return i.reply({ content: "> 🛑 **Tenhle server není uveden a seznamu.**\nKontaktuj majitele (viz. ).", ephemeral: true });
+
+ const admins = [
+ "411436203330502658"/*b1ngo*/, "607915400604286997"/*samus*/, "436180906533715969"/*micut*/,
+ "846451292388851722"/*aldix_eu*/, "644571265725628437"/*griffin0s*/
+ ];
+
+ if (!fs.existsSync(loc)) {
+ if (!admins.includes(admin.id)) return i.reply({ content: "> 🛑 **<@" + user.id + "> je v jiném sboru. Nemůžeš ho odebrat!**", ephemeral: true });
+
+ const row = new ActionRowBuilder()
+ .addComponents(
+ new ButtonBuilder()
+ .setCustomId('confirmOtherSborDelete')
+ .setLabel('Opravdu smazat')
+ .setStyle(ButtonStyle.Danger)
+ .setEmoji('🛑'),
+ );
+ const rpl = await i.reply({ content: "> ⚠️ **<@" + user.id + "> je v DB jiného sboru. Opravdu chceš záznam odebrat?** *(30s na odpověď)*", ephemeral: true, components: [row] });
+
+ const filter = i => i.customId === 'confirmOtherSborDelete' && i.user.id === admin.id;
+
+ const collector = rpl.createMessageComponentCollector({
+ filter, max: 1, time: 30000
+ });
+
+ collector.on('collect', async i => {
+ if (bot.LEA.g.LSPD.includes(i.guild.id)) loc = path.resolve("./db/LSSD") + "/" + user.id + ".json", worker = JSON.parse(fs.readFileSync(loc, "utf-8"));
+ else if (bot.LEA.g.LSSD.includes(i.guild.id)) loc = path.resolve("./db/LSPD") + "/" + user.id + ".json", worker = JSON.parse(fs.readFileSync(loc, "utf-8"));
+
+ await rpl.edit({ content: `**Tenhle záznam (<@${user.id}>) byl vymazán z DB!**`, files: [loc], components: [] });
+
+ await dcLog(bot, i.guild.id, i.member,
+ {
+ title: "Smazání z DB",
+ description:
+ `**<@${i.user.id}> smazal <@${user.id}> z DB.**`
+ + `\n> **Jméno:** \`${worker.name}\``
+ + `\n> **Volačka:** \`${worker.radio}\``
+ + `\n> **Odznak:** \`${worker.badge}\``,
+ color: "#ff0000",
+ file: loc
+ }
+ );
+
+ fs.unlinkSync(loc);
+ return console.log(" < [CMD/DB] > " + i.member.displayName + ` smazal(a) DB záznam ${user.id}.json`);
+ });
+
+ collector.on('error', async () => {
+ return await rpl.edit({ content: "> 🛑 **Čas vypršel. Záznam nebyl smazán.**", components: [] });
+ });
+
+ collector.on('end', async collected => {
+ if (collected.size === 0) return await rpl.edit({ content: "> 🛑 **Čas vypršel. Záznam nebyl smazán.**", components: [] });
+ });
+ } else {
+ worker = JSON.parse(fs.readFileSync(loc, "utf-8"));
+ await i.reply({ content: `**Tenhle záznam (<@${user.id}>) byl vymazán z DB!**`, files: [loc], ephemeral: true });
+ console.log(" < [CMD/DB] > " + i.member.displayName + ` smazal(a) DB záznam ${user.id}.json`);
+ await dcLog(bot, i.guild.id, i.member,
+ {
+ title: "Smazání z DB",
+ description:
+ `**<@${i.user.id}> smazal <@${user.id}> z DB.**`
+ + `\n> **Jméno:** \`${worker.name}\``
+ + `\n> **Volačka:** \`${worker.radio}\``
+ + `\n> **Odznak:** \`${worker.badge}\``,
+ color: "#ff0000",
+ file: loc
+ }
+ );
+ return fs.unlinkSync(loc);
+ }
+};
\ No newline at end of file
diff --git a/src/commands/u_upravitVDB.js b/src/commands/u_upravitVDB.js
new file mode 100644
index 0000000..a441633
--- /dev/null
+++ b/src/commands/u_upravitVDB.js
@@ -0,0 +1,93 @@
+import { ActionRowBuilder, ApplicationCommandType, ButtonBuilder, ButtonStyle, ContextMenuCommandBuilder, ModalBuilder, SlashCommandBuilder, TextInputBuilder, TextInputStyle } from "discord.js";
+import fs from "fs";
+import path from "path";
+import { checkDB, getDB } from "../../src/functions/db.js";
+import { dcLog } from "../../src/functions/logSystem.js";
+
+export const context = new ContextMenuCommandBuilder()
+ .setName('Upravit v DB')
+ .setType(ApplicationCommandType.User)
+ .setDMPermission(false);
+
+export default async function run(bot, i) {
+ const user = i.targetUser;
+
+ let passed = false;
+ await i.guild.fetch();
+ const admin = await i.member;
+ if (admin.id === "411436203330502658") passed = true; //PetyXbron / b1ngo
+ if (bot.LEA.g.LSPD.includes(i.guild.id) && !passed) {
+ if (admin.roles.cache.has("1154446249005690917")) passed = true; //Staff team Refresh
+ if (admin.roles.cache.has("1201813866548580443")) passed = true; //.
+ if (admin.roles.cache.has("1154446249005690916")) passed = true; //*
+ if (admin.id === "846451292388851722") passed = true; //aldix_eu
+ if (admin.id === "644571265725628437") passed = true; //griffin0s
+ } else if (bot.LEA.g.LSSD.includes(i.guild.id) && !passed) {
+ if (admin.roles.cache.has("1139267137651884072")) passed = true; //Leadership
+ if (admin.roles.cache.has("1139295201282764882")) passed = true; //FTO Commander
+ }
+
+ if (!passed) return i.reply({ content: "> 🛑 **K tomuhle má přístup jen admin.**", ephemeral: true });
+
+ if (!(await checkDB(user.id))) return i.reply({ content: "> 🛑 <@" + user.id + "> **už není v DB.**", ephemeral: true });
+
+ const gotDB = await getDB(user.id);
+ const data = gotDB.data;
+ if (!bot.LEA.g[gotDB.guildName].includes(i.guild.id)) return i.reply({ content: `> 🛑 **<@${user.id}> je členem \`${gotDB.guildName}\`!** (Nemůžeš ho upravit)`, ephemeral: true });
+
+ const modal = new ModalBuilder()
+ .setCustomId("editModal")
+ .setTitle("LEA | Úprava DB");
+
+ const idInput = new TextInputBuilder()
+ .setCustomId("id")
+ .setLabel("ID Discord člena")
+ .setStyle(TextInputStyle.Short)
+ .setPlaceholder(user.id)
+ .setValue(user.id)
+ .setRequired(true);
+
+ const nameInput = new TextInputBuilder()
+ .setCustomId("name")
+ .setLabel("Jméno")
+ .setStyle(TextInputStyle.Short)
+ .setPlaceholder(data.name)
+ .setValue(data.name)
+ .setRequired(true);
+
+ const callInput = new TextInputBuilder()
+ .setCustomId("call")
+ .setLabel("Volačka")
+ .setStyle(TextInputStyle.Short)
+ .setPlaceholder(data.radio)
+ .setValue(data.radio)
+ .setRequired(true);
+
+ const badgeInput = new TextInputBuilder()
+ .setCustomId("badge")
+ .setLabel("Číslo odznaku")
+ .setStyle(TextInputStyle.Short)
+ .setPlaceholder(data.badge.toString())
+ .setValue(data.badge.toString())
+ .setMinLength(4)
+ .setMaxLength(4)
+ .setRequired(true);
+
+ const rankInput = new TextInputBuilder()
+ .setCustomId("rank")
+ .setLabel("Hodnost")
+ .setStyle(TextInputStyle.Short)
+ .setPlaceholder(data.rank)
+ .setValue(data.rank)
+ .setRequired(true);
+
+ const actionRow0 = new ActionRowBuilder().addComponents(idInput);
+ const actionRow1 = new ActionRowBuilder().addComponents(nameInput);
+ const actionRow2 = new ActionRowBuilder().addComponents(callInput);
+ const actionRow3 = new ActionRowBuilder().addComponents(badgeInput);
+ const actionRow4 = new ActionRowBuilder().addComponents(rankInput);
+
+ modal.addComponents(actionRow0, actionRow1, actionRow2, actionRow3, actionRow4);
+
+ await i.showModal(modal);
+};
\ No newline at end of file
diff --git a/src/commands/u_zkontrolovatVDB.js b/src/commands/u_zkontrolovatVDB.js
new file mode 100644
index 0000000..a3e7cae
--- /dev/null
+++ b/src/commands/u_zkontrolovatVDB.js
@@ -0,0 +1,47 @@
+import { ActionRowBuilder, ApplicationCommandType, ButtonBuilder, ButtonStyle, ContextMenuCommandBuilder, ModalBuilder, SlashCommandBuilder, TextInputBuilder, TextInputStyle } from "discord.js";
+import fs from "fs";
+import path from "path";
+import { checkDB, getDB } from "../functions/db.js";
+import { dcLog } from "../functions/logSystem.js";
+
+export const context = new ContextMenuCommandBuilder()
+ .setName('Zkontrolovat v DB')
+ .setType(ApplicationCommandType.User)
+ .setDMPermission(false);
+
+export default async function run(bot, i) {
+ const user = i.targetUser;
+
+ let passed = false;
+ await i.guild.fetch();
+ const admin = await i.member;
+ if (admin.id === "411436203330502658") passed = true; //PetyXbron / b1ngo
+ if (bot.LEA.g.LSPD.includes(i.guild.id) && !passed) {
+ if (admin.roles.cache.has("1154446249005690917")) passed = true; //Staff team Refresh
+ if (admin.roles.cache.has("1201813866548580443")) passed = true; //.
+ if (admin.roles.cache.has("1154446249005690916")) passed = true; //*
+ if (admin.id === "846451292388851722") passed = true; //aldix_eu
+ if (admin.id === "644571265725628437") passed = true; //griffin0s
+ } else if (bot.LEA.g.LSSD.includes(i.guild.id) && !passed) {
+ if (admin.roles.cache.has("1139267137651884072")) passed = true; //Leadership
+ if (admin.roles.cache.has("1139295201282764882")) passed = true; //FTO Commander
+ }
+
+ if (!passed) return i.reply({ content: "> 🛑 **K tomuhle má přístup jen admin.**", ephemeral: true });
+
+ if (!(await checkDB(user.id))) return i.reply({ content: "> 🛑 <@" + user.id + "> **není v DB.**", ephemeral: true });
+
+ let log, sbor;
+ if (bot.LEA.g.LSPD.includes(i.guild.id)) log = path.resolve("./db/LSPD") + "/" + user.id + ".json", sbor = "LSPD";
+ else if (bot.LEA.g.LSSD.includes(i.guild.id)) log = path.resolve("./db/LSSD") + "/" + user.id + ".json", sbor = "LSSD";
+ else return i.reply({ content: "> 🛑 **Tenhle server není uveden a seznamu.**\nKontaktuj majitele (viz. ).", ephemeral: true });
+
+ if (!fs.existsSync(log)) {
+ if (bot.LEA.g.LSPD.includes(i.guild.id)) log = path.resolve("./db/LSSD") + "/" + user.id + ".json", sbor = "LSSD";
+ else if (bot.LEA.g.LSSD.includes(i.guild.id)) log = path.resolve("./db/LSPD") + "/" + user.id + ".json", sbor = "LSPD";
+ }
+
+ console.log(" < [CMD/DB] > " + i.member.displayName + ` zobrazil(a) DB záznam ${user.id}.json`);
+
+ i.reply({ content: `> ✅ **<@${user.id}>, členem \`${sbor}\`**`, files: [log], ephemeral: true });
+};
\ No newline at end of file
diff --git a/src/events/api.js b/src/events/api.js
new file mode 100644
index 0000000..d780c4d
--- /dev/null
+++ b/src/events/api.js
@@ -0,0 +1,196 @@
+import path from "path";
+import fetch from "node-fetch";
+import fs from "fs";
+import { config as secret } from "dotenv";
+
+export default async function api(bot, app) {
+ //Login feature
+ app.post('/api/login/getToken', async (req, res) => {
+ const tokenResponseData = await fetch('https://discord.com/api/oauth2/token', {
+ method: 'POST',
+ body: new URLSearchParams({
+ client_id: secret().parsed.botClientID,
+ client_secret: secret().parsed.botClientSecret,
+ code: req.body.code,
+ grant_type: 'authorization_code',
+ redirect_uri: secret().parsed.web,
+ scope: 'identify+guilds+guilds.members.read',
+ }).toString(),
+ headers: {
+ 'Content-Type': 'application/x-www-form-urlencoded',
+ },
+ });
+
+ return res.json(await tokenResponseData.json());
+ });
+
+ app.get("/api/login/getMe", async (req, res) => {
+ const authString = req.headers.authorization;
+ const me = await fetch('https://discord.com/api/users/@me', {
+ headers: {
+ authorization: authString,
+ },
+ });
+ if (!me.ok) return false;
+ const response = await me.json();
+ const { id, global_name } = response;
+
+ console.log(` < [PS/Login] > Fetch: ${response.global_name} | ${response.username} | ${response.id}`);
+
+ res.json({ id, global_name });
+ });
+
+ app.get("/api/db/getTable/:dep(LSSD|LSPD)", async (req, res) => {
+ const dep = req.params.dep;
+ const authString = req.headers.authorization;
+ const verifyResponse = await fetch(secret().parsed.web + "/api/login/verifyMe", {
+ method: 'GET',
+ headers: {
+ authorization: authString,
+ },
+ });
+ if (!verifyResponse.ok) return res.json({ passed: false, username: "xxx", id: "000", displayName: "XXX", workers: [] });
+ const { passed, username, id, displayName, avatar } = await verifyResponse.json();
+ if (!passed) return res.json({ passed: false, username, id, displayName, avatar, workers: [] });
+
+ const guild = await bot.guilds.fetch(dep === "LSSD" ? "1139266097921675345" : "1154446248934387828");
+ await guild.members.fetch();
+
+ let final = [], workers = 0;
+ const db = fs.readdirSync(path.resolve("./db/" + dep)).filter(file => file.endsWith(".json") && file !== "000000000000000001.json");
+ for (const file of db) {
+ let worker = JSON.parse(fs.readFileSync((path.resolve("./db/" + dep) + "/" + file), "utf-8"));
+
+ worker.discordID = file.split(".json")[0],
+ worker.tag = worker.radio.toLowerCase().replaceAll("-", ""),
+ worker.header = { red: false };
+ let hours0 = false,
+ moHours = 0;
+
+ worker.m = await guild.members.cache.get(worker.discordID);
+ worker.u = worker.m?.user || false;
+ if (!worker.m) worker.header.red = true, worker.m = false;
+
+ worker.roles = { omluvenka: false, warn: false, suspend: false, redat: false }, worker.div = [];
+ for (const a of worker.apologies) {
+ if (a.removed) continue;
+ const startDateArr = a.start.split(". ");
+ const startDate = new Date(startDateArr[1] + "/" + startDateArr[0] + "/" + startDateArr[2]);
+ const endDateArr = a.end.split(". ");
+ const endDate = new Date(endDateArr[1] + "/" + endDateArr[0] + "/" + endDateArr[2]);
+ const now = new Date();
+ now.setHours(0, 0, 0, 0);
+ if (now.getTime() >= startDate.getTime() && now.getTime() <= endDate.getTime()) {
+ worker.roles.omluvenka = true;
+ break;
+ }
+ }
+
+ if (dep === "LSSD" && worker.m) { //ONLY LSSD!
+ worker.roles.warn = worker.m.roles.cache.has("1139379787324997722");
+ worker.roles.suspend = worker.m.roles.cache.has("1139379875610898522");
+ if (worker.m.roles.cache.has("1139275625740370001")) worker.div.push("SRT");
+ if (worker.m.roles.cache.has("1139296112117817534")) worker.div.push("DEA");
+ if (worker.m.roles.cache.has("1139293160602874066")) worker.div.push("ST");
+ if (worker.m.roles.cache.has("1139294859354710188")) worker.div.push("AU");
+ if (worker.m.roles.cache.has("1139297065063690315")) worker.div.push("TU");
+ if (worker.m.roles.cache.has("1139298429391089685")) worker.div.push("MBU");
+ if (worker.m.roles.cache.has("1139295387266580652")) worker.div.push("FTO");
+ if (worker.m.roles.cache.has("1139297368450277376")) worker.div.push("CID");
+ if (
+ !worker.m.roles.cache.has("1139267137651884072")
+ && !worker.roles.omluvenka
+ && (Math.round((worker.hours + Number.EPSILON) * 100) / 100) === 0
+ ) hours0 = true;
+ } else if (dep === "LSPD" && worker.m) {
+ worker.roles.warn = worker.m.roles.cache.has("1154446248934387830");
+ worker.roles.suspend = worker.m.roles.cache.has("1154446248934387831");
+ if (worker.m.roles.cache.has("1205534460733296700")) worker.div.push("METRO");
+ if (worker.m.roles.cache.has("1154446248934387836")) worker.div.push("SWAT");
+ if (worker.m.roles.cache.has("1154446248946978950")) worker.div.push("MBU");
+ if (worker.m.roles.cache.has("1154446248946978948")) worker.div.push("AU");
+ if (worker.m.roles.cache.has("1156133057393336331")) worker.div.push("FTO");
+ if (worker.m.roles.cache.has("1154446248934387832")) worker.div.push("ST");
+ if (
+ !worker.m.roles.cache.has("1154446248967938179")
+ && !worker.roles.omluvenka
+ && (Math.round((worker.hours + Number.EPSILON) * 100) / 100) === 0
+ ) hours0 = true;
+ }
+
+ if (worker.roles.suspend || hours0) worker.header.red = true;
+
+ await worker.duties.filter(d => !d.removed).forEach(function (duty) {
+ const dutyDateArr = duty.date.split(". ");
+ const dutyDate = new Date(dutyDateArr[1] + "/" + dutyDateArr[0] + "/" + dutyDateArr[2]).getTime();
+ const todayDate = new Date().getTime();
+ const ms30days = 1000 * 60 * 60 * 24 * 30;
+
+ if (todayDate - dutyDate < ms30days) moHours = moHours + duty.hours;
+ });
+
+ worker.hours0 = hours0;
+ final.push(worker);
+ workers++;
+ }
+
+ console.log(` < [PS/Login] > Tables generated: ${dep} (${workers}w) | ${displayName} | ${username} | ${id}`);
+
+ res.json({ passed: true, username, id, displayName, avatar, workers: final });
+ });
+
+ app.get("/api/login/verifyMe", async (req, res) => {
+ const authString = req.headers.authorization;
+ let me, lssd, lspd, meR, lssdR, lspdR, r, rBy, passed = false;
+
+ lssd = await fetch('https://discord.com/api/users/@me/guilds/1139266097921675345/member', {
+ headers: {
+ authorization: authString,
+ },
+ });
+
+ if (lssd.ok) {
+ lssdR = await lssd.json();
+ passed = lssdR.roles.includes("1139267137651884072");
+ } else {
+ me = await fetch('https://discord.com/api/users/@me', {
+ headers: {
+ authorization: authString,
+ },
+ });
+ if (!me.ok) {
+ console.log(" < [PS/Login] > Verify: " + "XXX" + " has not been verified");
+ return res.json({ passed: false, username: undefined, id: undefined, displayName: undefined, avatar: undefined });
+ } else meR = await me.json();
+ }
+
+ if (!passed) {
+ lspd = await fetch('https://discord.com/api/users/@me/guilds/1154446248934387828/member', {
+ headers: {
+ authorization: authString,
+ },
+ });
+ if (lspd.ok) {
+ lspdR = await lspd.json();
+ passed = lspdR.roles.includes("1154446248967938179");
+ if (passed) r = lspdR, rBy = "LSPD";
+ else r = lspdR, rBy = false;
+ }
+ } else if (lssd.ok) r = lssdR, rBy = "LSSD";
+ else if (!lssd.ok) r = undefined, rBy = null;
+
+ if (!lssd.ok && me.ok) {
+ console.log(" < [PS/Login] > Verify: " + meR.user.username + " has not been verified (LSSD verify check failed)");
+ return res.json({ passed: false, username: meR.user.username, id: meR.user.id, displayName: meR.user.global_name, avatar: meR.user.avatar });
+ }
+
+ if (passed) console.log(" < [PS/Login] > Verify: " + r.user.username + " verified from " + rBy);
+ else console.log(" < [PS/Login] > Verify: " + "XXX" + " has not been verified");
+ return res.json({ passed, username: r?.user.username, id: r?.user.id, displayName: r?.user.global_name, avatar: r?.user.avatar });
+ });
+
+ //DONE
+ app.listen(secret().parsed.webPort, () => {
+ console.log(` < [PS/Web] > LEA Bot tables are now available at IP:${secret().parsed.webPort}!`);
+ });
+}
\ No newline at end of file
diff --git a/src/events/interactionCreate.js b/src/events/interactionCreate.js
index c88a49d..2065520 100644
--- a/src/events/interactionCreate.js
+++ b/src/events/interactionCreate.js
@@ -1,14 +1,29 @@
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChannelType, EmbedBuilder, InteractionType, ModalBuilder, TextInputBuilder, TextInputStyle, time } from "discord.js";
import fs from "fs";
import path from "path";
-import { checkDB, checkEVENT, getServer } from "../../src/functions/db.js";
-import { dg } from "../../src/functions/logSystem.js";
-import { update } from "../../web/script.js";
+import { checkDB, getServer } from "../../src/functions/db.js";
+import { dcLog } from "../../src/functions/logSystem.js";
export default async function (bot, i) {
- if (i.type === InteractionType.ApplicationCommand) {
- //return i.reply({ content: "> 🛑 **Probíhá údržba bota!**", ephemeral: true });
- const command = bot.slashes.get(i.commandName);
+ if (
+ !i.isUserContextMenuCommand()
+ && i.type !== InteractionType.ApplicationCommand
+ && i.type !== InteractionType.MessageComponent
+ && i.type !== InteractionType.ModalSubmit
+ ) return;
+
+ /*console.log(" < [CMD/*] > " + i.user.username + ` se pokusil o příkaz při údržbě!`);
+ return i.reply({
+ content:
+ `> 🛑 ***Probíhá údržba bota!***
+ > Odhadovaný konec:
+ > Správce: <@411436203330502658>`,
+ ephemeral: true });*/
+
+ if (i.isUserContextMenuCommand() || i.type === InteractionType.ApplicationCommand) {
+ let cmdName = i.commandName;
+ if (i.isUserContextMenuCommand()) cmdName = i.commandName.toLowerCase().replaceAll(" ", "");
+ const command = bot.slashes.get(cmdName);
if (command) {
command.default(bot, i);
}
@@ -20,17 +35,15 @@ export default async function (bot, i) {
await i.guild.fetch();
const admin = await i.member;
if (admin.id === "411436203330502658") passed = true; //PetyXbron / b1ngo
- if (bot.LEA.g.SAHP.includes(i.guild.id) && !passed) {
- if (admin.roles.cache.has("1145344761402765343")) passed = true; //Staff team Refresh
- if (admin.roles.cache.has("1139266408681844887")) passed = true; //.
- if (admin.id === "607915400604286997") passed = true; //Samus
- if (admin.id === "436180906533715969") passed = true; //Mičut
- } else if (bot.LEA.g.LSSD.includes(i.guild.id) && !passed) {
+ if (bot.LEA.g.LSPD.includes(i.guild.id) && !passed) {
if (admin.roles.cache.has("1167182546904293481")) passed = true; //Staff team Refresh
if (admin.roles.cache.has("1167182546904293482")) passed = true; //*
if (admin.roles.cache.has("1190825815596875829")) passed = true; //.
- if (admin.id === "798644986215661589") passed = true; //Smouky
- if (admin.id === "829978476701941781") passed = true; //Frexik
+ if (admin.id === "846451292388851722") passed = true; //aldix_eu
+ if (admin.id === "644571265725628437") passed = true; //griffin0s
+ } else if (bot.LEA.g.LSSD.includes(i.guild.id) && !passed) {
+ if (admin.roles.cache.has("1139267137651884072")) passed = true; //Leadership
+ if (admin.roles.cache.has("1139295201282764882")) passed = true; //FTO Commander
}
if (admin.id === i.message.interaction.user.id) passed = true; //Owner
if (!passed) {
@@ -45,7 +58,7 @@ export default async function (bot, i) {
if (type === 0) {
const modal = new ModalBuilder()
.setCustomId("dutyOWModal")
- .setTitle("SAHP | Přepis služby");
+ .setTitle("LEA | Přepis služby");
const today = new Date();
@@ -87,7 +100,7 @@ export default async function (bot, i) {
} else if (type === 1) {
const modal = new ModalBuilder()
.setCustomId("apologyOWModal")
- .setTitle("SAHP | Přepis omluvenky");
+ .setTitle("LEA | Přepis omluvenky");
const today = new Date();
@@ -144,7 +157,7 @@ export default async function (bot, i) {
} else if (type === 2) {
const modal = new ModalBuilder()
.setCustomId("cpzOWModal")
- .setTitle("SAHP | Přepis CPZ");
+ .setTitle("LEA | Přepis CPZ");
const nameInput = new TextInputBuilder()
.setCustomId("name")
@@ -205,7 +218,7 @@ export default async function (bot, i) {
const member = await i.guild.members.fetch(worker.id);
let log;
- if (bot.LEA.g.SAHP.includes(i.guild.id)) log = JSON.parse(fs.readFileSync((path.resolve("./db/SAHP") + "/" + worker.id + ".json"), "utf-8"));
+ if (bot.LEA.g.LSPD.includes(i.guild.id)) log = JSON.parse(fs.readFileSync((path.resolve("./db/LSPD") + "/" + worker.id + ".json"), "utf-8"));
else if (bot.LEA.g.LSSD.includes(i.guild.id)) log = JSON.parse(fs.readFileSync((path.resolve("./db/LSSD") + "/" + worker.id + ".json"), "utf-8"));
else return i.editReply({ content: "> 🛑 **Tenhle server není uveden a seznamu.**\nKontaktuj majitele (viz. ).", ephemeral: true });
@@ -252,10 +265,12 @@ export default async function (bot, i) {
if (i.type === InteractionType.ModalSubmit) {
if (i.customId === "dutyModal") {
let content;
- if (bot.LEA.g.SAHP.includes(i.guild.id)) content = JSON.parse(fs.readFileSync((path.resolve("./db/SAHP") + "/" + i.user.id + ".json"), "utf-8"));
+ if (bot.LEA.g.LSPD.includes(i.guild.id)) content = JSON.parse(fs.readFileSync((path.resolve("./db/LSPD") + "/" + i.user.id + ".json"), "utf-8"));
else if (bot.LEA.g.LSSD.includes(i.guild.id)) content = JSON.parse(fs.readFileSync((path.resolve("./db/LSSD") + "/" + i.user.id + ".json"), "utf-8"));
else return i.reply({ content: "> 🛑 **Tenhle server není uveden a seznamu.**\nKontaktuj majitele (viz. ).", ephemeral: true });
+ await i.deferReply();
+
const index = content.duties.length + 1;
const row = new ActionRowBuilder()
@@ -263,6 +278,7 @@ export default async function (bot, i) {
new ButtonBuilder()
.setCustomId("edit")
.setLabel("Přepsat")
+ .setDisabled()
.setStyle(ButtonStyle.Primary)
.setEmoji("📝"),
)
@@ -278,7 +294,7 @@ export default async function (bot, i) {
(i.fields.getTextInputValue("datum").split(" ").length - 1) !== 2
|| (i.fields.getTextInputValue("datum").split(" ").length - 1) !== 2
) {
- return await i.reply({
+ return await i.editReply({
content:
"### Nalezena chyba - datum!"
+ "\n- Formát data je špatně. Napiš např. `24. 12. 2023` (tečky a mezery)"
@@ -289,7 +305,7 @@ export default async function (bot, i) {
ephemeral: true
});
} else if (!i.fields.getTextInputValue("start").includes(":") || !i.fields.getTextInputValue("end").includes(":")) {
- return await i.reply({
+ return await i.editReply({
content:
"### Nalezena chyba - čas!"
+ "\n- V některém z časů se neobjevila `:`."
@@ -301,8 +317,6 @@ export default async function (bot, i) {
});
}
- await i.deferReply();
-
let hours,
h1 = parseInt(i.fields.getTextInputValue("start").split(":")[0]),
h2 = parseInt(i.fields.getTextInputValue("end").split(":")[0]),
@@ -345,7 +359,7 @@ export default async function (bot, i) {
content.folder = i.channelId;
let workersPath;
- if (bot.LEA.g.SAHP.includes(i.guild.id)) workersPath = (path.resolve("./db/SAHP") + "/" + i.user.id + ".json");
+ if (bot.LEA.g.LSPD.includes(i.guild.id)) workersPath = (path.resolve("./db/LSPD") + "/" + i.user.id + ".json");
else if (bot.LEA.g.LSSD.includes(i.guild.id)) workersPath = (path.resolve("./db/LSSD") + "/" + i.user.id + ".json");
fs.writeFileSync(
@@ -356,7 +370,7 @@ export default async function (bot, i) {
console.log(" < [DB/Duty] > " + i.member.displayName + " zapsal(a) duty o délce " + hours.toString() + " hodin");
} else if (i.customId === "apologyModal") {
let content;
- if (bot.LEA.g.SAHP.includes(i.guild.id)) content = JSON.parse(fs.readFileSync((path.resolve("./db/SAHP") + "/" + i.user.id + ".json"), "utf-8"));
+ if (bot.LEA.g.LSPD.includes(i.guild.id)) content = JSON.parse(fs.readFileSync((path.resolve("./db/LSPD") + "/" + i.user.id + ".json"), "utf-8"));
else if (bot.LEA.g.LSSD.includes(i.guild.id)) content = JSON.parse(fs.readFileSync((path.resolve("./db/LSSD") + "/" + i.user.id + ".json"), "utf-8"));
else return i.reply({ content: "> 🛑 **Tenhle server není uveden a seznamu.**\nKontaktuj majitele (viz. ).", ephemeral: true });
@@ -367,6 +381,7 @@ export default async function (bot, i) {
new ButtonBuilder()
.setCustomId("edit")
.setLabel("Přepsat")
+ .setDisabled()
.setStyle(ButtonStyle.Primary)
.setEmoji("📝"),
);
@@ -425,7 +440,7 @@ export default async function (bot, i) {
content.folder = i.channelId;
let workersPath;
- if (bot.LEA.g.SAHP.includes(i.guild.id)) workersPath = (path.resolve("./db/SAHP") + "/" + i.user.id + ".json");
+ if (bot.LEA.g.LSPD.includes(i.guild.id)) workersPath = (path.resolve("./db/LSPD") + "/" + i.user.id + ".json");
else if (bot.LEA.g.LSSD.includes(i.guild.id)) workersPath = (path.resolve("./db/LSSD") + "/" + i.user.id + ".json");
fs.writeFileSync(
@@ -442,6 +457,7 @@ export default async function (bot, i) {
new ButtonBuilder()
.setCustomId("edit")
.setLabel("Přepsat")
+ .setDisabled()
.setStyle(ButtonStyle.Primary)
.setEmoji("📝"),
);
@@ -472,26 +488,36 @@ export default async function (bot, i) {
let post = false, gotNick = true, gotRole = true, folders;
const today = new Date();
- if (i.guild.id === "1167182546853961860") { //LSSD
- folders = await i.guild.channels.fetch("1193340608971018382");
+ if (i.guild.id === "1154446248934387828") { //LSPD
+ folders = await i.guild.channels.fetch("1213984576100241419");
try { var member = await i.guild.members.fetch(i.fields.getTextInputValue("id")); }
- catch (e) { await i.reply({ content: "> 🛑 **Člen nebyl nalezen.**", ephemeral: true }); console.log(e); }
+ catch (e) { await i.reply({ content: "> 🛑 **Člen nebyl nalezen.**", ephemeral: true }); return console.log(e); }
const rank = i.fields.getTextInputValue("rank"),
name = i.fields.getTextInputValue("name"),
radio = i.fields.getTextInputValue("call"),
badge = i.fields.getTextInputValue("badge");
- let roleID, tagID;
- if (rank === "Deputy Trainee") roleID = "1167182546874945704", tagID = "1193350188765564988";
- else if (rank === "Deputy I") roleID = "1167182546887520377", tagID = "1193350232684122252";
- else if (rank === "Deputy II") roleID = "1167182546887520378", tagID = "1193350293300199534";
- else if (rank === "Deputy III") roleID = "1167182546887520379", tagID = "1193350317765566494";
- else if (rank === "Senior Deputy") roleID = "1190754447253586041", tagID = "1193350345628332152";
- else if (rank === "Sergeant") roleID = "1167182546887520381", tagID = "1193350409138487427";
- else if (rank === "Lieutenant") roleID = "1167182546887520384", tagID = "1193350438947397642";
- else roleID = false, tagID = false;
-
- if (!roleID) await i.reply({ content: `> 🛑 **Neznámá hodnost... (\`${rank}\`)**`, ephemeral: true });
+ let rolesIDs, tagID;
+ if (rank === "Chief of Police") rolesIDs = ["1154446249005690910"], tagID = "1213985427724308490";
+ else if (rank === "Assistant Chief of Police") rolesIDs = ["1154446248967938187"], tagID = "1213985427724308490";
+ else if (rank === "Deputy Chief of Police") rolesIDs = ["1154446248967938186"], tagID = "1213985427724308490";
+ else if (rank === "Commander") rolesIDs = ["1154446248967938185"], tagID = "1213985427724308490";
+ else if (rank === "Captain") rolesIDs = ["1154446248967938183"], tagID = "1213985427724308490";
+ else if (rank === "Lieutenant") rolesIDs = ["1154446248967938182"], tagID = "1213985427724308490";
+ else if (rank === "Detective III") rolesIDs = ["1201811560708964402"], tagID = "1213985702484643930";
+ else if (rank === "Sergeant II") rolesIDs = ["1154446248967938181"], tagID = "1213985702484643930";
+ else if (rank === "Detective II") rolesIDs = ["1201811536117501972"], tagID = "1213985702484643930";
+ else if (rank === "Sergeant I") rolesIDs = ["1154446248967938180"], tagID = "1213985702484643930";
+ else if (rank === "Detective I") rolesIDs = ["1201811500252274689"], tagID = "1213985702484643930";
+ else if (rank === "Police Officer III+I") rolesIDs = ["1154448318961827962"], tagID = "1213985550458163200";
+ else if (rank === "Police Officer III") rolesIDs = ["1154446248946978957"], tagID = "1213985579742797874";
+ else if (rank === "Police Officer II") rolesIDs = ["1154446248946978956"], tagID = "1213985508917514250";
+ else if (rank === "Police Officer") rolesIDs = ["1154446248946978955"], tagID = "1213985475396771860";
+ else if (rank === "Cadet") rolesIDs = ["1154446248946978954"], tagID = "1213985402961006612";
+ else rolesIDs = false, tagID = false;
+
+ if (!rolesIDs) return i.reply({ content: `> 🛑 **Neznámá hodnost... (\`${rank}\`)**`, ephemeral: true });
+ rolesIDs.push("1167182546874945703"); //LSPD role
await i.deferReply();
@@ -500,7 +526,7 @@ export default async function (bot, i) {
.setDescription(
`> **App:** <@${member.id}>`
+ `\n> **Jméno:** \`${name}\``
- + `\n> **Hodnost:** <@&${roleID}>`
+ + `\n> **Hodnost:** <@&${rolesIDs}>`
+ `\n> **Odznak:** \`${badge}\``
+ `\n> **Volačka:** \`${radio}\``
+ "\n\n"
@@ -508,9 +534,9 @@ export default async function (bot, i) {
+ `\n> **Omluvenek:** \`0\``
+ `\n> **Povýšení:** ${time(today, "R")}`
)
- .setThumbnail(bot.LEA.i.LSSD)
- .setColor(bot.LEA.c.LSSD)
- .setFooter({ text: "LSSD | Vytvořil b1ngo ✌️", iconURL: bot.LEA.i.LSSD });
+ .setThumbnail(bot.LEA.i.LSPD)
+ .setColor(bot.LEA.c.LSPD)
+ .setFooter({ text: "LSPD | Vytvořil b1ngo ✌️", iconURL: bot.LEA.i.LSPD });
const row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
@@ -531,25 +557,25 @@ export default async function (bot, i) {
});
try { await member.setNickname(`[${radio}] ${name}`); } catch { gotNick = false; }
- try { await member.roles.add(["1167182546874945703", roleID]); } catch { gotRole = false; }
+ try { await member.roles.add(rolesIDs); } catch { gotRole = false; }
- const onderka = await i.guild.members.fetch("411436203330502658");
+ const b1ngo = await i.guild.members.fetch("411436203330502658");
const slozkaEmbed = new EmbedBuilder()
- .setAuthor({ name: onderka.displayName, iconURL: onderka.displayAvatarURL() })
+ .setAuthor({ name: b1ngo.displayName, iconURL: b1ngo.displayAvatarURL() })
.setTitle("Vítejte ve Vaší složce!")
.setDescription(
- `Zdravím <@${member.id}>, gratuluji Vám k úspěšnému přijetí na hodnost <@&${roleID}>.`
+ `Zdravím <@${member.id}>, gratuluji Vám k úspěšnému přijetí na hodnost <@&${rolesIDs}>.`
+ "\n**Zde si povinně zapisujete časy služeb a případné omluvenky.**"
+ "\n\n**Službu si zapisujete pomocí a omluvenku přes .**"
+ "\nVe skutečnosti je to prosté. Systém Vás navede při použití příkazů."
+ "\nV případě dotazů, neváhejte mě (<@411436203330502658>) označit. Ovšem, nepište DMs."
)
- .setThumbnail(bot.LEA.i.LSSD)
+ .setThumbnail(bot.LEA.i.LSPD)
.setColor(getServer(i.guild.id).color)
.setFooter(getServer(i.guild.id).footer);
await post.send({ content: `<@${member.id}>`, embeds: [slozkaEmbed] });
- } else if (i.guild.id === "1139266097921675345") { //SAHP
- folders = await i.guild.channels.fetch("1188146028440997948");
+ } else if (i.guild.id === "1139266097921675345") { //LSSD
+ folders = await i.guild.channels.fetch("1203743211000963082");
try { var member = await i.guild.members.fetch(i.fields.getTextInputValue("id")); }
catch (e) { await i.reply({ content: "> 🛑 **Člen nebyl nalezen.**", ephemeral: true }); console.log(e); }
@@ -557,22 +583,23 @@ export default async function (bot, i) {
name = i.fields.getTextInputValue("name"),
radio = i.fields.getTextInputValue("call"),
badge = i.fields.getTextInputValue("badge");
- let roleID, tagID;
- if (rank === "Trooper Trainee") roleID = "1139276175819157646", tagID = "1188146360327872613";
- else if (rank === "Trooper I") roleID = "1139276036673130527", tagID = "1188146386206724126";
- else if (rank === "Trooper II") roleID = "1139275934025916568", tagID = "1188146415583625316";
- else if (rank === "Trooper III") roleID = "1139275782607347905", tagID = "1188146446885716030";
- else if (rank === "Sergeant") roleID = "1139275398295867453", tagID = "1188146467442012160";
- else if (rank === "Lieutenant") roleID = "1139275038877560856", tagID = "1188146485582377051";
- else if (rank === "Captain") roleID = "1139274974683746335", tagID = "1188146485582377051";
- else if (rank === "A. Chief") roleID = "1139274974683746335", tagID = "1188146485582377051";
- else if (rank === "Chief") roleID = "1139274974683746335", tagID = "1188146485582377051";
- else if (rank === "A. Commissioner") roleID = "1139274629547053139", tagID = "1188146485582377051";
- else if (rank === "D. Commissioner") roleID = "1139274565973983262", tagID = "1188146485582377051";
- else if (rank === "Commissioner") roleID = "1139274486085058590", tagID = "1188146485582377051";
- else roleID = false, tagID = false;
-
- if (!roleID) await i.reply({ content: `> 🛑 **Neznámá hodnost... (\`${rank}\`)**`, ephemeral: true });
+ let rolesIDs, tagID;
+ if (rank === "Sheriff") rolesIDs = ["1139274486085058590"], tagID = "1203829217167409192";
+ else if (rank === "Undersheriff") rolesIDs = ["1139274565973983262"], tagID = "1203829217167409192";
+ else if (rank === "Assistant Sheriff") rolesIDs = ["1139274629547053139"], tagID = "1203829217167409192";
+ else if (rank === "Division Chief") rolesIDs = ["1139274788842516520"], tagID = "1203829217167409192";
+ else if (rank === "Area Commander") rolesIDs = ["1139274892617977966"], tagID = "1203829217167409192";
+ else if (rank === "Captain") rolesIDs = ["1139274974683746335"], tagID = "1203829217167409192";
+ else if (rank === "Lieutenant") rolesIDs = ["1139275038877560856"], tagID = "1203829217167409192";
+ else if (rank === "Sergeant") rolesIDs = ["1139275398295867453", "1139279790210306198"], tagID = "1203829180232630362";
+ else if (rank === "Deputy III") rolesIDs = ["1139275782607347905"], tagID = "1203829143234551898";
+ else if (rank === "Deputy II") rolesIDs = ["1139275934025916568"], tagID = "1203829113240952904";
+ else if (rank === "Deputy I") rolesIDs = ["1139276036673130527"], tagID = "1203829081100001311";
+ else if (rank === "Deputy Trainee") rolesIDs = ["1139276175819157646"], tagID = "1203829031049367593";
+ else rolesIDs = false, tagID = false;
+
+ if (!rolesIDs) return i.reply({ content: `> 🛑 **Neznámá hodnost... (\`${rank}\`)**`, ephemeral: true });
+ rolesIDs.push("1139276300188647444"); //LSSD role
await i.deferReply();
@@ -581,7 +608,7 @@ export default async function (bot, i) {
.setDescription(
`> **App:** <@${member.id}>`
+ `\n> **Jméno:** \`${name}\``
- + `\n> **Hodnost:** <@&${roleID}>`
+ + `\n> **Hodnost:** <@&${rolesIDs[0]}>`
+ `\n> **Odznak:** \`${badge}\``
+ `\n> **Volačka:** \`${radio}\``
+ "\n\n"
@@ -589,9 +616,9 @@ export default async function (bot, i) {
+ `\n> **Omluvenek:** \`0\``
+ `\n> **Povýšení:** ${time(today, "R")}`
)
- .setThumbnail(bot.LEA.i.SAHP)
- .setColor(bot.LEA.c.SAHP)
- .setFooter({ text: "SAHP | Vytvořil b1ngo ✌️", iconURL: bot.LEA.i.SAHP });
+ .setThumbnail(bot.LEA.i.LSSD)
+ .setColor(bot.LEA.c.LSSD)
+ .setFooter({ text: "LSSD | Vytvořil b1ngo ✌️", iconURL: bot.LEA.i.LSSD });
const row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
@@ -612,26 +639,27 @@ export default async function (bot, i) {
});
try { await member.setNickname(`[${radio}] ${name}`); } catch { gotNick = false; }
- try { await member.roles.add(["1139276300188647444", roleID]); } catch { gotRole = false; }
+ try { await member.roles.add(rolesIDs); } catch { gotRole = false; }
- const onderka = await i.guild.members.fetch("411436203330502658");
+ const b1ngo = await i.guild.members.fetch("411436203330502658");
const slozkaEmbed = new EmbedBuilder()
- .setAuthor({ name: onderka.displayName, iconURL: onderka.displayAvatarURL() })
+ .setAuthor({ name: b1ngo.displayName, iconURL: b1ngo.displayAvatarURL() })
.setTitle("Vítejte ve Vaší složce!")
.setDescription(
- `Zdravím <@${member.id}>, gratuluji Vám k úspěšnému přijetí na hodnost <@&${roleID}>.`
+ `Zdravím <@${member.id}>, gratuluji Vám k úspěšnému přijetí na hodnost <@&${rolesIDs[0]}>.`
+ "\n**Zde si povinně zapisujete časy služeb a případné omluvenky.**"
+ "\n\n**Službu si zapisujete pomocí a omluvenku přes .**"
+ "\nVe skutečnosti je to prosté. Systém Vás navede při použití příkazů."
+ "\nV případě dotazů, neváhejte mě (<@411436203330502658>) označit. Ovšem, nepište DMs."
)
- .setThumbnail(bot.LEA.i.SAHP)
+ .setThumbnail(bot.LEA.i.LSSD)
.setColor(getServer(i.guild.id).color)
.setFooter(getServer(i.guild.id).footer);
await post.send({ content: `<@${member.id}>`, embeds: [slozkaEmbed] });
}
const worker = {
+ "active": true,
"badge": parseInt(i.fields.getTextInputValue("badge")),
"name": i.fields.getTextInputValue("name"),
"radio": i.fields.getTextInputValue("call"),
@@ -646,14 +674,13 @@ export default async function (bot, i) {
"to": i.fields.getTextInputValue("rank"),
"from": null,
"boss": i.member.displayName,
- "reason": "Přidání do DB",
"hours": 0
}
]
};
let workersPath;
- if (bot.LEA.g.SAHP.includes(i.guild.id)) workersPath = (path.resolve("./db/SAHP") + "/" + i.fields.getTextInputValue("id") + ".json");
+ if (bot.LEA.g.LSPD.includes(i.guild.id)) workersPath = (path.resolve("./db/LSPD") + "/" + i.fields.getTextInputValue("id") + ".json");
else if (bot.LEA.g.LSSD.includes(i.guild.id)) workersPath = (path.resolve("./db/LSSD") + "/" + i.fields.getTextInputValue("id") + ".json");
else return i.editReply({ content: "> 🛑 **Tenhle server není uveden a seznamu.**\nKontaktuj majitele (viz. ).", ephemeral: true });
@@ -674,6 +701,19 @@ export default async function (bot, i) {
.setColor(getServer(i.guild.id).color)
.setFooter(getServer(i.guild.id).footer);
+ await dcLog(bot, i.guild.id, i.member,
+ {
+ title: "Přidání do DB",
+ description:
+ `**<@${i.user.id}> přidal(a) <@${i.fields.getTextInputValue("id")}> do DB.**`
+ + `\n> **Jméno:** \`${i.fields.getTextInputValue("name")}\``
+ + `\n> **Hodnost:** \`${i.fields.getTextInputValue("rank")}\``
+ + `\n> **Volačka:** \`${i.fields.getTextInputValue("call")}\``
+ + `\n> **Odznak:** \`${i.fields.getTextInputValue("badge")}\``,
+ color: "#00ff0d"
+ }
+ );
+
console.log(" < [DB/Login] > " + i.member.displayName + " zaregistroval(a) [" + i.fields.getTextInputValue("call") + "] " + i.fields.getTextInputValue("name") + " do DB");
await i.editReply({ embeds: [loginEmbed] });
@@ -682,65 +722,96 @@ export default async function (bot, i) {
const member = await i.guild.members.fetch(i.fields.getTextInputValue("id"));
if (!member) return i.reply({ content: "> 🛑 <@" + i.fields.getTextInputValue("id") + "> **není v DB.**", ephemeral: true });
- let content, oldRoleID, roleID, tagID, gotNick = true, gotRole = true, newRank = i.fields.getTextInputValue("rank");
- if (i.guild.id === "1167182546853961860") { //LSSD
- if (newRank === "Deputy Trainee") roleID = "1167182546874945704", tagID = "1193350188765564988";
- else if (newRank === "Deputy I") roleID = "1167182546887520377", tagID = "1193350232684122252";
- else if (newRank === "Deputy II") roleID = "1167182546887520378", tagID = "1193350293300199534";
- else if (newRank === "Deputy III") roleID = "1167182546887520379", tagID = "1193350317765566494";
- else if (newRank === "Senior Deputy") roleID = "1190754447253586041", tagID = "1193350345628332152";
- else if (newRank === "Sergeant") roleID = "1167182546887520381", tagID = "1193350409138487427";
- else if (newRank === "Lieutenant") roleID = "1167182546887520384", tagID = "1193350438947397642";
- else roleID = false, tagID = false;
- if (!roleID) return i.reply({ content: `> 🛑 **Neznámá hodnost... (\`${newRank}\`)**`, ephemeral: true });
-
- content = JSON.parse(fs.readFileSync((path.resolve("./db/LSSD") + "/" + i.fields.getTextInputValue("id") + ".json"), "utf-8"));
+ let content, oldRolesIDs, rolesIDs, tagID, gotNick = true, gotRole = true, newRank = i.fields.getTextInputValue("rank");
+ if (i.guild.id === "1154446248934387828") { //LSPD
+ if (newRank === "Chief of Police") rolesIDs = ["1154446249005690910"], tagID = "1213985427724308490";
+ else if (newRank === "Assistant Chief of Police") rolesIDs = ["1154446248967938187"], tagID = "1213985427724308490";
+ else if (newRank === "Deputy Chief of Police") rolesIDs = ["1154446248967938186"], tagID = "1213985427724308490";
+ else if (newRank === "Commander") rolesIDs = ["1154446248967938185"], tagID = "1213985427724308490";
+ else if (newRank === "Captain") rolesIDs = ["1154446248967938183"], tagID = "1213985427724308490";
+ else if (newRank === "Lieutenant") rolesIDs = ["1154446248967938182"], tagID = "1213985427724308490";
+ else if (newRank === "Detective III") rolesIDs = ["1201811560708964402"], tagID = "1213985427724308490";
+ else if (newRank === "Sergeant II") rolesIDs = ["1154446248967938181"], tagID = "1213985427724308490";
+ else if (newRank === "Detective II") rolesIDs = ["1201811536117501972"], tagID = "1213985427724308490";
+ else if (newRank === "Sergeant I") rolesIDs = ["1154446248967938180"], tagID = "1213985427724308490";
+ else if (newRank === "Detective I") rolesIDs = ["1201811500252274689"], tagID = "1213985427724308490";
+ else if (newRank === "Police Officer III+I") rolesIDs = ["1154448318961827962"], tagID = "1213985550458163200";
+ else if (newRank === "Police Officer III") rolesIDs = ["1154446248946978957"], tagID = "1213985579742797874";
+ else if (newRank === "Police Officer II") rolesIDs = ["1154446248946978956"], tagID = "1213985508917514250";
+ else if (newRank === "Police Officer") rolesIDs = ["1154446248946978955"], tagID = "1213985475396771860";
+ else if (newRank === "Cadet") rolesIDs = ["1154446248946978954"], tagID = "1213985402961006612";
+ else rolesIDs = false, tagID = false;
+ if (!rolesIDs) return i.reply({ content: `> 🛑 **Neznámá hodnost... (\`${newRank}\`)**`, ephemeral: true });
+
+ content = JSON.parse(fs.readFileSync((path.resolve("./db/LSPD") + "/" + i.fields.getTextInputValue("id") + ".json"), "utf-8"));
if (!(await i.guild.channels.fetch(content.folder))) return i.reply({ content: "> 🛑 **Nebyla nalezena složka <@" + i.fields.getTextInputValue("id") + ">!**", ephemeral: true });
- if (content.rank === "Deputy Trainee") oldRoleID = "1167182546874945704";
- else if (content.rank === "Deputy I") oldRoleID = "1167182546887520377";
- else if (content.rank === "Deputy II") oldRoleID = "1167182546887520378";
- else if (content.rank === "Deputy III") oldRoleID = "1167182546887520379";
- else if (content.rank === "Senior Deputy") oldRoleID = "1190754447253586041";
- else if (content.rank === "Sergeant") oldRoleID = "1167182546887520381";
- else if (content.rank === "Lieutenant") oldRoleID = "1167182546887520384";
- } else if (i.guild.id === "1139266097921675345") { //SAHP
- if (newRank === "Trooper Trainee") roleID = "1139276175819157646", tagID = "1188146360327872613";
- else if (newRank === "Trooper I") roleID = "1139276036673130527", tagID = "1188146386206724126";
- else if (newRank === "Trooper II") roleID = "1139275934025916568", tagID = "1188146415583625316";
- else if (newRank === "Trooper III") roleID = "1139275782607347905", tagID = "1188146446885716030";
- else if (newRank === "Sergeant") roleID = "1139275398295867453", tagID = "1188146467442012160";
- else if (newRank === "Lieutenant") roleID = "1139275038877560856", tagID = "1188146485582377051";
- else if (newRank === "Captain") roleID = "1139274974683746335", tagID = "1188146485582377051";
- else if (newRank === "A. Chief") roleID = "1139274974683746335", tagID = "1188146485582377051";
- else if (newRank === "Chief") roleID = "1139274974683746335", tagID = "1188146485582377051";
- else if (newRank === "A. Commissioner") roleID = "1139274629547053139", tagID = "1188146485582377051";
- else if (newRank === "D. Commissioner") roleID = "1139274565973983262", tagID = "1188146485582377051";
- else if (newRank === "Commissioner") roleID = "1139274486085058590", tagID = "1188146485582377051";
- else roleID = false, tagID = false;
- if (!roleID) return i.reply({ content: `> 🛑 **Neznámá hodnost... (\`${newRank}\`)**`, ephemeral: true });
-
- content = JSON.parse(fs.readFileSync((path.resolve("./db/SAHP") + "/" + i.fields.getTextInputValue("id") + ".json"), "utf-8"));
+ if (content.rank === "Chief of Police") oldRolesIDs = ["1154446249005690910"];
+ else if (content.rank === "Assistant Chief of Police") oldRolesIDs = ["1154446248967938187"];
+ else if (content.rank === "Deputy Chief of Police") oldRolesIDs = ["1154446248967938186"];
+ else if (content.rank === "Commander") oldRolesIDs = ["1154446248967938185"];
+ else if (content.rank === "Captain") oldRolesIDs = ["1154446248967938183"];
+ else if (content.rank === "Lieutenant") oldRolesIDs = ["1154446248967938182"];
+ else if (content.rank === "Detective III") oldRolesIDs = ["1201811560708964402"];
+ else if (content.rank === "Sergeant II") oldRolesIDs = ["1154446248967938181"];
+ else if (content.rank === "Detective II") oldRolesIDs = ["1201811536117501972"];
+ else if (content.rank === "Sergeant I") oldRolesIDs = ["1154446248967938180"];
+ else if (content.rank === "Detective I") oldRolesIDs = ["1201811500252274689"];
+ else if (content.rank === "Police Officer III+I") oldRolesIDs = ["1154448318961827962"];
+ else if (content.rank === "Police Officer III") oldRolesIDs = ["1154446248946978957"];
+ else if (content.rank === "Police Officer II") oldRolesIDs = ["1154446248946978956"];
+ else if (content.rank === "Police Officer") oldRolesIDs = ["1154446248946978955"];
+ else if (content.rank === "Cadet") oldRolesIDs = ["1154446248946978954"];
+ } else if (i.guild.id === "1139266097921675345") { //LSSD
+ if (newRank === "Sheriff") rolesIDs = ["1139274486085058590", "1139267137651884072"], tagID = "1203829217167409192";
+ else if (newRank === "Undersheriff") rolesIDs = ["1139274565973983262", "1139267137651884072"], tagID = "1203829217167409192";
+ else if (newRank === "Assistant Sheriff") rolesIDs = ["1139274629547053139", "1139267137651884072"], tagID = "1203829217167409192";
+ else if (newRank === "Division Chief") rolesIDs = ["1139274788842516520", "1139267137651884072"], tagID = "1203829217167409192";
+ else if (newRank === "Area Commander") rolesIDs = ["1139274892617977966", "1139267137651884072"], tagID = "1203829217167409192";
+ else if (newRank === "Captain") rolesIDs = ["1139274974683746335", "1139267137651884072"], tagID = "1203829217167409192";
+ else if (newRank === "Lieutenant") rolesIDs = ["1139275038877560856", "1139267137651884072"], tagID = "1203829217167409192";
+ else if (newRank === "Sergeant") rolesIDs = ["1139275398295867453", "1139279790210306198"], tagID = "1203829180232630362";
+ else if (newRank === "Deputy III") rolesIDs = ["1139275782607347905"], tagID = "1203829143234551898";
+ else if (newRank === "Deputy II") rolesIDs = ["1139275934025916568"], tagID = "1203829113240952904";
+ else if (newRank === "Deputy I") rolesIDs = ["1139276036673130527"], tagID = "1203829081100001311";
+ else if (newRank === "Deputy Trainee") rolesIDs = ["1139276175819157646"], tagID = "1203829031049367593";
+ else rolesIDs = false, tagID = false;
+ if (!rolesIDs) return i.reply({ content: `> 🛑 **Neznámá hodnost... (\`${newRank}\`)**`, ephemeral: true });
+
+ content = JSON.parse(fs.readFileSync((path.resolve("./db/LSSD") + "/" + i.fields.getTextInputValue("id") + ".json"), "utf-8"));
if (!(await i.guild.channels.fetch(content.folder))) return i.reply({ content: "> 🛑 **Nebyla nalezena složka <@" + i.fields.getTextInputValue("id") + ">!**", ephemeral: true });
- if (content.rank === "Trooper Trainee") oldRoleID = "1139276175819157646";
- else if (content.rank === "Trooper I") oldRoleID = "1139276036673130527";
- else if (content.rank === "Trooper II") oldRoleID = "1139275934025916568";
- else if (content.rank === "Trooper III") oldRoleID = "1139275782607347905";
- else if (content.rank === "Sergeant") oldRoleID = "1139275398295867453";
- else if (content.rank === "Lieutenant") oldRoleID = "1139275038877560856";
- else if (content.rank === "Captain") oldRoleID = "1139274974683746335";
- else if (content.rank === "A. Chief") roleID = "1139274974683746335";
- else if (content.rank === "Chief") roleID = "1139274974683746335";
- else if (content.rank === "A. Commissioner") roleID = "1139274629547053139";
- else if (content.rank === "D. Commissioner") roleID = "1139274565973983262";
- else if (content.rank === "Commissioner") roleID = "1139274486085058590";
+ if (content.rank === "Sheriff") oldRolesIDs = ["1139274486085058590", "1139267137651884072"];
+ else if (content.rank === "Undersheriff") oldRolesIDs = ["1139274565973983262", "1139267137651884072"];
+ else if (content.rank === "Assistant Sheriff") oldRolesIDs = ["1139274629547053139", "1139267137651884072"];
+ else if (content.rank === "Division Chief") oldRolesIDs = ["1139274788842516520", "1139267137651884072"];
+ else if (content.rank === "Area Commander") oldRolesIDs = ["1139274892617977966", "1139267137651884072"];
+ else if (content.rank === "Captain") oldRolesIDs = ["1139274974683746335", "1139267137651884072"];
+ else if (content.rank === "Lieutenant") oldRolesIDs = ["1139275038877560856", "1139267137651884072"];
+ else if (content.rank === "Sergeant") oldRolesIDs = ["1139275398295867453", "1139279790210306198"];
+ else if (content.rank === "Deputy III") oldRolesIDs = ["1139275782607347905"];
+ else if (content.rank === "Deputy II") oldRolesIDs = ["1139275934025916568"];
+ else if (content.rank === "Deputy I") oldRolesIDs = ["1139276036673130527"];
+ else if (content.rank === "Deputy Trainee") oldRolesIDs = ["1139276175819157646"];
}
await i.deferReply();
const today = new Date();
+ await dcLog(bot, i.guild.id, i.member,
+ {
+ title: "Povýšení v DB",
+ description:
+ `**<@${i.user.id}> povýšil(a) <@${i.fields.getTextInputValue("id")}> v DB.**`
+ + `\n> **Jméno:** \`${content.name}\``
+ + `\n> **Hodnost:** \`${content.rank}\` -> \`${i.fields.getTextInputValue("rank")}\``
+ + `\n> **Volačka:** \`${content.radio}\` -> \`${i.fields.getTextInputValue("call")}\``
+ + `\n> **Odznak:** \`${content.badge}\` -> \`${i.fields.getTextInputValue("badge")}\``,
+ color: "#0033ff"
+ }
+ );
+
console.log(" < [DB/Rankup] > " + i.member.displayName + ` povýšil(a) [${content.radio}] ${content.name} na [${i.fields.getTextInputValue("call")}] ${content.name} (${i.fields.getTextInputValue("rank")})`);
const rankup = {
@@ -748,7 +819,6 @@ export default async function (bot, i) {
"to": i.fields.getTextInputValue("rank"),
"from": content.rank,
"boss": i.member.displayName,
- "reason": i.fields.getTextInputValue("reason"),
"hours": content.hours
};
content.rankups.push(rankup);
@@ -757,7 +827,7 @@ export default async function (bot, i) {
content.rank = i.fields.getTextInputValue("rank");
let workersPath;
- if (bot.LEA.g.SAHP.includes(i.guild.id)) workersPath = (path.resolve("./db/SAHP") + "/" + i.fields.getTextInputValue("id") + ".json");
+ if (bot.LEA.g.LSPD.includes(i.guild.id)) workersPath = (path.resolve("./db/LSPD") + "/" + i.fields.getTextInputValue("id") + ".json");
else if (bot.LEA.g.LSSD.includes(i.guild.id)) workersPath = (path.resolve("./db/LSSD") + "/" + i.fields.getTextInputValue("id") + ".json");
fs.writeFileSync(
@@ -766,8 +836,8 @@ export default async function (bot, i) {
);
try { await member.setNickname(`[${content.radio}] ${content.name}`); } catch { gotNick = false; }
- try { await member.roles.remove([oldRoleID]); } catch { gotRole = false; }
- try { await member.roles.add([roleID]); } catch { gotRole = false; }
+ try { await member.roles.remove(oldRolesIDs); } catch { gotRole = false; }
+ try { await member.roles.add(rolesIDs); } catch { gotRole = false; }
if (content.folder) {
try {
@@ -777,7 +847,7 @@ export default async function (bot, i) {
await folder.setAppliedTags([tagID]);
if (start) {
- const rankUpDateArr = content.rankups[content.rankups.length - 1].date.split(". ");
+ const rankUpDateArr = rankup.date.split(". ");
const rankUpDate = new Date(rankUpDateArr[1] + "/" + rankUpDateArr[0] + "/" + rankUpDateArr[2]);
const workerEmbed = new EmbedBuilder()
@@ -785,7 +855,7 @@ export default async function (bot, i) {
.setDescription(
`> **App:** <@${i.fields.getTextInputValue("id")}>`
+ `\n> **Jméno:** \`${content.name}\``
- + `\n> **Hodnost:** ${roleID ? `<@&${roleID}>` : `\`${content.rank}\``}`
+ + `\n> **Hodnost:** ${rolesIDs ? `<@&${rolesIDs}>` : `\`${content.rank}\``}`
+ `\n> **Odznak:** \`${content.badge}\``
+ `\n> **Volačka:** \`${content.radio}\``
+ "\n\n"
@@ -793,9 +863,9 @@ export default async function (bot, i) {
+ `\n> **Omluvenek:** \`${content.apologies.filter(a => !a.removed).length}\``
+ `\n> **Povýšení:** ${time(rankUpDate, "R")}`
)
- .setThumbnail(bot.LEA.i.SAHP)
- .setColor(bot.LEA.c.SAHP)
- .setFooter({ text: "SAHP | Vytvořil b1ngo ✌️", iconURL: bot.LEA.i.SAHP });
+ .setThumbnail(getServer(i.guild.id).footer.iconURL)
+ .setColor(getServer(i.guild.id).color)
+ .setFooter(getServer(i.guild.id).footer);
const row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
@@ -840,7 +910,7 @@ export default async function (bot, i) {
const rankupEmbed = new EmbedBuilder()
.setTitle("Úspěch")
.setDescription(
- `<@${i.fields.getTextInputValue("id")}> byl(a) povýšen(a)!`
+ `<@${i.fields.getTextInputValue("id")}> byl(a) povýšen(a)!\n`
+ `> **Popis složky:** ${start ? "✅" : "❌"}\n`
+ `> **Název složky:** ✅\n`
+ `> **Přezdívka:** ${gotNick ? "✅" : "❌"}\n`
@@ -854,13 +924,201 @@ export default async function (bot, i) {
}
}
+ } else if (i.customId === "editModal") {
+ if (!(await checkDB(i.fields.getTextInputValue("id"), i))) return i.reply({ content: "> 🛑 <@" + i.fields.getTextInputValue("id") + "> **není v DB.**", ephemeral: true });
+ const member = await i.guild.members.fetch(i.fields.getTextInputValue("id"));
+ if (!member) return i.reply({ content: "> 🛑 <@" + i.fields.getTextInputValue("id") + "> **není v DB.**", ephemeral: true });
+
+ let content, oldRolesIDs, rolesIDs, tagID, gotNick = true, gotRole = true, newRank = i.fields.getTextInputValue("rank");
+ if (i.guild.id === "1154446248934387828") { //LSPD
+ content = JSON.parse(fs.readFileSync((path.resolve("./db/LSPD") + "/" + i.fields.getTextInputValue("id") + ".json"), "utf-8"));
+ if (!(await i.guild.channels.fetch(content.folder))) return i.reply({ content: "> 🛑 **Nebyla nalezena složka <@" + i.fields.getTextInputValue("id") + ">!**", ephemeral: true });
+
+ if (newRank !== content.rank) {
+ if (newRank === "Chief of Police") rolesIDs = ["1154446249005690910"], tagID = "1213985427724308490";
+ else if (newRank === "Assistant Chief of Police") rolesIDs = ["1154446248967938187"], tagID = "1213985427724308490";
+ else if (newRank === "Deputy Chief of Police") rolesIDs = ["1154446248967938186"], tagID = "1213985427724308490";
+ else if (newRank === "Commander") rolesIDs = ["1154446248967938185"], tagID = "1213985427724308490";
+ else if (newRank === "Captain") rolesIDs = ["1154446248967938183"], tagID = "1213985427724308490";
+ else if (newRank === "Lieutenant") rolesIDs = ["1154446248967938182"], tagID = "1213985427724308490";
+ else if (newRank === "Detective III") rolesIDs = ["1201811560708964402"], tagID = "1213985702484643930";
+ else if (newRank === "Sergeant II") rolesIDs = ["1154446248967938181"], tagID = "1213985702484643930";
+ else if (newRank === "Detective II") rolesIDs = ["1201811536117501972"], tagID = "1213985702484643930";
+ else if (newRank === "Sergeant I") rolesIDs = ["1154446248967938180"], tagID = "1213985702484643930";
+ else if (newRank === "Detective I") rolesIDs = ["1201811500252274689"], tagID = "1213985702484643930";
+ else if (newRank === "Police Officer III+I") rolesIDs = ["1154448318961827962"], tagID = "1213985550458163200";
+ else if (newRank === "Police Officer III") rolesIDs = ["1154446248946978957"], tagID = "1213985579742797874";
+ else if (newRank === "Police Officer II") rolesIDs = ["1154446248946978956"], tagID = "1213985508917514250";
+ else if (newRank === "Police Officer") rolesIDs = ["1154446248946978955"], tagID = "1213985475396771860";
+ else if (newRank === "Cadet") rolesIDs = ["1154446248946978954"], tagID = "1213985402961006612";
+ else rolesIDs = false, tagID = false;
+ if (!rolesIDs) return i.reply({ content: `> 🛑 **Neznámá hodnost... (\`${newRank}\`)**`, ephemeral: true });
+
+ if (content.rank === "Chief of Police") oldRolesIDs = ["1154446249005690910"];
+ else if (content.rank === "Assistant Chief of Police") oldRolesIDs = ["1154446248967938187"];
+ else if (content.rank === "Deputy Chief of Police") oldRolesIDs = ["1154446248967938186"];
+ else if (content.rank === "Commander") oldRolesIDs = ["1154446248967938185"];
+ else if (content.rank === "Captain") oldRolesIDs = ["1154446248967938183"];
+ else if (content.rank === "Lieutenant") oldRolesIDs = ["1154446248967938182"];
+ else if (content.rank === "Detective III") oldRolesIDs = ["1201811560708964402"];
+ else if (content.rank === "Sergeant II") oldRolesIDs = ["1154446248967938181"];
+ else if (content.rank === "Detective II") oldRolesIDs = ["1201811536117501972"];
+ else if (content.rank === "Sergeant I") oldRolesIDs = ["1154446248967938180"];
+ else if (content.rank === "Detective I") oldRolesIDs = ["1201811500252274689"];
+ else if (content.rank === "Police Officer III+I") oldRolesIDs = ["1154448318961827962"];
+ else if (content.rank === "Police Officer III") oldRolesIDs = ["1154446248946978957"];
+ else if (content.rank === "Police Officer II") oldRolesIDs = ["1154446248946978956"];
+ else if (content.rank === "Police Officer") oldRolesIDs = ["1154446248946978955"];
+ else if (content.rank === "Cadet") oldRolesIDs = ["1154446248946978954"];
+ }
+ } else if (i.guild.id === "1139266097921675345") { //LSSD
+ content = JSON.parse(fs.readFileSync((path.resolve("./db/LSSD") + "/" + i.fields.getTextInputValue("id") + ".json"), "utf-8"));
+ if (!(await i.guild.channels.fetch(content.folder))) return i.reply({ content: "> 🛑 **Nebyla nalezena složka <@" + i.fields.getTextInputValue("id") + ">!**", ephemeral: true });
+
+ if (newRank !== content.rank) {
+ if (newRank === "Sheriff") rolesIDs = ["1139274486085058590", "1139267137651884072"], tagID = "1203829217167409192";
+ else if (newRank === "Undersheriff") rolesIDs = ["1139274565973983262", "1139267137651884072"], tagID = "1203829217167409192";
+ else if (newRank === "Assistant Sheriff") rolesIDs = ["1139274629547053139", "1139267137651884072"], tagID = "1203829217167409192";
+ else if (newRank === "Division Chief") rolesIDs = ["1139274788842516520", "1139267137651884072"], tagID = "1203829217167409192";
+ else if (newRank === "Area Commander") rolesIDs = ["1139274892617977966", "1139267137651884072"], tagID = "1203829217167409192";
+ else if (newRank === "Captain") rolesIDs = ["1139274974683746335", "1139267137651884072"], tagID = "1203829217167409192";
+ else if (newRank === "Lieutenant") rolesIDs = ["1139275038877560856", "1139267137651884072"], tagID = "1203829217167409192";
+ else if (newRank === "Sergeant") rolesIDs = ["1139275398295867453", "1139279790210306198"], tagID = "1203829180232630362";
+ else if (newRank === "Deputy III") rolesIDs = ["1139275782607347905"], tagID = "1203829143234551898";
+ else if (newRank === "Deputy II") rolesIDs = ["1139275934025916568"], tagID = "1203829113240952904";
+ else if (newRank === "Deputy I") rolesIDs = ["1139276036673130527"], tagID = "1203829081100001311";
+ else if (newRank === "Deputy Trainee") rolesIDs = ["1139276175819157646"], tagID = "1203829031049367593";
+ else rolesIDs = false, tagID = false;
+ if (!rolesIDs) return i.reply({ content: `> 🛑 **Neznámá hodnost... (\`${newRank}\`)**`, ephemeral: true });
+
+ if (content.rank === "Sheriff") rolesIDs = ["1139274486085058590", "1139267137651884072"];
+ else if (content.rank === "Undersheriff") rolesIDs = ["1139274565973983262", "1139267137651884072"];
+ else if (content.rank === "Assistant Sheriff") rolesIDs = ["1139274629547053139", "1139267137651884072"];
+ else if (content.rank === "Division Chief") rolesIDs = ["1139274788842516520", "1139267137651884072"];
+ else if (content.rank === "Area Commander") rolesIDs = ["1139274892617977966", "1139267137651884072"];
+ else if (content.rank === "Captain") rolesIDs = ["1139274974683746335", "1139267137651884072"];
+ else if (content.rank === "Lieutenant") rolesIDs = ["1139275038877560856", "1139267137651884072"];
+ else if (content.rank === "Sergeant") rolesIDs = ["1139275398295867453", "1139279790210306198"];
+ else if (content.rank === "Deputy III") rolesIDs = ["1139275782607347905"];
+ else if (content.rank === "Deputy II") rolesIDs = ["1139275934025916568"];
+ else if (content.rank === "Deputy I") rolesIDs = ["1139276036673130527"];
+ else if (content.rank === "Deputy Trainee") rolesIDs = ["1139276175819157646"];
+ }
+ }
+
+ await i.deferReply();
+
+ let changed = { name: false, badge: false, radio: false, rank: false },
+ old = { name: content.name, badge: content.badge, radio: content.radio, rank: content.rank };
+ if (i.fields.getTextInputValue("name") !== content.name) changed.name = true;
+ if (parseInt(i.fields.getTextInputValue("badge")) !== content.badge) changed.badge = true;
+ if (i.fields.getTextInputValue("call") !== content.radio) changed.radio = true;
+ if (i.fields.getTextInputValue("rank") !== content.rank) changed.rank = true;
+
+ await dcLog(bot, i.guild.id, i.member,
+ {
+ title: "Úprava v DB",
+ description:
+ `**<@${i.user.id}> upravil(a) <@${i.fields.getTextInputValue("id")}> v DB.**`
+ + "\n" + (changed.name ? `> **Jméno:** \`${old.name}\` -> \`${i.fields.getTextInputValue("name")}\`` : `> **Jméno:** \`${content.name}\``)
+ + "\n" + (changed.rank ? `> **Hodnost:** \`${old.rank}\` -> \`${i.fields.getTextInputValue("rank")}\`` : `> **Hodnost:** \`${content.rank}\``)
+ + "\n" + (changed.radio ? `> **Volačka:** \`${old.radio}\` -> \`${i.fields.getTextInputValue("call")}\`` : `> **Volačka:** \`${content.radio}\``)
+ + "\n" + (changed.badge ? `> **Odznak:** \`${old.badge}\` -> \`${i.fields.getTextInputValue("badge")}\`` : `> **Odznak:** \`${content.badge}\``),
+ color: "#fcba03"
+ }
+ );
+
+ console.log(" < [DB/Edit] > " + i.member.displayName + ` upravil(a) [${content.radio}] ${content.name} na [${i.fields.getTextInputValue("call")}] ${i.fields.getTextInputValue("name")} (${i.fields.getTextInputValue("rank")})`);
+
+ if (changed.name) content.name = i.fields.getTextInputValue("name");
+ if (changed.badge) content.badge = parseInt(i.fields.getTextInputValue("badge"));
+ if (changed.radio) content.radio = i.fields.getTextInputValue("call");
+ if (changed.rank) content.rank = i.fields.getTextInputValue("rank");
+
+ let workersPath;
+ if (bot.LEA.g.LSPD.includes(i.guild.id)) workersPath = (path.resolve("./db/LSPD") + "/" + i.fields.getTextInputValue("id") + ".json");
+ else if (bot.LEA.g.LSSD.includes(i.guild.id)) workersPath = (path.resolve("./db/LSSD") + "/" + i.fields.getTextInputValue("id") + ".json");
+
+ fs.writeFileSync(
+ workersPath,
+ JSON.stringify(content, null, 4)
+ );
+
+ if (changed.name || changed.radio) try { await member.setNickname(`[${content.radio}] ${content.name}`); } catch { gotNick = false; }
+ if (changed.rank) try { await member.roles.remove(oldRolesIDs); } catch { gotRole = false; }
+ if (changed.rank) try { await member.roles.add(rolesIDs); } catch { gotRole = false; }
+
+ if (content.folder) {
+ try {
+ const folder = await i.guild.channels.fetch(content.folder);
+ const start = await folder.fetchStarterMessage({ force: true });
+
+ if (changed.rank) await folder.setAppliedTags([tagID]);
+
+ if (start) {
+ const rankUpDateArr = content.rankups[content.rankups.length - 1].date.split(". ");
+ const rankUpDate = new Date(rankUpDateArr[1] + "/" + rankUpDateArr[0] + "/" + rankUpDateArr[2]);
+
+ const workerEmbed = new EmbedBuilder()
+ .setAuthor({ name: `[${content.radio}] ${content.name}`, iconURL: member.displayAvatarURL() })
+ .setDescription(
+ `> **App:** <@${i.fields.getTextInputValue("id")}>`
+ + `\n> **Jméno:** \`${content.name}\``
+ + `\n> **Hodnost:** ${rolesIDs ? `<@&${rolesIDs}>` : `\`${content.rank}\``}`
+ + `\n> **Odznak:** \`${content.badge}\``
+ + `\n> **Volačka:** \`${content.radio}\``
+ + "\n\n"
+ + `\n> **Hodin:** \`${Math.round((content.hours + Number.EPSILON) * 100) / 100}\``
+ + `\n> **Omluvenek:** \`${content.apologies.filter(a => !a.removed).length}\``
+ + `\n> **Povýšení:** ${time(rankUpDate, "R")}`
+ )
+ .setThumbnail(getServer(i.guild.id).footer.iconURL)
+ .setColor(getServer(i.guild.id).color)
+ .setFooter(getServer(i.guild.id).footer);
+ const row = new ActionRowBuilder()
+ .addComponents(
+ new ButtonBuilder()
+ .setCustomId("summary_" + i.fields.getTextInputValue("id"))
+ .setLabel("Souhrn")
+ .setStyle(ButtonStyle.Success)
+ .setEmoji("👀"),
+ );
+ await start.edit({ message: `<@${i.fields.getTextInputValue("id")}>`, embeds: [workerEmbed], components: [row] });
+ }
+
+ const rankup2Embed = new EmbedBuilder()
+ .setTitle("Úprava!")
+ .setDescription(
+ (changed.name ? `> **Jméno:** \`${old.name}\` -> \`${content.name}\`` : `> **Jméno:** \`${content.name}\``)
+ + "\n" + (changed.rank ? `> **Hodnost:** \`${old.rank}\` -> \`${content.rank}\`` : `> **Hodnost:** \`${content.rank}\``)
+ + "\n" + (changed.radio ? `> **Volačka:** \`${old.radio}\` -> \`${content.radio}\`` : `> **Volačka:** \`${content.radio}\``)
+ + "\n" + (changed.badge ? `> **Odznak:** \`${old.badge}\` -> \`${content.badge}\`` : `> **Odznak:** \`${content.badge}\``)
+ )
+ .setColor(getServer(i.guild.id).color)
+ .setFooter(getServer(i.guild.id).footer);
+ await folder.send({ content: `<@${i.fields.getTextInputValue("id")}>` + (start ? "" : "<@411436203330502658>"), embeds: [rankup2Embed] });
+ if (changed.name || changed.radio) await folder.setName(`[${i.fields.getTextInputValue("call")}] ${content.name}`);
+
+ const rankupEmbed = new EmbedBuilder()
+ .setTitle("Úspěch")
+ .setDescription(
+ `<@${i.fields.getTextInputValue("id")}> byl(a) upravena(a)!`)
+ .setColor(getServer(i.guild.id).color)
+ .setFooter(getServer(i.guild.id).footer);
+
+ await i.editReply({ embeds: [rankupEmbed], ephemeral: true });
+ } catch (e) {
+ console.error(e);
+ }
+ }
+
} else if (i.customId === "dutyOWModal") {
await i.deferReply({ ephemeral: true });
if (!(await checkDB(i.message.interaction.user.id))) return i.editReply({ content: "> 🛑 <@" + user.id + "> **už není v DB.**", ephemeral: true });
let content;
- if (bot.LEA.g.SAHP.includes(i.guild.id)) content = JSON.parse(fs.readFileSync((path.resolve("./db/SAHP") + "/" + i.message.interaction.user.id + ".json"), "utf-8"));
+ if (bot.LEA.g.LSPD.includes(i.guild.id)) content = JSON.parse(fs.readFileSync((path.resolve("./db/LSPD") + "/" + i.message.interaction.user.id + ".json"), "utf-8"));
else if (bot.LEA.g.LSSD.includes(i.guild.id)) content = JSON.parse(fs.readFileSync((path.resolve("./db/LSSD") + "/" + i.message.interaction.user.id + ".json"), "utf-8"));
const index = parseInt(i.message.embeds[0].fields[0].name.slice(-1)) - 1;
@@ -871,6 +1129,7 @@ export default async function (bot, i) {
new ButtonBuilder()
.setCustomId("edit")
.setLabel("Přepsat")
+ .setDisabled()
.setStyle(ButtonStyle.Primary)
.setEmoji("📝"),
)
@@ -959,7 +1218,7 @@ export default async function (bot, i) {
content.hours = (Math.round((parseFloat(content.hours) + Number.EPSILON) * 100) / 100) + parseFloat(hoursAfter);
let workersPath;
- if (bot.LEA.g.SAHP.includes(i.guild.id)) workersPath = (path.resolve("./db/SAHP") + "/" + i.message.interaction.user.id + ".json");
+ if (bot.LEA.g.LSPD.includes(i.guild.id)) workersPath = (path.resolve("./db/LSPD") + "/" + i.message.interaction.user.id + ".json");
else if (bot.LEA.g.LSSD.includes(i.guild.id)) workersPath = (path.resolve("./db/LSSD") + "/" + i.message.interaction.user.id + ".json");
fs.writeFileSync(
@@ -976,7 +1235,7 @@ export default async function (bot, i) {
if (!(await checkDB(i.message.interaction.user.id))) return i.editReply({ content: "> 🛑 <@" + user.id + "> **už není v DB.**", ephemeral: true });
let content;
- if (bot.LEA.g.SAHP.includes(i.guild.id)) content = JSON.parse(fs.readFileSync((path.resolve("./db/SAHP") + "/" + i.message.interaction.user.id + ".json"), "utf-8"));
+ if (bot.LEA.g.LSPD.includes(i.guild.id)) content = JSON.parse(fs.readFileSync((path.resolve("./db/LSPD") + "/" + i.message.interaction.user.id + ".json"), "utf-8"));
else if (bot.LEA.g.LSSD.includes(i.guild.id)) content = JSON.parse(fs.readFileSync((path.resolve("./db/LSSD") + "/" + i.message.interaction.user.id + ".json"), "utf-8"));
const index = parseInt(i.message.embeds[0].fields[0].name.slice(-1)) - 1;
@@ -987,6 +1246,7 @@ export default async function (bot, i) {
new ButtonBuilder()
.setCustomId("edit")
.setLabel("Přepsat")
+ .setDisabled()
.setStyle(ButtonStyle.Primary)
.setEmoji("📝"),
);
@@ -1060,7 +1320,7 @@ export default async function (bot, i) {
}
let workersPath;
- if (bot.LEA.g.SAHP.includes(i.guild.id)) workersPath = (path.resolve("./db/SAHP") + "/" + i.message.interaction.user.id + ".json");
+ if (bot.LEA.g.LSPD.includes(i.guild.id)) workersPath = (path.resolve("./db/LSPD") + "/" + i.message.interaction.user.id + ".json");
else if (bot.LEA.g.LSSD.includes(i.guild.id)) workersPath = (path.resolve("./db/LSSD") + "/" + i.message.interaction.user.id + ".json");
fs.writeFileSync(
@@ -1081,6 +1341,7 @@ export default async function (bot, i) {
new ButtonBuilder()
.setCustomId("edit")
.setLabel("Přepsat")
+ .setDisabled()
.setStyle(ButtonStyle.Primary)
.setEmoji("📝"),
);
@@ -1113,87 +1374,6 @@ export default async function (bot, i) {
console.log(" < [OW/CPZ] > " + i.member.displayName + ` přepsal(a) CPZ zápis ${i.fields.getTextInputValue("name")} (${i.fields.getTextInputValue("birth")}) od ${i.fields.getTextInputValue("pd")}`);
i.editReply({ content: "✅ **Přepsáno!**", ephemeral: true });
- } else if (i.customId === "fakturaModal") {
- if (!(await checkDB(i.user.id))) {
- let worker;
- if (bot.LEA.g.SAHP.includes(i.guild.id)) worker = JSON.parse(fs.readFileSync((path.resolve("./db/SAHP") + "/" + i.user.id + ".json"), "utf-8"));
- else if (bot.LEA.g.LSSD.includes(i.guild.id)) worker = JSON.parse(fs.readFileSync((path.resolve("./db/LSSD") + "/" + i.user.id + ".json"), "utf-8"));
- else return i.reply({ content: "> 🛑 **Tenhle server není uveden a seznamu.**\nKontaktuj majitele (viz. ).", ephemeral: true });
-
- if (!worker) return i.reply({ content: "> 🛑 **Před zapsáním __faktury__ tě musí admin přilásit do DB.** Můžeš si založit <#1139284046388674610>.", ephemeral: true });
- }
-
- if (!(await checkEVENT(i.user.id))) {
- let worker;
- if (bot.LEA.g.SAHP.includes(i.guild.id)) worker = JSON.parse(fs.readFileSync((path.resolve("./db/SAHP") + "/" + i.user.id + ".json"), "utf-8"));
- else if (bot.LEA.g.LSSD.includes(i.guild.id)) worker = JSON.parse(fs.readFileSync((path.resolve("./db/LSSD") + "/" + i.user.id + ".json"), "utf-8"));
- else return i.reply({ content: "> 🛑 **Tenhle server není uveden a seznamu.**\nKontaktuj majitele (viz. ).", ephemeral: true });
-
- const content = {
- name: worker.name,
- stats: {
- value: 0,
- invoices: 0
- },
- invoices: []
- };
-
- fs.writeFileSync(
- (path.resolve("./db/event") + "/" + i.user.id + ".json"),
- JSON.stringify(content, null, 4)
- );
- }
-
- const user = await JSON.parse(fs.readFileSync((path.resolve("./db/event") + "/" + i.user.id + ".json"), "utf-8"));
-
- await i.deferReply({ ephemeral: true });
-
- const idFile = fs.readdirSync(path.resolve("./db/event")).filter(f => f.endsWith(".txt"))[0];
- const id = parseInt(idFile.split(".")[0]) + 1;
-
- const invoiceEmbed = new EmbedBuilder()
- .setAuthor({ name: i.member.displayName, iconURL: i.member.displayAvatarURL() })
- .setTitle("EVENT | Zápis faktury")
- .setDescription("Faktura byla zapsána do soutěže!")
- .addFields([
- {
- name: `Faktura #` + id.toString(), inline: false,
- value:
- `> **Jméno:** \`${i.fields.getTextInputValue("name")}\`\n`
- + `> **Důvod:** \`\`\`${i.fields.getTextInputValue("reason")}\`\`\`\n`
- + `> **Částka:** \`${parseInt(i.fields.getTextInputValue("money").split(" ").join("")).toLocaleString()} $\``
- }
- ])
- .setThumbnail("https://i.imgur.com/bGCFY6I.png")
- .setImage(bot.LEA.i.event[Math.floor(Math.random() * bot.LEA.i.event.length)])
- .setColor(bot.LEA.c.event)
- .setFooter(getServer(i.guild.id).footer);
-
- const today = new Date();
-
- const day = dg(today, "Date") + ". " + dg(today, "Month") + ". " + dg(today, "FullYear");
- const time = dg(today, "Hours") + ":" + dg(today, "Minutes") + ":" + dg(today, "Seconds");
-
- user.invoices.push({
- "value": parseInt(i.fields.getTextInputValue("money").split(" ").join("")),
- "shared": day + " " + time,
- "reason": i.fields.getTextInputValue("reason"),
- "name": i.fields.getTextInputValue("name"),
- "id": id
- });
- user.stats.value = user.stats.value + parseInt(i.fields.getTextInputValue("money").split(" ").join(""));
- user.stats.invoices = user.invoices.length;
-
- fs.writeFileSync(
- (path.resolve("./db/event") + "/" + i.user.id + ".json"),
- JSON.stringify(user, null, 4)
- );
-
- fs.renameSync(path.resolve("./db/event") + "/" + idFile, path.resolve("./db/event") + "/" + id.toString() + ".txt");
-
- console.log(" < [EVE/Faktura] > " + i.member.displayName + " si zapsal fakturu s ID " + id);
-
- await i.editReply({ embeds: [invoiceEmbed], ephemeral: true });
}
}
}
\ No newline at end of file
diff --git a/src/events/oneTime.js b/src/events/oneTime.js
new file mode 100644
index 0000000..2f46e15
--- /dev/null
+++ b/src/events/oneTime.js
@@ -0,0 +1,99 @@
+import { ActionRowBuilder, ActivityType, ButtonBuilder, ButtonStyle, EmbedBuilder } from "discord.js";
+
+
+export default async function tools(bot) {
+ /*bot.guilds.cache.forEach(async (guild) => {
+ const me = await guild.members.fetchMe();
+ if (me.nickname !== "LEA Bot") me.setNickname("LEA Bot");
+ });*/
+
+ /*const server = await bot.guilds.fetch("1154446248934387828");
+ const kanal = await server.channels.fetch("1213984576100241419");
+ for (const tag of kanal.availableTags) {
+ console.log(tag.name + " | " + tag.id);
+ }*/
+
+ /*const server = await bot.guilds.fetch("1139266097921675345");
+ const kanal = await server.channels.fetch("1203743211000963082");
+
+ const vlakna = await kanal.threads.fetchActive();
+ console.log(vlakna)
+ console.log(vlakna.threads.first())
+ vlakna.threads.forEach(async (t) => {
+ if (t.joinable && !t.joined) await t.join(); console.log(` < [DT] > thread ${t.name} joined`);
+ });*/
+
+ /*ORIENTACE V NÁVODU
+ const row = new ActionRowBuilder()
+ .addComponents(
+ new ButtonBuilder()
+ .setLabel("Vytvoření složky")
+ .setURL("https://discord.com/channels/1139266097921675345/1170795599164080228/1170797004595666984")
+ .setStyle(ButtonStyle.Link)
+ .setEmoji("📂"),
+ )
+ .addComponents(
+ new ButtonBuilder()
+ .setLabel("Zapsání duty")
+ .setURL("https://discord.com/channels/1139266097921675345/1170795599164080228/1170798279534071900")
+ .setStyle(ButtonStyle.Link)
+ .setEmoji("🕑"),
+ )
+ .addComponents(
+ new ButtonBuilder()
+ .setLabel("Zápis omluvenky")
+ .setURL("https://discord.com/channels/1139266097921675345/1170795599164080228/1170799102120960071")
+ .setStyle(ButtonStyle.Link)
+ .setEmoji("🙏"),
+ );
+
+ const server = await bot.guilds.fetch("1139266097921675345");
+ const kanal = await server.channels.fetch("1203743211000963082");
+ const vlakno = await kanal.threads.fetch("1170795599164080228");
+ console.log(vlakno);
+ const member = await server.members.fetch("411436203330502658");
+ const navodEmbed = new EmbedBuilder()
+ .setAuthor({ name: member.displayName, iconURL: member.displayAvatarURL() })
+ .setTitle("Revoluce zápisů")
+ .setDescription("Klikni na tlačítko pro přesun na daný návod.")
+ .setThumbnail(bot.LEA.i.SAHP)
+ .setColor(getServer(i.guild.id).color)
+ .setFooter({ text: "SAHP | Vytvořil b1ngo ✌️", iconURL: bot.LEA.i.SAHP });
+ await vlakno.send({ embeds: [navodEmbed], components: [row] });*/
+
+ /*const server = await bot.guilds.fetch("1139266097921675345");
+ const kanal = await server.channels.fetch("1139287456928239687");
+ await kanal.send({
+ "content": "<@&1139276300188647444>",
+ "tts": false,
+ "embeds": [
+ {
+ "id": 16875634,
+ "color": 16777215,
+ "image": {
+ "url": "https://i.imgur.com/0QTDERM.jpeg"
+ },
+ "fields": []
+ },
+ {
+ "id": 359050108,
+ "description": "# STRIKE SYSTÉM\n*řešení pro neomluvené absence*\n\nVážení zaměstnanci, přinášíme vám novinku ohledně trestání neomluvené absence.\n\n> **Proč se řeší absence?**\n> Snažíme se brát RP více vážně a opravdu se **starat o aktivitu PD** v našem městě.\n\n> **Co když nemůžu na meeting?**\n> Jedná se o úplně **v pořádku** případ, kdy ale po vás žádáme, aby jste se omluvili.\n> Budeme tak vědět, kolik lidí máme očekávat, proč členi sboru nejsou aktivní a zároveň důkaz toho, že se stále zajímáte o svoje místo a nekašlete na LSSD.\n\n> **Co se stane, když se neomluvím?**\n> Nově při každém neomluvení na povinnou akci (meeting, převoz skladu, výcvik, zásah, teambuilding...) dostanete **1 strike**, což je nižší váha warnu, na druhou stranu, už ale nebude možné doplnit omluvenky později.\n> - Jakmile obdržíte **3 striky**, dostanete **1 warn**.\n> - Získání 2 warnů vede k **degradu** na nižší hodnost.\n> - V případě Deputy I se jedná o **vyloučení** ze státní ozbrojené složky.\n\nKvůli téhle změně proběhne ještě tzv. **WARN WIPE**, takže se nikdo nebude muset starat o své aktuální warny. Všechny dosavadní warny budou odebrány.",
+ "color": 16777215,
+ "thumbnail": {
+ "url": "https://i.imgur.com/X3cH2iu.png"
+ },
+ "fields": [],
+ "author": {
+ "name": "[County-6] Tyler Pierce",
+ "icon_url": "https://images-ext-1.discordapp.net/external/eBaH6i4z8RsT5S2m3NjVZpd8I7kO7ul-mv0OIuvh0sc/https/cdn.discordapp.com/guilds/1139266097921675345/users/411436203330502658/avatars/1d41d7d593f6b9a0b8c22bb975574e24.webp"
+ },
+ "footer": {
+ "text": "Zavedeno"
+ },
+ "timestamp": "2024-04-14T16:00:00.000Z"
+ }
+ ],
+ "components": [],
+ "actions": {}
+ });*/
+}
\ No newline at end of file
diff --git a/src/events/ready.js b/src/events/ready.js
index 9711424..d0925d9 100644
--- a/src/events/ready.js
+++ b/src/events/ready.js
@@ -1,10 +1,9 @@
-import { ActionRowBuilder, ActivityType, ButtonBuilder, ButtonStyle, EmbedBuilder } from "discord.js";
+import { ActivityType } from "discord.js";
import { checkApologies } from "../../src/functions/outdated.js";
import newSystem from "../../src/functions/newSystem.js";
-import { update, updateDiv } from "../../web/script.js";
-import express from "express";
-import path from "path";
-import { config as secret } from "dotenv";
+import web from "./web.js";
+import api from "./api.js";
+import tools from "./oneTime.js";
export default async function (bot) {
console.log(` < [DC/Invite] > https://discord.com/oauth2/authorize?client_id=${bot.user.id}&permissions=309640612928&scope=bot%20applications.commands`);
@@ -14,96 +13,9 @@ export default async function (bot) {
checkApologies(bot);
newSystem(bot);
- /*bot.guilds.cache.forEach(async (guild) => {
- const me = await guild.members.fetchMe();
- if (me.nickname !== "LEA Bot") me.setNickname("LEA Bot");
- });*/
-
- /*const server = await bot.guilds.fetch("1167182546853961860");
- const kanal = await server.channels.fetch("1193340608971018382");
- for (const tag of kanal.availableTags) {
- console.log(tag.name + " | " + tag.id);
- }
-
- const server = await bot.guilds.fetch("1139266097921675345");
- const kanal = await server.channels.fetch("1188146028440997948");
-
- const vlakna = await kanal.threads.fetchActive();
- console.log(vlakna)
- console.log(vlakna.threads.first())
- vlakna.threads.forEach(async (t) => {
- if (t.joinable && !t.joined) await t.join(); console.log(` < [DT] > thread ${t.name} joined`);
- });*/
-
- /*ORIENTACE V NÁVODU
- const row = new ActionRowBuilder()
- .addComponents(
- new ButtonBuilder()
- .setLabel("Vytvoření složky")
- .setURL("https://discord.com/channels/1139266097921675345/1170795599164080228/1170797004595666984")
- .setStyle(ButtonStyle.Link)
- .setEmoji("📂"),
- )
- .addComponents(
- new ButtonBuilder()
- .setLabel("Zapsání duty")
- .setURL("https://discord.com/channels/1139266097921675345/1170795599164080228/1170798279534071900")
- .setStyle(ButtonStyle.Link)
- .setEmoji("🕑"),
- )
- .addComponents(
- new ButtonBuilder()
- .setLabel("Zápis omluvenky")
- .setURL("https://discord.com/channels/1139266097921675345/1170795599164080228/1170799102120960071")
- .setStyle(ButtonStyle.Link)
- .setEmoji("🙏"),
- );
-
- const server = await bot.guilds.fetch("1139266097921675345");
- const kanal = await server.channels.fetch("1188146028440997948");
- const vlakno = await kanal.threads.fetch("1170795599164080228");
- console.log(vlakno);
- const member = await server.members.fetch("411436203330502658");
- const navodEmbed = new EmbedBuilder()
- .setAuthor({ name: member.displayName, iconURL: member.displayAvatarURL() })
- .setTitle("Revoluce zápisů")
- .setDescription("Klikni na tlačítko pro přesun na daný návod.")
- .setThumbnail(bot.LEA.i.SAHP)
- .setColor(getServer(i.guild.id).color)
- .setFooter({ text: "SAHP | Vytvořil b1ngo ✌️", iconURL: bot.LEA.i.SAHP });
- await vlakno.send({ embeds: [navodEmbed], components: [row] });*/
-
console.log(" < [PS/Info] > Discord bot operational!");
- const tApp = express();
- const tPort = secret().port;
-
- tApp.get('/', (req, res) => {
- res.sendFile(path.resolve("./web/main.html"));
- });
-
- tApp.get('/sahp', async function (req, res) {
- await update(bot, 1);
- res.sendFile(path.resolve("./web/SAHP.html"));
- });
-
- tApp.get('/lssd', async function (req, res) {
- await update(bot, 2);
- res.sendFile(path.resolve("./web/LSSD.html"));
- });
-
- tApp.get('/divize', async function (req, res) {
- await updateDiv(bot);
- res.sendFile(path.resolve("./web/div.html"));
- });
-
- tApp.get('/div', (req, res) => {
- res.redirect('/divize');
- });
-
- tApp.listen(tPort, () => {
- console.log(` < [PS/Web] > LEA Bot tables are now available at IP:${tPort}!`);
- });
-
- update(bot);
+ const app = await web(bot)
+ await api(bot, app)
+ tools(bot)
}
\ No newline at end of file
diff --git a/src/events/web.js b/src/events/web.js
new file mode 100644
index 0000000..c6d03fe
--- /dev/null
+++ b/src/events/web.js
@@ -0,0 +1,77 @@
+import express from "express";
+import path from "path";
+import { update, updateDiv, updateBL } from "../../web/script.js";
+import { config as secret } from "dotenv";
+
+export default async function web(bot) {
+ const app = express();
+
+ app.set('trust proxy', true);
+ app.use(express.json());
+
+ app.use((req, res, next) => {
+ if (req.hostname === secret().parsed.domain && req.headers.host.includes(':')) {
+ const subdomain = 'leabot';
+ const newHost = `${subdomain}.${req.hostname}`;
+ return res.redirect(301, `${req.protocol}://${newHost}${req.url}`);
+ }
+ next();
+ });
+
+ //SITES
+ app.get('/', (req, res) => {
+ console.log(` < [PS/Web] > Got ${req.path} ${req.method} request!`);
+ res.sendFile(path.resolve("./web/index/index.html"));
+ });
+ app.get('/', (req, res) => {
+ console.log(` < [PS/Web] > Got ${req.path} ${req.method} request!`);
+ res.sendFile(path.resolve("./web/index/index.html"));
+ });
+
+ app.get('/lspd', async function (req, res) {
+ console.log(` < [PS/Web] > Got ${req.path} ${req.method} request!`);
+ //res.send(await update(bot, 1));
+ res.sendFile(path.resolve("./web/LSPD/LSPD.html"));
+ });
+
+ app.get('/lssd', async function (req, res) {
+ console.log(` < [PS/Web] > Got ${req.path} ${req.method} request!`);
+ //res.send(await update(bot, 2));
+ res.sendFile(path.resolve("./web/LSSD/LSSD.html"));
+ });
+
+ app.get('/divize', async function (req, res) {
+ console.log(` < [PS/Web] > Got ${req.path} ${req.method} request!`);
+ res.send(await updateDiv(bot));
+ //res.sendFile(path.resolve("./web/divize.html"));
+ });
+
+ app.get('/blacklist', async function (req, res) {
+ console.log(` < [PS/Web] > Got ${req.path} ${req.method} request!`);
+ res.send(await updateBL(bot));
+ //res.sendFile(path.resolve("./web/blacklist.html"));
+ });
+
+ //REDIRECTS
+ app.get('/bl', (req, res) => {
+ res.redirect('/blacklist');
+ });
+
+ app.get('/div', (req, res) => {
+ res.redirect('/divize');
+ });
+
+ function giveStatic(req, res) {
+ const filePath = path.resolve(`./web${req.path}`);
+ res.sendFile(filePath);
+ }
+
+ app.get('/index/script.js', giveStatic);
+ app.get('/index/style.css', giveStatic);
+ app.get('/LSSD/script.js', giveStatic);
+ app.get('/LSSD/style.css', giveStatic);
+ app.get('/LSPD/script.js', giveStatic);
+ app.get('/LSPD/style.css', giveStatic);
+
+ return app
+}
\ No newline at end of file
diff --git a/src/functions/db.js b/src/functions/db.js
index 151dea1..12f99d2 100644
--- a/src/functions/db.js
+++ b/src/functions/db.js
@@ -5,29 +5,29 @@ import { bot } from "../../index.js";
export async function checkDB(id) {
let exists;
exists =
- await fs.existsSync((path.resolve("./db/SAHP") + "/" + id + ".json"))
+ await fs.existsSync((path.resolve("./db/LSSD") + "/" + id + ".json"))
||
- await fs.existsSync((path.resolve("./db/LSSD") + "/" + id + ".json"));
+ await fs.existsSync((path.resolve("./db/LSPD") + "/" + id + ".json"));
return exists;
}
export async function getDB(id) {
let r = { exists: false, data: {}, id: id, guild: undefined, guildName: undefined, guildEmoji: undefined, guildID: undefined };
- if (await fs.existsSync((path.resolve("./db/SAHP") + "/" + id + ".json"))) {
+ if (await fs.existsSync((path.resolve("./db/LSPD") + "/" + id + ".json"))) {
r.exists = true;
- r.data = JSON.parse(fs.readFileSync((path.resolve("./db/SAHP") + "/" + id + ".json"), "utf-8"));
+ r.data = JSON.parse(fs.readFileSync((path.resolve("./db/LSPD") + "/" + id + ".json"), "utf-8"));
r.guild = 1;
- r.guildName = "SAHP";
- r.guildEmoji = "<:SAHP:1174876044570931210>";
- r.guildID = "1139266097921675345";
+ r.guildName = "LSPD";
+ r.guildEmoji = "<:LSPD:1178108366514565181>";
+ r.guildID = "1154446248934387828";
} else if (await fs.existsSync((path.resolve("./db/LSSD") + "/" + id + ".json"))) {
r.exists = true;
r.data = JSON.parse(fs.readFileSync((path.resolve("./db/LSSD") + "/" + id + ".json"), "utf-8"));
r.guild = 2;
r.guildName = "LSSD";
r.guildEmoji = "<:LSSD:1178106303198011412>";
- r.guildID = "1167182546853961860";
+ r.guildID = "1139266097921675345";
}
return r;
@@ -41,17 +41,20 @@ export async function checkEVENT(id) {
export function getServer(guildID) {
let r = {};
- if (bot.LEA.g.SAHP.includes(guildID)) {
- r.footer = { text: "SAHP | Vytvořil b1ngo ✌️", iconURL: bot.LEA.i.SAHP };
- r.color = bot.LEA.c.SAHP;
+ if (bot.LEA.g.LSPD.includes(guildID)) {
+ r.name = "LSPD"
+ r.footer = { text: "LSPD | Vytvořil b1ngo ✌️", iconURL: bot.LEA.i.LSPD };
+ r.color = bot.LEA.c.LSPD;
r.id = 1;
} else if (bot.LEA.g.LSSD.includes(guildID)) {
+ r.name = "LSSD"
r.footer = { text: "LSSD | Vytvořil b1ngo ✌️", iconURL: bot.LEA.i.LSSD };
r.color = bot.LEA.c.LSSD;
r.id = 2;
} else {
- r.footer = { text: "LEA Bot | Vytvořil b1ngo ✌️", iconURL: bot.LEA.i.LSPD };
- r.color = bot.LEA.c.LSPD;
+ r.name = "XXXX"
+ r.footer = { text: "LEA Bot | Vytvořil b1ngo ✌️", iconURL: bot.LEA.i.LEAbot };
+ r.color = bot.LEA.c.LEAbot;
r.id = 0;
}
diff --git a/src/functions/logSystem.js b/src/functions/logSystem.js
index 4027f33..9230320 100644
--- a/src/functions/logSystem.js
+++ b/src/functions/logSystem.js
@@ -1,6 +1,8 @@
import fs from "fs";
import path from "path";
import util from "util";
+import { getServer } from "./db.js";
+import { EmbedBuilder } from "discord.js";
export function dg(date, option) {
let r;
@@ -62,4 +64,26 @@ export async function setup() {
logStream.write(`[${day} | ${time} WAR] ${util.format(d)}` + "\n");
logStdout.write(`[${day} | ${time} WAR] ${util.format(d)}` + "\n");
};
+}
+
+export async function dcLog(bot, guildID, member, options = {}) {
+ const gotServer = getServer(guildID);
+ let guild, channel,
+ title = options.title,
+ description = options.description,
+ color = options.color,
+ file = options.file;
+ if (gotServer.id === 2) {
+ guild = await bot.guilds.fetch("1139266097921675345");
+ channel = await guild.channels.fetch("1204181260688167012");
+ let files = [];
+ if (!!file) files = [file];
+ const logEmbed = new EmbedBuilder()
+ .setAuthor({ name: member.displayName, iconURL: member.displayAvatarURL() })
+ .setTitle(title)
+ .setDescription(description)
+ .setColor(color)
+ .setFooter({ text: "LSSD | Vytvořil b1ngo ✌️", iconURL: bot.LEA.i.LSSD });
+ await channel.send({ embeds: [logEmbed], files: files });
+ }
}
\ No newline at end of file
diff --git a/src/functions/newSystem.js b/src/functions/newSystem.js
index e04da41..9dac32d 100644
--- a/src/functions/newSystem.js
+++ b/src/functions/newSystem.js
@@ -6,10 +6,10 @@ export default async function folders(bot) {
return;
try {
const guild = await bot.guilds.fetch("1139266097921675345");
- const folders = await guild.channels.fetch("1188146028440997948");
- const db = fs.readdirSync(path.resolve("./db/SAHP")).filter(file => file.endsWith(".json") && file !== "000000000000000001.json");
+ const folders = await guild.channels.fetch("1203743211000963082");
+ const db = fs.readdirSync(path.resolve("./db/LSPD")).filter(file => file.endsWith(".json") && file !== "000000000000000001.json");
for (const file of db) {
- let worker = JSON.parse(fs.readFileSync((path.resolve("./db/SAHP") + "/" + file), "utf-8"));
+ let worker = JSON.parse(fs.readFileSync((path.resolve("./db/LSPD") + "/" + file), "utf-8"));
try {
var member = await guild.members.fetch(file.slice(0, -5));
} catch (e) {
@@ -77,6 +77,7 @@ export default async function folders(bot) {
new ButtonBuilder()
.setCustomId("edit")
.setLabel("Přepsat")
+ .setDisabled()
.setStyle(ButtonStyle.Primary)
.setEmoji("📝")
.setDisabled(),
@@ -110,6 +111,7 @@ export default async function folders(bot) {
new ButtonBuilder()
.setCustomId("edit")
.setLabel("Přepsat")
+ .setDisabled()
.setStyle(ButtonStyle.Primary)
.setEmoji("📝")
.setDisabled(),
@@ -144,7 +146,7 @@ export default async function folders(bot) {
}
fs.writeFileSync(
- path.resolve("./db/SAHP") + "/" + file,
+ path.resolve("./db/LSPD") + "/" + file,
JSON.stringify(worker, null, 4)
);
diff --git a/src/functions/outdated.js b/src/functions/outdated.js
index 4e858d3..e1b5c50 100644
--- a/src/functions/outdated.js
+++ b/src/functions/outdated.js
@@ -3,13 +3,13 @@ import path from "path";
export async function checkApologies(bot) {
/* FIX
- let workers = (await fs.promises.readdir(path.resolve("./db/SAHP"))).concat(await fs.promises.readdir(path.resolve("./db/LSSD")));
+ let workers = (await fs.promises.readdir(path.resolve("./db/LSPD"))).concat(await fs.promises.readdir(path.resolve("./db/LSSD")));
for (const fileName of workers.filter(f => f !== "000000000000000001.json")) {
const workerID = fileName.split(".json")[0];
let sbor;
- let worker = JSON.parse(fs.readFileSync((path.resolve("./db/SAHP") + "/" + workerID + ".json"), "utf-8"));
+ let worker = JSON.parse(fs.readFileSync((path.resolve("./db/LSPD") + "/" + workerID + ".json"), "utf-8"));
if (!worker) { worker = JSON.parse(fs.readFileSync((path.resolve("./db/LSSD") + "/" + workerID + ".json"), "utf-8")); sbor = "LSSD"; }
else sbor = "SAHP";
@@ -37,7 +37,7 @@ export async function checkApologies(bot) {
if (sbor === "SAHP") {
await fs.writeFileSync(
- (path.resolve("./db/SAHP") + "/" + workerID + ".json"),
+ (path.resolve("./db/LSPD") + "/" + workerID + ".json"),
JSON.stringify(worker, null, 4)
);
} else {
diff --git a/src/functions/register.js b/src/functions/register.js
index 93d8c9e..277a81f 100644
--- a/src/functions/register.js
+++ b/src/functions/register.js
@@ -30,9 +30,12 @@ export async function commands(bot) {
const command = file.split(".")[0];
function registerCommand(cmd, cmdFile) {
bot.slashes.set(cmd, cmdFile);
- slashCommands.push(cmdFile.slash.toJSON());
+ if (cmdFile.slash) slashCommands.push(cmdFile.slash.toJSON());
+ else if (cmdFile.context) slashCommands.push(cmdFile.context.toJSON());
}
- registerCommand(command, commandFile);
+ let cmdName = command
+ if (commandFile.context) cmdName = command.split("_")[1].toLowerCase()
+ registerCommand(cmdName, commandFile);
};;
bot.once("ready", async (bot) => {
diff --git a/web/script.js b/web/script.js
deleted file mode 100644
index ba16899..0000000
--- a/web/script.js
+++ /dev/null
@@ -1,596 +0,0 @@
-import fs from "fs";
-import path from "path";
-import { getDB } from "../src/functions/db.js";
-
-export async function update(bot, sbor) {
- if (!bot) return false;
- if (!sbor) return await updateSAHP(bot), updateLSSD(bot), updateDiv(bot);
- if (sbor === 1) return await updateSAHP(bot);
- if (sbor === 2) return await updateLSSD(bot);
-}
-
-export async function updateSAHP(bot) {
- let jsonData = [], count = 0;
- const db = fs.readdirSync(path.resolve("./db/SAHP")).filter(file => file.endsWith(".json") && file !== "000000000000000001.json");
- for (const file of db) {
- let worker = JSON.parse(fs.readFileSync((path.resolve("./db/SAHP") + "/" + file), "utf-8"));
- worker.discordID = file.split(".json")[0];
- jsonData.push(worker);
- }
-
- let data = fs.readFileSync(path.resolve("./web/tableSAHP.html"), "utf-8");
-
- const guild = await bot.guilds.fetch("1139266097921675345");
- await guild.members.fetch();
-
- await jsonData.forEach(async (item, i) => { // deepscan-disable-line
- let tag = item.radio.toLowerCase().replaceAll("-", ""),
- mem = false,
- stlS = "", stlH = "",
- stlM = " style=\"text-align: center;\"",
- stlF = " style=\"background: #c80000; color: white; text-align: center; font-weight: bold;\"";
-
- mem = await guild.members.cache.get(item.discordID);
- if (!mem) {
- stlS = " style=\"background: #a60000; color: white;\"";
- stlH = " style=\"background: #c80000; color: white;\"";
- stlM = " style=\"background: #a60000; color: white; text-align: center;\"";
- } else if ((Math.round((item.hours + Number.EPSILON) * 100) / 100) === 0) {
- stlS = " style=\"background: #a60000; color: white;\"";
- stlH = " style=\"background: #c80000; color: white;\"";
- stlM = " style=\"background: #a60000; color: white; text-align: center;\"";
- }
- let roles = { warn: false, _1068: false, _1080: false }, div = [];
- if (mem) {
- roles.warn = mem.roles.cache.has("1139379787324997722");
- roles._1068 = mem.roles.cache.has("1178405506927300608");
- roles._1080 = mem.roles.cache.has("1179493599650521200");
- if (mem.roles.cache.has("1139275625740370001")) div.push("SWAT");
- if (mem.roles.cache.has("1139296112117817534")) div.push("DOA");
- if (mem.roles.cache.has("1139293160602874066")) div.push("ST");
- if (mem.roles.cache.has("1139294859354710188")) div.push("AU");
- if (mem.roles.cache.has("1149017017345638410")) div.push("BP");
- if (mem.roles.cache.has("1139297065063690315")) div.push("TU");
- if (mem.roles.cache.has("1139298429391089685")) div.push("MBU");
- if (mem.roles.cache.has("1139295387266580652")) div.push("FTO");
- if (mem.roles.cache.has("1139297368450277376")) div.push("CID");
- }
-
-
- let newData = [];
- newData.push(``);
- newData.push(` ${item.radio} | `);
- newData.push(` ${item.name} | `);
- newData.push(` ${item.badge} | `);
- newData.push(` ${item.rank} | `);
- newData.push(` ${item.discordID} | `);
- newData.push(` ${mem ? mem.user.tag : "Není na appce"} | `);
- newData.push(` ${item.rankups[item.rankups.length - 1].date} | `);
- newData.push(` ${Math.round(((item.hours - item.rankups[item.rankups.length - 1].hours) + Number.EPSILON) * 100) / 100} | `);
- newData.push(` ${Math.round((item.hours + Number.EPSILON) * 100) / 100} | `);
- newData.push(` N/A | `);
- newData.push(` ${item.apologies.length} | `);
- newData.push(` N/A | `);
- newData.push(` | `);
- if (roles.warn) newData.push(` | `);
- else newData.push(` | `);
- newData.push(` | `);
- if (roles._1068) newData.push(` | `);
- else newData.push(` | `);
- if (roles._1080) newData.push(` | `);
- else newData.push(` | `);
- newData.push(` | `);
- newData.push(` ${div.join(", ")} | `);
- newData.push(`
`);
-
- if (!data.includes(
- ``
- + `\r\n ${item.radio} | `
- + `\r\n | `
- + `\r\n ${item.badge} | `
- + `\r\n ${item.rank} | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n
`
- )) { /*console.log(item.discordID + " " + item.radio);*/ }
- else count++;
-
- try {
- data = data.replace(
- ``
- + `\r\n ${item.radio} | `
- + `\r\n | `
- + `\r\n ${item.badge} | `
- + `\r\n ${item.rank} | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n
`,
- newData.join("\r\n")
- );
- } catch (e) { console.error(e); }
- });
-
- try {
- fs.writeFileSync(path.resolve("./web/SAHP.html"), data, "utf-8");
- console.log(` < [PS/Web] > SAHP.html updated! (${count} / ${jsonData.length})`);
- return true;
- } catch (e) {
- console.error(`Error writing file: ${e.message}`);
- return false;
- };
-}
-
-export async function updateLSSD(bot) {
- let jsonData = [], count = 0;
- const db = fs.readdirSync(path.resolve("./db/LSSD")).filter(file => file.endsWith(".json") && file !== "000000000000000001.json");
- for (const file of db) {
- let worker = JSON.parse(fs.readFileSync((path.resolve("./db/LSSD") + "/" + file), "utf-8"));
- worker.discordID = file.split(".json")[0];
- jsonData.push(worker);
- }
-
- let data = fs.readFileSync(path.resolve("./web/tableLSSD.html"), "utf-8");
-
- const guild = await bot.guilds.fetch("1167182546853961860");
- await guild.members.fetch();
-
- await jsonData.forEach(async (item, i) => { // deepscan-disable-line
- let tag = item.radio.toLowerCase().replaceAll("-", ""),
- mem = false,
- stlS = "", stlH = "",
- stlM = " style=\"text-align: center;\"",
- stlF = " style=\"background: #c80000; color: white; text-align: center; font-weight: bold;\"";
-
- mem = await guild.members.cache.get(item.discordID);
- if (!mem) {
- stlS = " style=\"background: #a60000; color: white;\"";
- stlH = " style=\"background: #c80000; color: white;\"";
- stlM = " style=\"background: #a60000; color: white; text-align: center;\"";
- } else if ((Math.round((item.hours + Number.EPSILON) * 100) / 100) === 0) {
- stlS = " style=\"background: #a60000; color: white;\"";
- stlH = " style=\"background: #c80000; color: white;\"";
- stlM = " style=\"background: #a60000; color: white; text-align: center;\"";
- }
- let roles = { warn: false, suspend: false }, div = [];
- if (mem) {
- roles.warn = mem.roles.cache.has("1167182546853961862");
- roles.suspend = mem.roles.cache.has("1167182546853961863");
- if (mem.roles.cache.has("1167182546874945700")) div.push("MBU");
- if (mem.roles.cache.has("1167182546874945696")) div.push("SRT");
- if (mem.roles.cache.has("1167182546853961868")) div.push("CID");
- if (mem.roles.cache.has("1167182546853961866")) div.push("FTO");
- if (mem.roles.cache.has("1167182546853961864")) div.push("ST");
- if (mem.roles.cache.has("1167182546874945698")) div.push("DEA");
- if (mem.roles.cache.has("1191352540680437780")) div.push("GU");
- if (mem.roles.cache.has("1170450979896963122")) div.push("AU");
- if (mem.roles.cache.has("1191724184011808929")) div.push("K-9");
- }
-
-
- let newData = [];
- newData.push(``);
- newData.push(` ${item.radio} | `);
- newData.push(` ${item.name} | `);
- newData.push(` ${item.badge} | `);
- newData.push(` ${item.rank} | `);
- newData.push(` ${item.discordID} | `);
- newData.push(` ${mem ? mem.user.tag : "Není na appce"} | `);
- newData.push(` ${item.rankups[item.rankups.length - 1].date} | `);
- newData.push(` ${Math.round(((item.hours - item.rankups[item.rankups.length - 1].hours) + Number.EPSILON) * 100) / 100} | `);
- newData.push(` ${Math.round((item.hours + Number.EPSILON) * 100) / 100} | `);
- newData.push(` N/A | `);
- newData.push(` ${item.apologies.length} | `);
- newData.push(` N/A | `);
- newData.push(` | `);
- if (roles.warn) newData.push(` | `);
- else newData.push(` | `);
- if (roles.suspend) newData.push(` | `);
- else newData.push(` | `);
- newData.push(` ${div.join(", ")} | `);
- newData.push(`
`);
-
- if (!data.includes(
- ``
- + `\r\n ${item.radio} | `
- + `\r\n | `
- + `\r\n ${item.badge} | `
- + `\r\n ${item.rank} | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n
`
- )) { /*console.log(item.discordID + " " + item.radio);*/ }
- else count++;
-
- try {
- data = data.replace(
- ``
- + `\r\n ${item.radio} | `
- + `\r\n | `
- + `\r\n ${item.badge} | `
- + `\r\n ${item.rank} | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n
`,
- newData.join("\r\n")
- );
- } catch (e) { console.error(e); }
- });
-
- try {
- fs.writeFileSync(path.resolve("./web/LSSD.html"), data, "utf-8");
- console.log(` < [PS/Web] > LSSD.html updated! (${count} / ${jsonData.length})`);
- return true;
- } catch (e) {
- console.error(`Error writing file: ${e.message}`);
- return false;
- };
-}
-
-export async function updateDiv(bot) {
- let divs = [
- {
- id: "0cid",
- count: 0,
- roles: ["1139297368450277376", "1167182546853961868"],
- commanderRoles: ["1153704499651817573", "1167182546853961869"],
- commanders: [],
- radio: "Echo 1-5
Eric 1-5",
- fullname: "Criminal Investigative Division",
- members: [],
- },
- {
- id: "1swat",
- count: 0,
- roles: ["1139275625740370001"],
- commanderRoles: ["1139275915357081761"],
- commanders: [],
- radio: "Ghost 1-30",
- fullname: "Special Weapons And Tactics",
- members: [],
- },
- {
- id: "1doa",
- count: 0,
- roles: ["1139296112117817534"],
- commanderRoles: ["1139295819753852948"],
- commanders: [],
- radio: false,
- fullname: false,
- members: [],
- },
- {
- id: "1st",
- count: 0,
- roles: ["1139293160602874066"],
- commanderRoles: ["1139293329218097244"],
- commanders: [],
- radio: false,
- fullname: "Sniper Team",
- members: [],
- },
- {
- id: "1au",
- count: 0,
- roles: ["1139294859354710188"],
- commanderRoles: ["1139295075080347730"],
- commanders: [],
- radio: false,
- fullname: "Air Unit",
- members: [],
- },
- {
- id: "1bp",
- count: 0,
- roles: ["1149017017345638410"],
- commanderRoles: ["1149017580791676981"],
- commanders: [],
- radio: false,
- fullname: "Border Patrol",
- members: [],
- },
- {
- id: "1tu",
- count: 0,
- roles: ["1139297065063690315"],
- commanderRoles: ["1139296993190097068"],
- commanders: [],
- radio: false,
- fullname: "Traffic Unit",
- members: [],
- },
- {
- id: "1mbu",
- count: 0,
- roles: ["1139298429391089685"],
- commanderRoles: ["1139298099706220544"],
- commanders: [],
- radio: false,
- fullname: "MotorBike Unit",
- members: [],
- },
- {
- id: "1fto",
- count: 0,
- roles: ["1139295387266580652"],
- commanderRoles: ["1139295201282764882"],
- commanders: [],
- radio: false,
- fullname: "Field Training Officer",
- members: [],
- },
- {
- id: "2mbu",
- count: 0,
- roles: ["1167182546874945700"],
- commanderRoles: ["1167182546874945701"],
- commanders: [],
- radio: false,
- fullname: "MotorBike Unit",
- members: [],
- },
- {
- id: "2srt",
- count: 0,
- roles: ["1167182546874945696"],
- commanderRoles: ["1167182546874945697"],
- commanders: [],
- radio: false,
- fullname: "Special Respond Team",
- members: [],
- },
- {
- id: "2fto",
- count: 0,
- roles: ["1167182546853961866"],
- commanderRoles: ["1167182546853961867"],
- commanders: [],
- radio: false,
- fullname: "Field Training Officer",
- members: [],
- },
- {
- id: "2st",
- count: 0,
- roles: ["1167182546853961864"],
- commanderRoles: ["1167182546853961865"],
- commanders: [],
- radio: false,
- fullname: "Sniper Team",
- members: [],
- },
- {
- id: "2dea",
- count: 0,
- roles: ["1167182546874945698"],
- commanderRoles: ["1167182546874945699"],
- commanders: [],
- radio: false,
- fullname: "Drug Enforcement Administration",
- members: [],
- },
- {
- id: "2gu",
- count: 0,
- roles: ["1191352540680437780"],
- commanderRoles: ["1191352422359117954"],
- commanders: [],
- radio: false,
- fullname: "Gang Unit",
- members: [],
- },
- {
- id: "2au",
- count: 0,
- roles: ["1170450979896963122"],
- commanderRoles: ["1170450636115034154"],
- commanders: [],
- radio: "Air 1-25",
- fullname: "Air Unit",
- members: [],
- },
- {
- id: "2k9",
- count: 0,
- roles: ["1191724184011808929"],
- commanderRoles: ["1191726198758314125"],
- commanders: [],
- radio: false,
- fullname: "K-9",
- members: [],
- }
- ];
-
- const SAHP = await bot.guilds.fetch("1139266097921675345");
- await SAHP.members.fetch();
- await SAHP.roles.fetch(divs.filter(d => d.id.split("")[0] === "1").map(d => d.roles[0]));
-
- const LSSD = await bot.guilds.fetch("1167182546853961860");
- await LSSD.members.fetch();
- await LSSD.roles.fetch(divs.filter(d => d.id.split("")[0] === "2").map(d => d.roles[0]));
-
- let data = fs.readFileSync(path.resolve("./web/tableDIV.html"), "utf-8"), count = 0;
-
- await divs.forEach(async d => { // deepscan-disable-line
- let mSize = 0, m = [], cm = [], m1, m2, cm1, cm2, mF = [], cmF = [];
- const sborID = d.id.split("")[0];
- if (sborID === "1") {
- m1 = SAHP.roles.cache.get(d.roles[0]).members;
- cm1 = SAHP.roles.cache.get(d.commanderRoles[0]).members;
- mSize = m1.size;
- m1.forEach(m => {
- let call = m.displayName.match(/\[(.*?)\]/);
- if (!!call) {
- call = call[1];
- call = call.split("-")[0].toLowerCase() + parseInt(call.split("-")[1]);
- call = `${m.displayName}`;
- mF.push(call);
- }
- });
- cm1.forEach(m => {
- let call = m.displayName.match(/\[(.*?)\]/);
- if (!!call) {
- call = call[1];
- call = call.split("-")[0].toLowerCase() + parseInt(call.split("-")[1]);
- call = `${m.displayName}`;
- cmF.push(call);
- }
- });
- }
- if (sborID === "2") {
- m2 = LSSD.roles.cache.get(d.roles[0]).members;
- cm2 = LSSD.roles.cache.get(d.commanderRoles[0]).members;
- mSize = m2.size;
- m2.forEach(m => {
- let call = m.displayName.match(/\[(.*?)\]/);
- if (!!call) {
- call = call[1];
- call = call.split("-")[0].toLowerCase() + parseInt(call.split("-")[1]);
- call = `${m.displayName}`;
- mF.push(call);
- }
- });
- cm2.forEach(m => {
- let call = m.displayName.match(/\[(.*?)\]/);
- if (!!call) {
- call = call[1];
- call = call.split("-")[0].toLowerCase() + parseInt(call.split("-")[1]);
- call = `${m.displayName}`;
- cmF.push(call);
- }
- });
- }
- if (sborID === "0") {
- m1 = SAHP.roles.cache.get(d.roles[0]).members;
- m2 = LSSD.roles.cache.get(d.roles[1]).members;
- cm1 = SAHP.roles.cache.get(d.commanderRoles[0]).members;
- cm2 = LSSD.roles.cache.get(d.commanderRoles[1]).members;
- mSize = m1.size + m2.size;
- m1.forEach(m => {
- let call = m.displayName.match(/\[(.*?)\]/);
- if (!!call) {
- call = call[1];
- call = call.split("-")[0].toLowerCase() + parseInt(call.split("-")[1]);
- call = `${m.displayName}`;
- mF.push(call);
- }
- });
- m2.forEach(m => {
- let call = m.displayName.match(/\[(.*?)\]/);
- if (!!call) {
- call = call[1];
- call = call.split("-")[0].toLowerCase() + parseInt(call.split("-")[1]);
- call = `${m.displayName}`;
- mF.push(call);
- }
- });
- cm1.forEach(m => {
- let call = m.displayName.match(/\[(.*?)\]/);
- if (!!call) {
- call = call[1];
- call = call.split("-")[0].toLowerCase() + parseInt(call.split("-")[1]);
- call = `${m.displayName}`;
- cmF.push(call);
- }
- });
- cm2.forEach(m => {
- let call = (m.displayName.match(/\[(.*?)\]/))[1];
- if (!!call) {
- call = call[1];
- call = call.split("-")[0].toLowerCase() + parseInt(call.split("-")[1]);
- call = `${m.displayName}`;
- cmF.push(call);
- }
- });
- }
- const divName = d.id.slice(1).toUpperCase();
- m = m.filter((mm, i) => i === m.indexOf(mm));
- cm = cm.filter((cc, i) => i === cm.indexOf(cc));
-
- //console.log(`${d.id} ${sborID} ${mSize} ${m}`);
-
- let newData = [];
- newData.push(`${divName} | `);
- newData.push(` ${mSize !== 0 ? mSize : ""} | `);
- newData.push(` ${cmF.join(", ")} | `);
- newData.push(` ${d.radio || ""} | `);
- newData.push(` ${d.fullname || ""} | `);
- newData.push(` ${mF.join(", ")} | `);
-
- if (!data.includes(
- `${divName} | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n ${d.radio || ""} | `
- + `\r\n ${d.fullname || ""} | `
- + `\r\n | `
- )) { /*console.log(d.id);*/ }
- else count++;
-
- try {
- data = data.replace(
- `${divName} | `
- + `\r\n | `
- + `\r\n | `
- + `\r\n ${d.radio || ""} | `
- + `\r\n ${d.fullname || ""} | `
- + `\r\n | `,
- newData.join("\r\n")
- );
- } catch (e) { console.error(e); }
- });
-
- try {
- fs.writeFileSync(path.resolve("./web/div.html"), data, "utf-8");
- console.log(` < [PS/Web] > div.html updated! (${count} / ${divs.length})`);
- return true;
- } catch (e) {
- console.error(`Error writing file: ${e.message}`);
- return false;
- };
-}
\ No newline at end of file