From 8cdb65a966b51f88a952a97e88915f2187d54870 Mon Sep 17 00:00:00 2001 From: Elis Odenhage Date: Tue, 21 Jun 2022 22:19:37 +0200 Subject: [PATCH 001/215] Rename database function from start to connect, fixes #375 --- src/managers/database/index.ts | 2 +- src/managers/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/managers/database/index.ts b/src/managers/database/index.ts index 0063c61..3bfe302 100644 --- a/src/managers/database/index.ts +++ b/src/managers/database/index.ts @@ -7,7 +7,7 @@ import logger from "../../logger"; // Configuration import { url } from "../../config/database"; -export const start = async () => { +export const connect = async () => { await mongoose .connect(url) .then(async (connection) => { diff --git a/src/managers/index.ts b/src/managers/index.ts index 6981d3c..a1f3dad 100644 --- a/src/managers/index.ts +++ b/src/managers/index.ts @@ -6,7 +6,7 @@ import * as event from "./event"; import * as command from "./command"; export const start = async (client: Client) => { - await database.start(); + await database.connect(); await schedule.start(client); await command.register(client); await event.register(client); From 9369fd8f0d4be74db5a14d98725a947b1115d2a5 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 29 Jun 2022 13:03:46 +0000 Subject: [PATCH 002/215] Update dependency jest to v28.1.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ac149cc..600e611 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "eslint-plugin-no-loops": "^0.3.0", "eslint-plugin-prettier": "^4.0.0", "husky": "8.0.1", - "jest": "28.1.1", + "jest": "28.1.2", "lint-staged": "13.0.1", "nodemon": "^2.0.16", "prettier": "^2.6.0" From 88c6740adccdfcbaccf7edf54c4753e44bd4c263 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Thu, 30 Jun 2022 12:44:01 +0200 Subject: [PATCH 003/215] =?UTF-8?q?=F0=9F=9A=B8=20gdpr=20fix=20for=20remov?= =?UTF-8?q?ing=20guild=20when=20bot=20has=20bent=20offline=20during=20remo?= =?UTF-8?q?val=20of=20bot.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + src/helpers/dropGuild/index.ts | 46 ++++++++----------- src/helpers/fetchGuild/index.ts | 12 ++--- src/jobs/keepDataUpToDate/index.ts | 38 +++++++++++++++ .../commands/credits/modules/work/index.ts | 2 +- src/plugins/events/guildCreate/index.ts | 11 +++-- src/plugins/events/guildDelete/index.ts | 2 +- .../messageCreate/modules/credits/index.ts | 2 +- .../messageCreate/modules/points/index.ts | 2 +- 9 files changed, 76 insertions(+), 40 deletions(-) create mode 100644 src/jobs/keepDataUpToDate/index.ts diff --git a/package.json b/package.json index ac149cc..740f844 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "tsconfig-paths": "^4.0.0", "typescript": "^4.6.3", "uuid": "^8.3.2", + "winston": "^3.8.0", "winston-daily-rotate-file": "^4.6.1" }, "devDependencies": { diff --git a/src/helpers/dropGuild/index.ts b/src/helpers/dropGuild/index.ts index 0c0e2ab..6145aa4 100644 --- a/src/helpers/dropGuild/index.ts +++ b/src/helpers/dropGuild/index.ts @@ -7,66 +7,60 @@ import timeoutSchema from "../../models/timeout"; import logger from "../../logger"; -import { Guild } from "discord.js"; +import { Snowflake } from "discord.js"; -export default async (guild: Guild) => { +export default async (id: Snowflake) => { await guildSchema - .deleteMany({ guildId: guild.id }) + .deleteMany({ guildId: id }) .then(async () => { - return logger?.silly(`Deleted guild: ${guild.id}`); + return logger?.silly(`Deleted guild: ${id}`); }) .catch(async (error) => { - logger?.error(`Error deleting guild: ${guild.id} - ${error}`); + logger?.error(`Error deleting guild: ${id} - ${error}`); }); await userSchema - .deleteMany({ guildId: guild.id }) + .deleteMany({ guildId: id }) .then(async () => { - logger?.silly(`Deleted users for guild: ${guild.id} from database`); + logger?.silly(`Deleted users for guild: ${id} from database`); }) .catch(async (error) => { - logger?.error(`Error deleting users for guild: ${guild.id} - ${error}`); + logger?.error(`Error deleting users for guild: ${id} - ${error}`); }); await apiSchema - .deleteMany({ guildId: guild.id }) + .deleteMany({ guildId: id }) .then(async () => { - logger?.silly(`Deleted apis for guild: ${guild.id} from database`); + logger?.silly(`Deleted apis for guild: ${id} from database`); }) .catch(async (error) => { - logger?.error(`Error deleting apis for guild: ${guild.id} - ${error}`); + logger?.error(`Error deleting apis for guild: ${id} - ${error}`); }); await counterSchema - .deleteMany({ guildId: guild.id }) + .deleteMany({ guildId: id }) .then(async () => { - logger?.silly(`Deleted counters for guild: ${guild.id} from database`); + logger?.silly(`Deleted counters for guild: ${id} from database`); }) .catch(async (error) => { - logger?.error( - `Error deleting counters for guild: ${guild.id} - ${error}` - ); + logger?.error(`Error deleting counters for guild: ${id} - ${error}`); }); await shopRoleSchema - .deleteMany({ guildId: guild.id }) + .deleteMany({ guildId: id }) .then(async () => { - logger?.silly(`Deleted shop roles for guild: ${guild.id} from database`); + logger?.silly(`Deleted shop roles for guild: ${id} from database`); }) .catch(async (error) => { - logger?.error( - `Error deleting shop roles for guild: ${guild.id} - ${error}` - ); + logger?.error(`Error deleting shop roles for guild: ${id} - ${error}`); }); await timeoutSchema - .deleteMany({ guildId: guild.id }) + .deleteMany({ guildId: id }) .then(async () => { - logger?.silly(`Deleted timeouts for guild: ${guild.id} from database`); + logger?.silly(`Deleted timeouts for guild: ${id} from database`); }) .catch(async (error) => { - logger?.error( - `Error deleting timeouts for guild: ${guild.id} - ${error}` - ); + logger?.error(`Error deleting timeouts for guild: ${id} - ${error}`); }); }; diff --git a/src/helpers/fetchGuild/index.ts b/src/helpers/fetchGuild/index.ts index a89e840..264687e 100644 --- a/src/helpers/fetchGuild/index.ts +++ b/src/helpers/fetchGuild/index.ts @@ -1,5 +1,5 @@ // Dependencies -import { Guild } from "discord.js"; +import { Snowflake } from "discord.js"; // Models import guildSchema from "../../models/guild"; @@ -8,18 +8,18 @@ import guildSchema from "../../models/guild"; import logger from "../../logger"; // Function -export default async (guild: Guild) => { - const guildObj = await guildSchema?.findOne({ guildId: guild.id }); +export default async (id: Snowflake) => { + const guildObj = await guildSchema?.findOne({ guildId: id }); if (guildObj === null) { - const newGuildObj = new guildSchema({ guildId: guild.id }); + const newGuildObj = new guildSchema({ guildId: id }); await newGuildObj .save() .then(async () => { - logger?.silly(`Created guild: ${guild.id}`); + logger?.silly(`Created guild: ${id}`); }) .catch(async (error) => { - logger?.error(`Error creating guild: ${guild.id} - ${error}`); + logger?.error(`Error creating guild: ${id} - ${error}`); }); return newGuildObj; diff --git a/src/jobs/keepDataUpToDate/index.ts b/src/jobs/keepDataUpToDate/index.ts new file mode 100644 index 0000000..9c7f307 --- /dev/null +++ b/src/jobs/keepDataUpToDate/index.ts @@ -0,0 +1,38 @@ +import { Client, Guild } from "discord.js"; +import logger from "../../logger"; +import dropGuild from "../../helpers/dropGuild"; +import fetchGuild from "../../helpers/fetchGuild"; + +import guildSchema from "../../models/guild"; + +export const options = { + schedule: "*/5 * * * * *", // https://crontab.guru/ +}; + +export const execute = async (client: Client) => { + const guildsDB = await guildSchema.find(); + const guildsDiscord = client.guilds.cache; + + const shouldNotExist = guildsDB + .filter((x) => !guildsDiscord.some((y) => y.id === x.guildId)) + .map((z) => z.guildId); + + const shouldExist = guildsDiscord + .filter((x) => !guildsDB.some((y) => y.guildId === x.id)) + .map((z) => z.id); + + logger.silly(shouldNotExist); + logger.silly(shouldExist); + + if (shouldNotExist) { + shouldNotExist.map(async (x) => { + await dropGuild(x); + }); + } + + if (shouldExist) { + shouldExist.map(async (x) => { + await fetchGuild(x); + }); + } +}; diff --git a/src/plugins/commands/credits/modules/work/index.ts b/src/plugins/commands/credits/modules/work/index.ts index ef0a550..b61d9fe 100644 --- a/src/plugins/commands/credits/modules/work/index.ts +++ b/src/plugins/commands/credits/modules/work/index.ts @@ -43,7 +43,7 @@ export default { return logger?.silly(`Guild is null`); } - const guildDB = await fetchGuild(guild); + const guildDB = await fetchGuild(guild.id); await cooldown.command(interaction, guildDB?.credits?.workTimeout); diff --git a/src/plugins/events/guildCreate/index.ts b/src/plugins/events/guildCreate/index.ts index 60d5a3c..0d775de 100644 --- a/src/plugins/events/guildCreate/index.ts +++ b/src/plugins/events/guildCreate/index.ts @@ -11,10 +11,13 @@ export const options: IEventOptions = { export const execute = async (guild: Guild) => { const { client } = guild; - logger?.silly(`Added to guild: ${guild.name} (${guild.id})`); + if (!client.user) + throw new Error("Discord API client user is not available."); - await fetchGuild(guild); + logger.silly( + `${client.user.username} joined guild: ${guild.name} (${guild.id})` + ); + + await fetchGuild(guild.id); await updatePresence(client); - - logger.silly(`guildCreate: ${guild}`); }; diff --git a/src/plugins/events/guildDelete/index.ts b/src/plugins/events/guildDelete/index.ts index 146351f..e33d341 100644 --- a/src/plugins/events/guildDelete/index.ts +++ b/src/plugins/events/guildDelete/index.ts @@ -16,7 +16,7 @@ export const execute = async (guild: Guild) => { logger?.silly(`Deleted from guild: ${guild.name} (${guild.id})`); - await dropGuild(guild); + await dropGuild(guild.id); await updatePresence(client); logger.silly(`guildDelete: ${guild}`); diff --git a/src/plugins/events/messageCreate/modules/credits/index.ts b/src/plugins/events/messageCreate/modules/credits/index.ts index 24a5ce2..8f4a54e 100644 --- a/src/plugins/events/messageCreate/modules/credits/index.ts +++ b/src/plugins/events/messageCreate/modules/credits/index.ts @@ -17,7 +17,7 @@ export default { const { id: guildId } = guild; const { id: userId } = author; - const guildData = await fetchGuild(guild); + const guildData = await fetchGuild(guild.id); const userData = await fetchUser(author, guild); if (content.length < guildData.credits.minimumLength) return; diff --git a/src/plugins/events/messageCreate/modules/points/index.ts b/src/plugins/events/messageCreate/modules/points/index.ts index ed18003..b73dbf2 100644 --- a/src/plugins/events/messageCreate/modules/points/index.ts +++ b/src/plugins/events/messageCreate/modules/points/index.ts @@ -14,7 +14,7 @@ export default { if (author.bot) return; if (channel?.type !== "GUILD_TEXT") return; - const guildData = await fetchGuild(guild); + const guildData = await fetchGuild(guild.id); const userData = await fetchUser(author, guild); if (content.length < guildData.credits.minimumLength) return; From 21365d5ecf533e9e416744bda9096e8154b58a55 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Thu, 30 Jun 2022 12:47:27 +0200 Subject: [PATCH 004/215] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Change=20keepDataU?= =?UTF-8?q?pToDate=20to=2000:00=20on=201=20of=20month?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jobs/keepDataUpToDate/index.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/jobs/keepDataUpToDate/index.ts b/src/jobs/keepDataUpToDate/index.ts index 9c7f307..4e7262a 100644 --- a/src/jobs/keepDataUpToDate/index.ts +++ b/src/jobs/keepDataUpToDate/index.ts @@ -6,7 +6,7 @@ import fetchGuild from "../../helpers/fetchGuild"; import guildSchema from "../../models/guild"; export const options = { - schedule: "*/5 * * * * *", // https://crontab.guru/ + schedule: "0 0 1 * *", // https://crontab.guru/ }; export const execute = async (client: Client) => { @@ -21,17 +21,14 @@ export const execute = async (client: Client) => { .filter((x) => !guildsDB.some((y) => y.guildId === x.id)) .map((z) => z.id); - logger.silly(shouldNotExist); - logger.silly(shouldExist); - if (shouldNotExist) { - shouldNotExist.map(async (x) => { + shouldNotExist.forEach(async (x) => { await dropGuild(x); }); } if (shouldExist) { - shouldExist.map(async (x) => { + shouldExist.forEach(async (x) => { await fetchGuild(x); }); } From a3ba5a272cc2a28893fda8b314029766ed185d7a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 30 Jun 2022 15:53:54 +0000 Subject: [PATCH 005/215] Update dependency discord-api-types to ^0.36.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ac149cc..88fb965 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "chance": "^1.1.8", "common": "^0.2.5", "crypto": "^1.0.1", - "discord-api-types": "^0.34.0", + "discord-api-types": "^0.36.0", "discord.js": "^13.6.0", "i18n": "^0.15.0", "i18next": "^21.6.13", From f9615d9a3be59aa4b9cdfe9a8530fe0aef1fe0f7 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 2 Jul 2022 03:04:51 +0000 Subject: [PATCH 006/215] Update dependency eslint to v8.19.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ac149cc..ef172f0 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "@types/uuid": "^8.3.4", "@typescript-eslint/eslint-plugin": "^5.15.0", "@typescript-eslint/parser": "^5.15.0", - "eslint": "8.18.0", + "eslint": "8.19.0", "eslint-config-airbnb-base": "15.0.0", "eslint-config-prettier": "8.5.0", "eslint-plugin-import": "2.26.0", From b1cebba225f431d9b5a7a38524f8efa2fcdb5b66 Mon Sep 17 00:00:00 2001 From: Joshua Schmitt Date: Mon, 4 Jul 2022 15:41:31 +0000 Subject: [PATCH 007/215] feat: :sparkles: added docker support --- Dockerfile | 30 ++++++++++++++++++++++++++++++ docker-compose.yml | 33 +++++++++++++++++++++++++++++++++ package.json | 3 +++ src/config_docker/database.ts | 7 +++++++ src/config_docker/discord.ts | 14 ++++++++++++++ src/config_docker/embed.ts | 19 +++++++++++++++++++ src/config_docker/encryption.ts | 6 ++++++ src/config_docker/other.ts | 25 +++++++++++++++++++++++++ src/config_docker/reputation.ts | 2 ++ src/types/enviroment.d.ts | 27 +++++++++++++++++++++++++++ 10 files changed, 166 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 src/config_docker/database.ts create mode 100644 src/config_docker/discord.ts create mode 100644 src/config_docker/embed.ts create mode 100644 src/config_docker/encryption.ts create mode 100644 src/config_docker/other.ts create mode 100644 src/config_docker/reputation.ts create mode 100644 src/types/enviroment.d.ts diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bf1e149 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +FROM node:16 + +LABEL maintainer="me@jqshuv.xyz" +LABEL org.opencontainers.image.source https://github.com/ZynerOrg/xyter +LABEL org.opencontainers.image.description "An multi-purpose discord.js bot." +LABEL org.opencontainers.image.licenses=GPL-3.0-only + + +WORKDIR /app + +LABEL maintainer="me@jqshuv.xyz" +LABEL org.opencontainers.image.source https://github.com/ZynerOrg/xyter +LABEL org.opencontainers.image.description "An multi-purpose discord.js bot." +LABEL org.opencontainers.image.licenses=GPL-3.0-only + +COPY package* . +RUN npm install + +COPY . . +RUN mv src/config_docker src/config + +RUN npx tsc + +RUN npx tsc -v > /app/tsc.log +RUN npm -v > /app/npm.log +RUN node -v > /app/node.log + +WORKDIR /app/build + +CMD [ "npx", "nodemon" ] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..007f637 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,33 @@ +services: + app: + depends_on: + - mongodb + build: . + restart: unless-stopped + environment: + # You can leave this as-is. + - DB_HOST=mongodb + - DB_USER=mongouser + - DB_PASSWORD=mongopasword + - DB_NAME=xyter + - DB_PORT=27017 + # You have to set these values! + - DISCORD_TOKEN=YOUR_DISCORD_TOKEN + - DISCORD_CLIENT_ID=YOUR_CLIENT_ID + - DISCORD_DEV_GUILD_ID=YOUR_DEV_GUILD_ID + - HOSTER_NAME=YOUR_HOSTER_NAME + - NODE_ENV=development + stdin_open: true + tty: true + mongodb: + image: mongo:latest + restart: unless-stopped + environment: + - MONGO_INITDB_ROOT_USERNAME=mongouser + - MONGO_INITDB_ROOT_PASSWORD=mongopasword + ports: + - $MONGODB_LOCAL_PORT:27017 + volumes: + - db:/data/db +volumes: + db: diff --git a/package.json b/package.json index ac149cc..02a2bd2 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,9 @@ "url": "https://github.com/ZynerOrg/xyter.git" }, "author": "Vermium Sifell (https://zyner.org)", + "contributors": [ + "Joshua Schmitt (https://jqshuv.xyz)" + ], "license": "GPL-3.0-only", "bugs": { "url": "https://github.com/ZynerOrg/xyter/issues", diff --git a/src/config_docker/database.ts b/src/config_docker/database.ts new file mode 100644 index 0000000..0d51b49 --- /dev/null +++ b/src/config_docker/database.ts @@ -0,0 +1,7 @@ +// MongoDB connection string + +const { DB_USER, DB_PASSWORD, DB_HOST, DB_PORT, DB_NAME } = process.env; + +const mongoUrl = `mongodb://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}?authSource=admin`; + +export const url = mongoUrl; diff --git a/src/config_docker/discord.ts b/src/config_docker/discord.ts new file mode 100644 index 0000000..f3f9c4a --- /dev/null +++ b/src/config_docker/discord.ts @@ -0,0 +1,14 @@ +import { Intents } from "discord.js"; // discord.js + +// Discord API token +export const token = process.env["DISCORD_TOKEN"]; + +// Discord API id +export const clientId = process.env["DISCORD_CLIENT_ID"]; + +// Discord API intents +export const intents = [ + Intents.FLAGS.GUILDS, + Intents.FLAGS.GUILD_MESSAGES, + Intents.FLAGS.GUILD_MEMBERS, +]; diff --git a/src/config_docker/embed.ts b/src/config_docker/embed.ts new file mode 100644 index 0000000..81430e5 --- /dev/null +++ b/src/config_docker/embed.ts @@ -0,0 +1,19 @@ +// Dependencies +import { ColorResolvable } from "discord.js"; + +// Color for successfully actions +export const successColor: ColorResolvable = "#22bb33"; + +// Color for waiting actions +export const waitColor: ColorResolvable = "#f0ad4e"; + +// Color for error actions +export const errorColor: ColorResolvable = "#bb2124"; + +// Footer text +export const footerText = + process.env["EMBED_FOOTER_TEXT"] || "https://github.com/ZynerOrg/xyter"; + +// Footer icon +export const footerIcon = + process.env["EMBED_FOOTER_ICON"] || "https://github.com/ZynerOrg.png"; diff --git a/src/config_docker/encryption.ts b/src/config_docker/encryption.ts new file mode 100644 index 0000000..d54eb43 --- /dev/null +++ b/src/config_docker/encryption.ts @@ -0,0 +1,6 @@ +// Encryption algorithm +export const algorithm = "aes-256-ctr"; + +// Encryption secret (strictly 32 length) +export const secretKey = + process.env["SECRET_KEY"] || "h/f#Ts8w5sch5L:J*_gPW)]$'!4K.K.-"; diff --git a/src/config_docker/other.ts b/src/config_docker/other.ts new file mode 100644 index 0000000..96cc6c3 --- /dev/null +++ b/src/config_docker/other.ts @@ -0,0 +1,25 @@ +// Development features + +let isDevMode: boolean; + +if (process.env["NODE_ENV"] == "production") { + isDevMode = false; +} else { + isDevMode = true; +} + +export const devMode = isDevMode; + +// Development guild +export const guildId = process.env["DISCORD_DEV_GUILD_ID"]; + +// Hoster name +export const hosterName = process.env["HOSTER_NAME"]; + +// Hoster Url +export const hosterUrl = + process.env["HOSTER_URL"] || + "https://xyter.zyner.org/customization/change-hoster"; + +// Winston log level +export const logLevel = "info"; diff --git a/src/config_docker/reputation.ts b/src/config_docker/reputation.ts new file mode 100644 index 0000000..064edc9 --- /dev/null +++ b/src/config_docker/reputation.ts @@ -0,0 +1,2 @@ +// Timeout between repute someone (seconds) +export const timeout = 86400; // One day diff --git a/src/types/enviroment.d.ts b/src/types/enviroment.d.ts new file mode 100644 index 0000000..5a55579 --- /dev/null +++ b/src/types/enviroment.d.ts @@ -0,0 +1,27 @@ +// Copyright (c) 2022 Joshua Schmitt +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +declare global { + namespace NodeJS { + interface ProcessEnv { + DB_HOST: string; + DB_PORT: string; + DB_USER: string; + DB_PASSWORD: string; + DISCORD_TOKEN: string; + DISCORD_CLIENT_ID: string; + DISCORD_DEV_GUILD_ID: string; + EMBED_FOOTER_TEXT: string; + EMBED_FOOTER_ICON: string; + SECRET_KEY: string; + DISCORD_DEV_GUILD_ID: string; + HOSTER_NAME: string; + HOSTER_URL: string; + NODE_ENV: string; + } + } +} + +export {}; From 985838cdca587569319cebf507ddcfc62071de66 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 4 Jul 2022 23:05:23 +0000 Subject: [PATCH 008/215] Update dependency lint-staged to v13.0.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 25374bd..08b0c96 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "eslint-plugin-prettier": "^4.0.0", "husky": "8.0.1", "jest": "28.1.2", - "lint-staged": "13.0.1", + "lint-staged": "13.0.3", "nodemon": "^2.0.16", "prettier": "^2.6.0" }, From ef8b20984d97b72c9e37d9c14f6f95cc9f182bb8 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 5 Jul 2022 01:36:16 +0200 Subject: [PATCH 009/215] =?UTF-8?q?=F0=9F=A9=B9=20forgot=20to=20change=20f?= =?UTF-8?q?rom=20millisecs=20default=20to=20secs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/models/guild.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/models/guild.ts b/src/models/guild.ts index 0b7a78d..44b6958 100644 --- a/src/models/guild.ts +++ b/src/models/guild.ts @@ -58,7 +58,7 @@ const guildSchema = new Schema( }, timeout: { type: Number, - default: 5000, + default: 5, }, workRate: { type: Number, @@ -66,7 +66,7 @@ const guildSchema = new Schema( }, workTimeout: { type: Number, - default: 900000, + default: 900, }, }, embeds: { @@ -118,7 +118,7 @@ const guildSchema = new Schema( }, timeout: { type: Number, - default: 5000, + default: 5, }, }, welcome: { From 68bc3f6843365c6dfd8c38f9279eb9307858bd69 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 5 Jul 2022 01:38:49 +0200 Subject: [PATCH 010/215] =?UTF-8?q?=F0=9F=8E=A8=20remove=20unnecessary=20e?= =?UTF-8?q?rror=20handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/helpers/listDir/index.ts | 4 +--- src/managers/database/index.ts | 25 ++----------------------- 2 files changed, 3 insertions(+), 26 deletions(-) diff --git a/src/helpers/listDir/index.ts b/src/helpers/listDir/index.ts index 382e41d..d70afc5 100644 --- a/src/helpers/listDir/index.ts +++ b/src/helpers/listDir/index.ts @@ -2,7 +2,5 @@ import fs from "fs"; const fsPromises = fs.promises; export default async (path: string) => { - return fsPromises.readdir(path).catch(async (err) => { - throw new Error(`Could not list directory: ${path}`, err); - }); + return fsPromises.readdir(path); }; diff --git a/src/managers/database/index.ts b/src/managers/database/index.ts index 0063c61..c58af68 100644 --- a/src/managers/database/index.ts +++ b/src/managers/database/index.ts @@ -1,27 +1,6 @@ -// 3rd party dependencies import mongoose from "mongoose"; - -// Dependencies -import logger from "../../logger"; - -// Configuration import { url } from "../../config/database"; -export const start = async () => { - await mongoose - .connect(url) - .then(async (connection) => { - logger.info(`Connected to database: ${connection.connection.name}`); - }) - .catch(async (e) => { - logger.error("Could not connect to database", e); - }); - - mongoose.connection.on("error", async (error) => { - logger.error(`${error}`); - }); - - mongoose.connection.on("warn", async (warning) => { - logger.warn(warning); - }); +export const connect = async () => { + await mongoose.connect(url); }; From fcd2d18480b9519259a1070615f5206916b46bfe Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 5 Jul 2022 01:39:25 +0200 Subject: [PATCH 011/215] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20better=20command?= =?UTF-8?q?=20manager?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/managers/command/index.ts | 76 +++++++++++++++++++++++++---------- 1 file changed, 55 insertions(+), 21 deletions(-) diff --git a/src/managers/command/index.ts b/src/managers/command/index.ts index c3c08f9..508aea6 100644 --- a/src/managers/command/index.ts +++ b/src/managers/command/index.ts @@ -5,31 +5,65 @@ import logger from "../../logger"; import { ICommand } from "../../interfaces/Command"; export const register = async (client: Client) => { - client.commands = new Collection(); - + // Get name of directories containing commands const commandNames = await listDir("plugins/commands"); + if (!commandNames) throw new Error("📦 No commands available"); - if (!commandNames) throw new Error("Could not list commands"); + const amountOfCommands = commandNames.length; + let importedCommandAmount = 0; + logger.info(`📦 Trying to load ${amountOfCommands} commands`); - logger.info(`Loading ${commandNames.length} commands`); + const importCommand = async (commandName: string) => { + // Import command from plugins/commands + const command: ICommand = await import( + `../../plugins/commands/${commandName}` + ); + if (!command) + throw new Error(`📦 No command found while importing "${commandName}"`); + if (!command.builder) + throw new Error( + `📦 No command builder found while importing "${commandName}"` + ); + if (!command.execute) + throw new Error( + `📦 No command execute found while importing "${commandName}"` + ); + if (!command.moduleData) + throw new Error( + `📦 No command moduleData found while importing "${commandName}"` + ); - await Promise.all( - commandNames.map(async (commandName) => { - const command: ICommand = await import( - `../../plugins/commands/${commandName}` - ).catch(async (e) => { - throw new Error(`Could not load command: ${commandName}`, e); + // Add command to collection + client.commands.set(command.builder.name, command); + importedCommandAmount += 1; + }; + + // Send log message when it's done loading commands + const doneImporting = async () => { + if (importedCommandAmount !== amountOfCommands) { + return logger.warn( + `📦 Failed importing ${ + amountOfCommands - importedCommandAmount + } of ${amountOfCommands} commands` + ); + } + + return logger.info(`📦 Managed to load all commands`); + }; + + // Start importing commands + commandNames.forEach(async (commandName: string, index: number) => { + await importCommand(commandName) + .then(async () => { + logger.debug(`📦 Imported the "${commandName}" command`); + }) + .catch(async (err) => { + logger.error(err); }); - client.commands.set(command.builder.name, command); - - logger.verbose(`${command.builder.name} loaded`); - }) - ) - .then(async () => { - logger.info(`Finished loading commands.`); - }) - .catch(async (err) => { - throw new Error(`Could not load commands: ${err}`); - }); + // If done importing + if (index + 1 === amountOfCommands) { + await doneImporting(); + } + }); }; From 5ae6c05aef91c1d214f6ec2be6ef1d52a8b21284 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 5 Jul 2022 01:39:56 +0200 Subject: [PATCH 012/215] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20better=20event=20m?= =?UTF-8?q?anager?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/managers/event/index.ts | 76 ++++++++++++++++++++++++++++++++++--- 1 file changed, 70 insertions(+), 6 deletions(-) diff --git a/src/managers/event/index.ts b/src/managers/event/index.ts index 348e138..41f5484 100644 --- a/src/managers/event/index.ts +++ b/src/managers/event/index.ts @@ -6,15 +6,35 @@ import logger from "../../logger"; export const register = async (client: Client) => { const eventNames = await listDir("plugins/events"); - if (!eventNames) return; + if (!eventNames) throw new Error("📦 No events available"); - for await (const eventName of eventNames) { + const amountOfEvents = eventNames.length; + let importedEventAmount = 0; + logger.info(`📦 Trying to load ${amountOfEvents} events`); + + const importEvent = async (eventName: string) => { + // Import event from plugins/events const event: IEvent = await import(`../../plugins/events/${eventName}`); - const eventExecutor = async (...args: Promise[]) => - event.execute(...args).catch(async (err) => { + if (!event) + throw new Error(`📦 No event found while importing "${eventName}"`); + if (!event.options) + throw new Error( + `📦 No event options found while importing "${eventName}"` + ); + if (!event.execute) + throw new Error( + `📦 No event execute found while importing "${eventName}"` + ); + + // Register event + const eventExecutor = async (...args: Promise[]) => { + await event.execute(...args).catch(async (err) => { logger.error(`${err}`); }); - if (!event.options?.type) return; + }; + + if (!event.options?.type) + throw new Error(`📦 No event type found while importing "${eventName}"`); switch (event.options.type) { case "once": @@ -25,5 +45,49 @@ export const register = async (client: Client) => { client.on(eventName, eventExecutor); break; } - } + importedEventAmount += 1; + }; + + // Send log message when it's done loading events + const doneImporting = async () => { + if (importedEventAmount !== amountOfEvents) { + return logger.warn( + `📦 Failed importing ${ + amountOfEvents - importedEventAmount + } of ${amountOfEvents} events` + ); + } + + return logger.info(`📦 Managed to load all events`); + }; + + eventNames.forEach(async (eventName: string, index: number) => { + await importEvent(eventName).then(async () => { + logger.debug(`📦 Imported the "${eventName}" event`); + }); + + // If done importing + if (index + 1 === amountOfEvents) { + await doneImporting(); + } + }); + + // for await (const eventName of eventNames) { + // const event: IEvent = await import(`../../plugins/events/${eventName}`); + // const eventExecutor = async (...args: Promise[]) => + // event.execute(...args).catch(async (err) => { + // logger.error(`${err}`); + // }); + // if (!event.options?.type) return; + + // switch (event.options.type) { + // case "once": + // client.once(eventName, eventExecutor); + // break; + + // case "on": + // client.on(eventName, eventExecutor); + // break; + // } + // } }; From 77daf24f6d68c6cc714c67b32ccda340bf2cbea7 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 5 Jul 2022 01:40:50 +0200 Subject: [PATCH 013/215] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20better=20schedule?= =?UTF-8?q?=20manager?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/managers/index.ts | 2 +- src/managers/schedule/index.ts | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/managers/index.ts b/src/managers/index.ts index 6981d3c..a1f3dad 100644 --- a/src/managers/index.ts +++ b/src/managers/index.ts @@ -6,7 +6,7 @@ import * as event from "./event"; import * as command from "./command"; export const start = async (client: Client) => { - await database.start(); + await database.connect(); await schedule.start(client); await command.register(client); await event.register(client); diff --git a/src/managers/schedule/index.ts b/src/managers/schedule/index.ts index 9fc8aa9..753d099 100644 --- a/src/managers/schedule/index.ts +++ b/src/managers/schedule/index.ts @@ -8,22 +8,19 @@ import listDir from "../../helpers/listDir"; import schedule from "node-schedule"; export const start = async (client: Client) => { - logger.info("Starting schedule manager..."); + logger.info("⏰ Started job management"); const jobNames = await listDir("jobs"); - if (!jobNames) return logger.info("No jobs found"); + if (!jobNames) return logger.warn("No available jobs found"); await Promise.all( jobNames.map(async (jobName) => { const job: IJob = await import(`../../jobs/${jobName}`); schedule.scheduleJob(job.options.schedule, async () => { - logger.info(`Executed job ${jobName}!`); + logger.verbose(`⏰ Performed the job "${jobName}"`); await job.execute(client); }); }) - ).then(async () => { - const list = schedule.scheduledJobs; - logger.silly(list); - }); + ); }; From 1790ed09c359d2262967892dc1b2d726e3a9f630 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 5 Jul 2022 01:41:30 +0200 Subject: [PATCH 014/215] =?UTF-8?q?=F0=9F=8E=A8=20move=20command=20collect?= =?UTF-8?q?ion=20to=20index?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 4327353..c3661d7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ import { token, intents } from "./config/discord"; -import { Client } from "discord.js"; // discord.js +import { Client, Collection } from "discord.js"; // discord.js import * as managers from "./managers"; @@ -11,6 +11,9 @@ const main = async () => { intents, }); + // Create command collection + client.commands = new Collection(); + await managers.start(client); // Authorize with Discord's API From b6c55872bddbe24266d8611571f55c966ef3bff5 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 5 Jul 2022 02:03:37 +0200 Subject: [PATCH 015/215] Revert 88c6740adccdfcbaccf7edf54c4753e44bd4c263 --- package.json | 1 - src/helpers/dropGuild/index.ts | 46 +++++++++++-------- src/helpers/fetchGuild/index.ts | 12 ++--- src/jobs/keepDataUpToDate/index.ts | 35 -------------- .../commands/credits/modules/work/index.ts | 2 +- src/plugins/events/guildCreate/index.ts | 11 ++--- src/plugins/events/guildDelete/index.ts | 2 +- .../messageCreate/modules/credits/index.ts | 2 +- .../messageCreate/modules/points/index.ts | 2 +- 9 files changed, 40 insertions(+), 73 deletions(-) delete mode 100644 src/jobs/keepDataUpToDate/index.ts diff --git a/package.json b/package.json index 2c9ce18..08b0c96 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,6 @@ "tsconfig-paths": "^4.0.0", "typescript": "^4.6.3", "uuid": "^8.3.2", - "winston": "^3.8.0", "winston-daily-rotate-file": "^4.6.1" }, "devDependencies": { diff --git a/src/helpers/dropGuild/index.ts b/src/helpers/dropGuild/index.ts index 6145aa4..0c0e2ab 100644 --- a/src/helpers/dropGuild/index.ts +++ b/src/helpers/dropGuild/index.ts @@ -7,60 +7,66 @@ import timeoutSchema from "../../models/timeout"; import logger from "../../logger"; -import { Snowflake } from "discord.js"; +import { Guild } from "discord.js"; -export default async (id: Snowflake) => { +export default async (guild: Guild) => { await guildSchema - .deleteMany({ guildId: id }) + .deleteMany({ guildId: guild.id }) .then(async () => { - return logger?.silly(`Deleted guild: ${id}`); + return logger?.silly(`Deleted guild: ${guild.id}`); }) .catch(async (error) => { - logger?.error(`Error deleting guild: ${id} - ${error}`); + logger?.error(`Error deleting guild: ${guild.id} - ${error}`); }); await userSchema - .deleteMany({ guildId: id }) + .deleteMany({ guildId: guild.id }) .then(async () => { - logger?.silly(`Deleted users for guild: ${id} from database`); + logger?.silly(`Deleted users for guild: ${guild.id} from database`); }) .catch(async (error) => { - logger?.error(`Error deleting users for guild: ${id} - ${error}`); + logger?.error(`Error deleting users for guild: ${guild.id} - ${error}`); }); await apiSchema - .deleteMany({ guildId: id }) + .deleteMany({ guildId: guild.id }) .then(async () => { - logger?.silly(`Deleted apis for guild: ${id} from database`); + logger?.silly(`Deleted apis for guild: ${guild.id} from database`); }) .catch(async (error) => { - logger?.error(`Error deleting apis for guild: ${id} - ${error}`); + logger?.error(`Error deleting apis for guild: ${guild.id} - ${error}`); }); await counterSchema - .deleteMany({ guildId: id }) + .deleteMany({ guildId: guild.id }) .then(async () => { - logger?.silly(`Deleted counters for guild: ${id} from database`); + logger?.silly(`Deleted counters for guild: ${guild.id} from database`); }) .catch(async (error) => { - logger?.error(`Error deleting counters for guild: ${id} - ${error}`); + logger?.error( + `Error deleting counters for guild: ${guild.id} - ${error}` + ); }); await shopRoleSchema - .deleteMany({ guildId: id }) + .deleteMany({ guildId: guild.id }) .then(async () => { - logger?.silly(`Deleted shop roles for guild: ${id} from database`); + logger?.silly(`Deleted shop roles for guild: ${guild.id} from database`); }) .catch(async (error) => { - logger?.error(`Error deleting shop roles for guild: ${id} - ${error}`); + logger?.error( + `Error deleting shop roles for guild: ${guild.id} - ${error}` + ); }); await timeoutSchema - .deleteMany({ guildId: id }) + .deleteMany({ guildId: guild.id }) .then(async () => { - logger?.silly(`Deleted timeouts for guild: ${id} from database`); + logger?.silly(`Deleted timeouts for guild: ${guild.id} from database`); }) .catch(async (error) => { - logger?.error(`Error deleting timeouts for guild: ${id} - ${error}`); + logger?.error( + `Error deleting timeouts for guild: ${guild.id} - ${error}` + ); }); }; diff --git a/src/helpers/fetchGuild/index.ts b/src/helpers/fetchGuild/index.ts index 264687e..a89e840 100644 --- a/src/helpers/fetchGuild/index.ts +++ b/src/helpers/fetchGuild/index.ts @@ -1,5 +1,5 @@ // Dependencies -import { Snowflake } from "discord.js"; +import { Guild } from "discord.js"; // Models import guildSchema from "../../models/guild"; @@ -8,18 +8,18 @@ import guildSchema from "../../models/guild"; import logger from "../../logger"; // Function -export default async (id: Snowflake) => { - const guildObj = await guildSchema?.findOne({ guildId: id }); +export default async (guild: Guild) => { + const guildObj = await guildSchema?.findOne({ guildId: guild.id }); if (guildObj === null) { - const newGuildObj = new guildSchema({ guildId: id }); + const newGuildObj = new guildSchema({ guildId: guild.id }); await newGuildObj .save() .then(async () => { - logger?.silly(`Created guild: ${id}`); + logger?.silly(`Created guild: ${guild.id}`); }) .catch(async (error) => { - logger?.error(`Error creating guild: ${id} - ${error}`); + logger?.error(`Error creating guild: ${guild.id} - ${error}`); }); return newGuildObj; diff --git a/src/jobs/keepDataUpToDate/index.ts b/src/jobs/keepDataUpToDate/index.ts deleted file mode 100644 index 4e7262a..0000000 --- a/src/jobs/keepDataUpToDate/index.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { Client, Guild } from "discord.js"; -import logger from "../../logger"; -import dropGuild from "../../helpers/dropGuild"; -import fetchGuild from "../../helpers/fetchGuild"; - -import guildSchema from "../../models/guild"; - -export const options = { - schedule: "0 0 1 * *", // https://crontab.guru/ -}; - -export const execute = async (client: Client) => { - const guildsDB = await guildSchema.find(); - const guildsDiscord = client.guilds.cache; - - const shouldNotExist = guildsDB - .filter((x) => !guildsDiscord.some((y) => y.id === x.guildId)) - .map((z) => z.guildId); - - const shouldExist = guildsDiscord - .filter((x) => !guildsDB.some((y) => y.guildId === x.id)) - .map((z) => z.id); - - if (shouldNotExist) { - shouldNotExist.forEach(async (x) => { - await dropGuild(x); - }); - } - - if (shouldExist) { - shouldExist.forEach(async (x) => { - await fetchGuild(x); - }); - } -}; diff --git a/src/plugins/commands/credits/modules/work/index.ts b/src/plugins/commands/credits/modules/work/index.ts index b61d9fe..ef0a550 100644 --- a/src/plugins/commands/credits/modules/work/index.ts +++ b/src/plugins/commands/credits/modules/work/index.ts @@ -43,7 +43,7 @@ export default { return logger?.silly(`Guild is null`); } - const guildDB = await fetchGuild(guild.id); + const guildDB = await fetchGuild(guild); await cooldown.command(interaction, guildDB?.credits?.workTimeout); diff --git a/src/plugins/events/guildCreate/index.ts b/src/plugins/events/guildCreate/index.ts index 0d775de..60d5a3c 100644 --- a/src/plugins/events/guildCreate/index.ts +++ b/src/plugins/events/guildCreate/index.ts @@ -11,13 +11,10 @@ export const options: IEventOptions = { export const execute = async (guild: Guild) => { const { client } = guild; - if (!client.user) - throw new Error("Discord API client user is not available."); + logger?.silly(`Added to guild: ${guild.name} (${guild.id})`); - logger.silly( - `${client.user.username} joined guild: ${guild.name} (${guild.id})` - ); - - await fetchGuild(guild.id); + await fetchGuild(guild); await updatePresence(client); + + logger.silly(`guildCreate: ${guild}`); }; diff --git a/src/plugins/events/guildDelete/index.ts b/src/plugins/events/guildDelete/index.ts index e33d341..146351f 100644 --- a/src/plugins/events/guildDelete/index.ts +++ b/src/plugins/events/guildDelete/index.ts @@ -16,7 +16,7 @@ export const execute = async (guild: Guild) => { logger?.silly(`Deleted from guild: ${guild.name} (${guild.id})`); - await dropGuild(guild.id); + await dropGuild(guild); await updatePresence(client); logger.silly(`guildDelete: ${guild}`); diff --git a/src/plugins/events/messageCreate/modules/credits/index.ts b/src/plugins/events/messageCreate/modules/credits/index.ts index 8f4a54e..24a5ce2 100644 --- a/src/plugins/events/messageCreate/modules/credits/index.ts +++ b/src/plugins/events/messageCreate/modules/credits/index.ts @@ -17,7 +17,7 @@ export default { const { id: guildId } = guild; const { id: userId } = author; - const guildData = await fetchGuild(guild.id); + const guildData = await fetchGuild(guild); const userData = await fetchUser(author, guild); if (content.length < guildData.credits.minimumLength) return; diff --git a/src/plugins/events/messageCreate/modules/points/index.ts b/src/plugins/events/messageCreate/modules/points/index.ts index b73dbf2..ed18003 100644 --- a/src/plugins/events/messageCreate/modules/points/index.ts +++ b/src/plugins/events/messageCreate/modules/points/index.ts @@ -14,7 +14,7 @@ export default { if (author.bot) return; if (channel?.type !== "GUILD_TEXT") return; - const guildData = await fetchGuild(guild.id); + const guildData = await fetchGuild(guild); const userData = await fetchUser(author, guild); if (content.length < guildData.credits.minimumLength) return; From 1a40d4ada83e903bc368e3fb6cccdceede34b5e6 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 5 Jul 2022 15:17:02 +0200 Subject: [PATCH 016/215] =?UTF-8?q?=F0=9F=92=A5=20migrate=20from=20*.ts=20?= =?UTF-8?q?to=20.env=20configs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 3 +++ package.json | 1 + src/config_example/database.ts | 3 --- src/config_example/discord.ts | 14 ---------- src/config_example/embed.ts | 17 ------------ src/config_example/encryption.ts | 5 ---- src/config_example/other.ts | 14 ---------- src/config_example/reputation.ts | 2 -- src/handlers/deployCommands/index.ts | 22 +++++++++------- src/handlers/devMode/index.ts | 15 +++++------ src/handlers/encryption/index.ts | 13 +++++----- src/helpers/embedBuilder/index.ts | 5 ++-- src/helpers/getEmbedConfig/index.ts | 22 ++++++++++++---- src/index.ts | 6 ++--- src/logger/index.ts | 4 +-- src/managers/database/index.ts | 19 ++++++++++++-- src/managers/index.ts | 1 + .../commands/reputation/modules/give/index.ts | 3 +-- .../commands/utility/modules/about/index.ts | 5 ++-- src/types/common/environment.d.ts | 26 +++++++++++++++++++ 20 files changed, 98 insertions(+), 102 deletions(-) delete mode 100644 src/config_example/database.ts delete mode 100644 src/config_example/discord.ts delete mode 100644 src/config_example/embed.ts delete mode 100644 src/config_example/encryption.ts delete mode 100644 src/config_example/other.ts delete mode 100644 src/config_example/reputation.ts create mode 100644 src/types/common/environment.d.ts diff --git a/.vscode/settings.json b/.vscode/settings.json index 38d1af9..edd979a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -22,5 +22,8 @@ "addWords": true, "scope": "workspace" } + }, + "[dotenv]": { + "editor.defaultFormatter": "foxundermoon.shell-format" } } diff --git a/package.json b/package.json index 08b0c96..3ca6361 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "crypto": "^1.0.1", "discord-api-types": "^0.36.0", "discord.js": "^13.6.0", + "dotenv": "^16.0.1", "i18n": "^0.15.0", "i18next": "^21.6.13", "i18next-async-backend": "^2.0.0", diff --git a/src/config_example/database.ts b/src/config_example/database.ts deleted file mode 100644 index 35e2e27..0000000 --- a/src/config_example/database.ts +++ /dev/null @@ -1,3 +0,0 @@ -// MongoDB connection string -export const url = - "mongodb+srv://username:password@server/database?retryWrites=true&w=majority"; diff --git a/src/config_example/discord.ts b/src/config_example/discord.ts deleted file mode 100644 index 7b22c28..0000000 --- a/src/config_example/discord.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Intents } from "discord.js"; // discord.js - -// Discord API token -export const token = ""; - -// Discord API id -export const clientId = ""; - -// Discord API intents -export const intents = [ - Intents.FLAGS.GUILDS, - Intents.FLAGS.GUILD_MESSAGES, - Intents.FLAGS.GUILD_MEMBERS, -]; diff --git a/src/config_example/embed.ts b/src/config_example/embed.ts deleted file mode 100644 index d6eebb1..0000000 --- a/src/config_example/embed.ts +++ /dev/null @@ -1,17 +0,0 @@ -// Dependencies -import { ColorResolvable } from "discord.js"; - -// Color for successfully actions -export const successColor: ColorResolvable = "#22bb33"; - -// Color for waiting actions -export const waitColor: ColorResolvable = "#f0ad4e"; - -// Color for error actions -export const errorColor: ColorResolvable = "#bb2124"; - -// Footer text -export const footerText = "https://github.com/ZynerOrg/xyter"; - -// Footer icon -export const footerIcon = "https://github.com/ZynerOrg.png"; diff --git a/src/config_example/encryption.ts b/src/config_example/encryption.ts deleted file mode 100644 index 9d547f1..0000000 --- a/src/config_example/encryption.ts +++ /dev/null @@ -1,5 +0,0 @@ -// Encryption algorithm -export const algorithm = "aes-256-ctr"; - -// Encryption secret (strictly 32 length) -export const secretKey = ""; diff --git a/src/config_example/other.ts b/src/config_example/other.ts deleted file mode 100644 index eefd62c..0000000 --- a/src/config_example/other.ts +++ /dev/null @@ -1,14 +0,0 @@ -// Development features -export const devMode = false; - -// Development guild -export const guildId = ""; - -// Hoster name -export const hosterName = "someone"; - -// Hoster Url -export const hosterUrl = "https://xyter.zyner.org/customization/change-hoster"; - -// Winston log level -export const logLevel = "info"; diff --git a/src/config_example/reputation.ts b/src/config_example/reputation.ts deleted file mode 100644 index 064edc9..0000000 --- a/src/config_example/reputation.ts +++ /dev/null @@ -1,2 +0,0 @@ -// Timeout between repute someone (seconds) -export const timeout = 86400; // One day diff --git a/src/handlers/deployCommands/index.ts b/src/handlers/deployCommands/index.ts index 492e1ab..9491db5 100644 --- a/src/handlers/deployCommands/index.ts +++ b/src/handlers/deployCommands/index.ts @@ -1,12 +1,8 @@ -import { token, clientId } from "../../config/discord"; -import { devMode, guildId } from "../../config/other"; - import logger from "../../logger"; import { Client } from "discord.js"; import { REST } from "@discordjs/rest"; import { Routes } from "discord-api-types/v9"; import { RESTPostAPIApplicationCommandsJSONBody } from "discord-api-types/v10"; - import { ICommand } from "../../interfaces/Command"; export default async (client: Client) => { @@ -32,10 +28,10 @@ export default async (client: Client) => { throw new Error(`Could not gather command list: ${error}`); }); - const rest = new REST({ version: "9" }).setToken(token); + const rest = new REST({ version: "9" }).setToken(process.env.DISCORD_TOKEN); await rest - .put(Routes.applicationCommands(clientId), { + .put(Routes.applicationCommands(process.env.DISCORD_CLIENT_ID), { body: commandList, }) .then(async () => { @@ -45,11 +41,17 @@ export default async (client: Client) => { logger.error(`${error}`); }); - if (devMode) { + if (process.env.NODE_ENV !== "production") { await rest - .put(Routes.applicationGuildCommands(clientId, guildId), { - body: commandList, - }) + .put( + Routes.applicationGuildCommands( + process.env.DISCORD_CLIENT_ID, + process.env.DISCORD_GUILD_ID + ), + { + body: commandList, + } + ) .then(async () => logger.info(`Finished updating guild command list.`)) .catch(async (error) => { logger.error(`${error}`); diff --git a/src/handlers/devMode/index.ts b/src/handlers/devMode/index.ts index c7900a0..ba36b50 100644 --- a/src/handlers/devMode/index.ts +++ b/src/handlers/devMode/index.ts @@ -1,16 +1,13 @@ -// Dependencies import { Client } from "discord.js"; - import logger from "../../logger"; -// Configuration -import { devMode, guildId } from "../../config/other"; - export default async (client: Client) => { - if (!devMode) { - return client?.application?.commands?.set([], guildId).then(async () => { - return logger.verbose(`Development mode is disabled.`); - }); + if (process.env.NODE_ENV !== "production") { + return client?.application?.commands + ?.set([], process.env.DISCORD_GUILD_ID) + .then(async () => { + return logger.verbose(`Development mode is disabled.`); + }); } return logger.info(`Development mode is enabled.`); diff --git a/src/handlers/encryption/index.ts b/src/handlers/encryption/index.ts index 8b6512c..0e1c027 100644 --- a/src/handlers/encryption/index.ts +++ b/src/handlers/encryption/index.ts @@ -1,13 +1,14 @@ import crypto from "crypto"; - -import { secretKey, algorithm } from "../../config/encryption"; - import { IEncryptionData } from "../../interfaces/EncryptionData"; const iv = crypto.randomBytes(16); const encrypt = (text: crypto.BinaryLike): IEncryptionData => { - const cipher = crypto.createCipheriv(algorithm, secretKey, iv); + const cipher = crypto.createCipheriv( + process.env.ENCRYPTION_ALGORITHM, + process.env.ENCRYPTION_SECRET, + iv + ); const encrypted = Buffer.concat([cipher.update(text), cipher.final()]); return { @@ -18,8 +19,8 @@ const encrypt = (text: crypto.BinaryLike): IEncryptionData => { const decrypt = (hash: IEncryptionData) => { const decipher = crypto.createDecipheriv( - algorithm, - secretKey, + process.env.ENCRYPTION_ALGORITHM, + process.env.ENCRYPTION_SECRET, Buffer.from(hash.iv, "hex") ); diff --git a/src/helpers/embedBuilder/index.ts b/src/helpers/embedBuilder/index.ts index d93cc5c..6d6a51d 100644 --- a/src/helpers/embedBuilder/index.ts +++ b/src/helpers/embedBuilder/index.ts @@ -1,9 +1,8 @@ -import { footerText, footerIcon } from "../../config/embed"; import { MessageEmbed } from "discord.js"; export default new MessageEmbed() .setFooter({ - text: footerText, - iconURL: footerIcon, + text: process.env.EMBED_FOOTER_TEXT, + iconURL: process.env.EMBED_FOOTER_ICON, }) .setTimestamp(new Date()); diff --git a/src/helpers/getEmbedConfig/index.ts b/src/helpers/getEmbedConfig/index.ts index ccd3fdb..0d88716 100644 --- a/src/helpers/getEmbedConfig/index.ts +++ b/src/helpers/getEmbedConfig/index.ts @@ -1,18 +1,30 @@ import guildSchema from "../../models/guild"; -import * as embedConfig from "../../config/embed"; import { Guild } from "discord.js"; export default async (guild?: Guild | null) => { + const { + EMBED_COLOR_SUCCESS, + EMBED_COLOR_WAIT, + EMBED_COLOR_ERROR, + EMBED_FOOTER_TEXT, + EMBED_FOOTER_ICON, + } = process.env; + + const defaultEmbedConfig = { + successColor: EMBED_COLOR_SUCCESS, + waitColor: EMBED_COLOR_WAIT, + errorColor: EMBED_COLOR_ERROR, + footerText: EMBED_FOOTER_TEXT, + footerIcon: EMBED_FOOTER_ICON, + }; if (!guild) { - return { ...embedConfig }; + return defaultEmbedConfig; } const guildConfig = await guildSchema.findOne({ guildId: guild.id }); if (!guildConfig) { - return { - ...embedConfig, - }; + return defaultEmbedConfig; } return guildConfig.embeds; }; diff --git a/src/index.ts b/src/index.ts index c3661d7..a33abb5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,3 @@ -import { token, intents } from "./config/discord"; - import { Client, Collection } from "discord.js"; // discord.js import * as managers from "./managers"; @@ -8,7 +6,7 @@ import * as managers from "./managers"; const main = async () => { // Initiate client object const client = new Client({ - intents, + intents: ["GUILDS", "GUILD_MEMBERS", "GUILD_MESSAGES"], }); // Create command collection @@ -17,7 +15,7 @@ const main = async () => { await managers.start(client); // Authorize with Discord's API - await client.login(token); + await client.login(process.env.DISCORD_TOKEN); }; main(); diff --git a/src/logger/index.ts b/src/logger/index.ts index 0593ec9..a91f01d 100644 --- a/src/logger/index.ts +++ b/src/logger/index.ts @@ -1,13 +1,11 @@ import winston from "winston"; import "winston-daily-rotate-file"; -import { logLevel } from "../config/other"; - const { combine, timestamp, printf, errors, colorize, align, json } = winston.format; export default winston.createLogger({ - level: logLevel || "info", + level: process.env.LOG_LEVEL || "info", transports: [ new winston.transports.DailyRotateFile({ filename: "logs/combined-%DATE%.log", diff --git a/src/managers/database/index.ts b/src/managers/database/index.ts index c58af68..4b65e4f 100644 --- a/src/managers/database/index.ts +++ b/src/managers/database/index.ts @@ -1,6 +1,21 @@ import mongoose from "mongoose"; -import { url } from "../../config/database"; +import logger from "../../logger"; export const connect = async () => { - await mongoose.connect(url); + await mongoose + .connect(process.env.MONGO_URL) + .then(async (connection) => { + logger.info(`💾 Connected to database: ${connection.connection.name}`); + }) + .catch(async (e) => { + logger.error("💾 Could not connect to database", e); + }); + + mongoose.connection.on("error", async (error) => { + logger.error(`💾 ${error}`); + }); + + mongoose.connection.on("warn", async (warning) => { + logger.warn(`💾 ${warning}`); + }); }; diff --git a/src/managers/index.ts b/src/managers/index.ts index a1f3dad..4e74859 100644 --- a/src/managers/index.ts +++ b/src/managers/index.ts @@ -1,3 +1,4 @@ +import "dotenv/config"; import { Client } from "discord.js"; import * as database from "./database"; diff --git a/src/plugins/commands/reputation/modules/give/index.ts b/src/plugins/commands/reputation/modules/give/index.ts index f9970df..5416ee1 100644 --- a/src/plugins/commands/reputation/modules/give/index.ts +++ b/src/plugins/commands/reputation/modules/give/index.ts @@ -1,6 +1,5 @@ import { CommandInteraction } from "discord.js"; import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; -import { timeout } from "../../../../../config/reputation"; import logger from "../../../../../logger"; import fetchUser from "../../../../../helpers/fetchUser"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; @@ -53,7 +52,7 @@ export default { await noSelfReputation(optionTarget, user); // Check if user is on cooldown otherwise create one - await cooldown.command(interaction, timeout); + await cooldown.command(interaction, process.env.REPUTATION_TIMEOUT); switch (optionType) { case "positive": diff --git a/src/plugins/commands/utility/modules/about/index.ts b/src/plugins/commands/utility/modules/about/index.ts index 92af9cb..e3670b3 100644 --- a/src/plugins/commands/utility/modules/about/index.ts +++ b/src/plugins/commands/utility/modules/about/index.ts @@ -8,7 +8,6 @@ import { // Configurations import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; -import { hosterName, hosterUrl } from "../../../../../config/other"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function @@ -45,10 +44,10 @@ export default { .setEmoji("💬") .setURL("https://discord.zyner.org"), new MessageButton() - .setLabel(`Hosted by ${hosterName}`) + .setLabel(`Hosted by ${process.env.BOT_HOSTER_NAME}`) .setStyle("LINK") .setEmoji("⚒️") - .setURL(`${hosterUrl}`) + .setURL(`${process.env.BOT_HOSTER_URL}`) ); const interactionEmbed = { diff --git a/src/types/common/environment.d.ts b/src/types/common/environment.d.ts new file mode 100644 index 0000000..4c1ee6c --- /dev/null +++ b/src/types/common/environment.d.ts @@ -0,0 +1,26 @@ +import { Snowflake, ColorResolvable } from "discord.js"; + +declare global { + namespace NodeJS { + interface ProcessEnv { + MONGO_URL: string; + DISCORD_TOKEN: string; + DISCORD_CLIENT_ID: Snowflake; + DISCORD_GUILD_ID: Snowflake; + DEVELOPMENT_MODE: boolean; + ENCRYPTION_ALGORITHM: string; + ENCRYPTION_SECRET: string; + EMBED_COLOR_SUCCESS: ColorResolvable; + EMBED_COLOR_WAIT: ColorResolvable; + EMBED_COLOR_ERROR: ColorResolvable; + EMBED_FOOTER_TEXT: string; + EMBED_FOOTER_ICON: string; + LOG_LEVEL: string; + REPUTATION_TIMEOUT: number; + BOT_HOSTER_NAME: string; + BOT_HOSTER_URL: string; + } + } +} + +export {}; From 9948c63d630adae34adda26a1117d4733753c5f1 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Tue, 5 Jul 2022 15:20:54 +0200 Subject: [PATCH 017/215] =?UTF-8?q?=F0=9F=94=A7=20example=20env?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..51665d3 --- /dev/null +++ b/.env.example @@ -0,0 +1,30 @@ +# THIS FILE SHOULD BE INSIDE OF build/ + +# Discord +DISCORD_TOKEN="" +DISCORD_CLIENT_ID="" +DISCORD_GUILD_ID="" + +# Database +MONGO_URL="mongodb+srv://username:password@host/database?retryWrites=true&w=majority" + +# Encryption +ENCRYPTION_ALGORITHM="aes-256-ctr" +ENCRYPTION_SECRET="A RANDOM STRING WITH LENGTH OF 32" + +#Embed +EMEBD_COLOR_SUCCESS="#22bb33" +EMBED_COLOR_WAIT="#f0ad4e" +EMBED_COLOR_ERROR="#bb2124" +EMBED_FOOTER_TEXT="https://github.com/ZynerOrg/xyter" +EMBED_FOOTER_ICON="https://github.com/ZynerOrg.png" + +# Log +LOG_LEVEL="silly" + +# Reputation +REPUTATION_TIMEOUT="86400" + +# Bot Hoster +BOT_HOSTER_NAME="Zyner" +BOT_HOSTER_URL="https://xyter.zyner.org/customization/change-hoster" From fbcbf8545b3cde8f3634b4a98c0a46af10cecb1f Mon Sep 17 00:00:00 2001 From: Joshua Schmitt Date: Tue, 5 Jul 2022 16:07:02 +0000 Subject: [PATCH 018/215] fix: :rocket: fix and rewrote docker stuff I reworked the docker files and added docker support for the new config system. The old config system is no longer working --- .dockerignore | 6 +++++ .gitignore | 5 ++++ Dockerfile | 20 +++------------ docker-compose.dev.yml | 33 +++++++++++++++++++++++++ docker-compose.yml | 44 ++++++++++++++++----------------- src/config_docker/database.ts | 7 ------ src/config_docker/discord.ts | 14 ----------- src/config_docker/embed.ts | 19 -------------- src/config_docker/encryption.ts | 6 ----- src/config_docker/other.ts | 25 ------------------- src/config_docker/reputation.ts | 2 -- src/types/enviroment.d.ts | 27 -------------------- 12 files changed, 69 insertions(+), 139 deletions(-) create mode 100644 .dockerignore create mode 100644 docker-compose.dev.yml delete mode 100644 src/config_docker/database.ts delete mode 100644 src/config_docker/discord.ts delete mode 100644 src/config_docker/embed.ts delete mode 100644 src/config_docker/encryption.ts delete mode 100644 src/config_docker/other.ts delete mode 100644 src/config_docker/reputation.ts delete mode 100644 src/types/enviroment.d.ts diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..efa748a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.vscode +.husky +.github +.cspell +.env +node_modules \ No newline at end of file diff --git a/.gitignore b/.gitignore index 9fe2862..ff5dc1a 100644 --- a/.gitignore +++ b/.gitignore @@ -140,3 +140,8 @@ dist .yarn/build-state.yml .yarn/install-state.gz .pnp.* + + +# Docker +database +docker-compose.local.yml \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index bf1e149..af5581d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,30 +1,16 @@ FROM node:16 -LABEL maintainer="me@jqshuv.xyz" -LABEL org.opencontainers.image.source https://github.com/ZynerOrg/xyter -LABEL org.opencontainers.image.description "An multi-purpose discord.js bot." -LABEL org.opencontainers.image.licenses=GPL-3.0-only - +LABEL maintainer="xyter@zyner.org" WORKDIR /app -LABEL maintainer="me@jqshuv.xyz" -LABEL org.opencontainers.image.source https://github.com/ZynerOrg/xyter -LABEL org.opencontainers.image.description "An multi-purpose discord.js bot." -LABEL org.opencontainers.image.licenses=GPL-3.0-only - COPY package* . RUN npm install COPY . . -RUN mv src/config_docker src/config -RUN npx tsc - -RUN npx tsc -v > /app/tsc.log -RUN npm -v > /app/npm.log -RUN node -v > /app/node.log +RUN npx -y tsc WORKDIR /app/build -CMD [ "npx", "nodemon" ] \ No newline at end of file +CMD [ "node", "." ] \ No newline at end of file diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml new file mode 100644 index 0000000..5765287 --- /dev/null +++ b/docker-compose.dev.yml @@ -0,0 +1,33 @@ +services: + app: + depends_on: + - mongodb + build: . + restart: unless-stopped + environment: + - DISCORD_TOKEN=YOUR TOKEN + - DISCORD_CLIENT_ID=YOUR CLIENT ID + - DISCORD_GUILD_ID=YOUR GUILD ID + ### LEAVE THIS AS IT IS! ### + - MONGO_URL=mongodb://mongodb:27017/xyter?retryWrites=true&w=majority + ############################ + - ENCRYPTION_ALGORITHM=aes-256-ctr + - ENCRYPTION_SECRET=A RANDOM STRING WITH LENGTH OF 32 + - EMEBD_COLOR_SUCCESS=#22bb33 + - EMBED_COLOR_WAIT=#f0ad4e + - EMBED_COLOR_ERROR=#bb2124 + - EMBED_FOOTER_TEXT=https://github.com/ZynerOrg/xyter + - EMBED_FOOTER_ICON=https://github.com/ZynerOrg.png + - LOG_LEVEL=silly + - REPUTATION_TIMEOUT=86400 + - BOT_HOSTER_NAME=Zyner + - BOT_HOSTER_URL=https://xyter.zyner.org/customization/change-hoster + - NODE_ENV=production + stdin_open: true + tty: true + mongodb: + image: mongo:4.2.21 + restart: unless-stopped + volumes: + - ./logs:/app/build/logs + - ./database:/data/db diff --git a/docker-compose.yml b/docker-compose.yml index 007f637..9b08008 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,32 +2,32 @@ services: app: depends_on: - mongodb - build: . + image: zyner/xyter:2022.07.0 restart: unless-stopped environment: - # You can leave this as-is. - - DB_HOST=mongodb - - DB_USER=mongouser - - DB_PASSWORD=mongopasword - - DB_NAME=xyter - - DB_PORT=27017 - # You have to set these values! - - DISCORD_TOKEN=YOUR_DISCORD_TOKEN - - DISCORD_CLIENT_ID=YOUR_CLIENT_ID - - DISCORD_DEV_GUILD_ID=YOUR_DEV_GUILD_ID - - HOSTER_NAME=YOUR_HOSTER_NAME - - NODE_ENV=development + - DISCORD_TOKEN=YOUR TOKEN + - DISCORD_CLIENT_ID=YOUR CLIENT ID + - DISCORD_GUILD_ID=YOUR GUILD ID + ### LEAVE THIS AS IT IS! ### + - MONGO_URL=mongodb://mongodb:27017/xyter?retryWrites=true&w=majority + ############################ + - ENCRYPTION_ALGORITHM=aes-256-ctr + - ENCRYPTION_SECRET=A RANDOM STRING WITH LENGTH OF 32 + - EMEBD_COLOR_SUCCESS=#22bb33 + - EMBED_COLOR_WAIT=#f0ad4e + - EMBED_COLOR_ERROR=#bb2124 + - EMBED_FOOTER_TEXT=https://github.com/ZynerOrg/xyter + - EMBED_FOOTER_ICON=https://github.com/ZynerOrg.png + - LOG_LEVEL=silly + - REPUTATION_TIMEOUT=86400 + - BOT_HOSTER_NAME=Zyner + - BOT_HOSTER_URL=https://xyter.zyner.org/customization/change-hoster + - NODE_ENV=production stdin_open: true tty: true mongodb: - image: mongo:latest + image: mongo:4.2.21 restart: unless-stopped - environment: - - MONGO_INITDB_ROOT_USERNAME=mongouser - - MONGO_INITDB_ROOT_PASSWORD=mongopasword - ports: - - $MONGODB_LOCAL_PORT:27017 volumes: - - db:/data/db -volumes: - db: + - ./logs:/app/build/logs + - ./database:/data/db diff --git a/src/config_docker/database.ts b/src/config_docker/database.ts deleted file mode 100644 index 0d51b49..0000000 --- a/src/config_docker/database.ts +++ /dev/null @@ -1,7 +0,0 @@ -// MongoDB connection string - -const { DB_USER, DB_PASSWORD, DB_HOST, DB_PORT, DB_NAME } = process.env; - -const mongoUrl = `mongodb://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}?authSource=admin`; - -export const url = mongoUrl; diff --git a/src/config_docker/discord.ts b/src/config_docker/discord.ts deleted file mode 100644 index f3f9c4a..0000000 --- a/src/config_docker/discord.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Intents } from "discord.js"; // discord.js - -// Discord API token -export const token = process.env["DISCORD_TOKEN"]; - -// Discord API id -export const clientId = process.env["DISCORD_CLIENT_ID"]; - -// Discord API intents -export const intents = [ - Intents.FLAGS.GUILDS, - Intents.FLAGS.GUILD_MESSAGES, - Intents.FLAGS.GUILD_MEMBERS, -]; diff --git a/src/config_docker/embed.ts b/src/config_docker/embed.ts deleted file mode 100644 index 81430e5..0000000 --- a/src/config_docker/embed.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Dependencies -import { ColorResolvable } from "discord.js"; - -// Color for successfully actions -export const successColor: ColorResolvable = "#22bb33"; - -// Color for waiting actions -export const waitColor: ColorResolvable = "#f0ad4e"; - -// Color for error actions -export const errorColor: ColorResolvable = "#bb2124"; - -// Footer text -export const footerText = - process.env["EMBED_FOOTER_TEXT"] || "https://github.com/ZynerOrg/xyter"; - -// Footer icon -export const footerIcon = - process.env["EMBED_FOOTER_ICON"] || "https://github.com/ZynerOrg.png"; diff --git a/src/config_docker/encryption.ts b/src/config_docker/encryption.ts deleted file mode 100644 index d54eb43..0000000 --- a/src/config_docker/encryption.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Encryption algorithm -export const algorithm = "aes-256-ctr"; - -// Encryption secret (strictly 32 length) -export const secretKey = - process.env["SECRET_KEY"] || "h/f#Ts8w5sch5L:J*_gPW)]$'!4K.K.-"; diff --git a/src/config_docker/other.ts b/src/config_docker/other.ts deleted file mode 100644 index 96cc6c3..0000000 --- a/src/config_docker/other.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Development features - -let isDevMode: boolean; - -if (process.env["NODE_ENV"] == "production") { - isDevMode = false; -} else { - isDevMode = true; -} - -export const devMode = isDevMode; - -// Development guild -export const guildId = process.env["DISCORD_DEV_GUILD_ID"]; - -// Hoster name -export const hosterName = process.env["HOSTER_NAME"]; - -// Hoster Url -export const hosterUrl = - process.env["HOSTER_URL"] || - "https://xyter.zyner.org/customization/change-hoster"; - -// Winston log level -export const logLevel = "info"; diff --git a/src/config_docker/reputation.ts b/src/config_docker/reputation.ts deleted file mode 100644 index 064edc9..0000000 --- a/src/config_docker/reputation.ts +++ /dev/null @@ -1,2 +0,0 @@ -// Timeout between repute someone (seconds) -export const timeout = 86400; // One day diff --git a/src/types/enviroment.d.ts b/src/types/enviroment.d.ts deleted file mode 100644 index 5a55579..0000000 --- a/src/types/enviroment.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2022 Joshua Schmitt -// -// This software is released under the MIT License. -// https://opensource.org/licenses/MIT - -declare global { - namespace NodeJS { - interface ProcessEnv { - DB_HOST: string; - DB_PORT: string; - DB_USER: string; - DB_PASSWORD: string; - DISCORD_TOKEN: string; - DISCORD_CLIENT_ID: string; - DISCORD_DEV_GUILD_ID: string; - EMBED_FOOTER_TEXT: string; - EMBED_FOOTER_ICON: string; - SECRET_KEY: string; - DISCORD_DEV_GUILD_ID: string; - HOSTER_NAME: string; - HOSTER_URL: string; - NODE_ENV: string; - } - } -} - -export {}; From 854ea0ce5fed4751dffc5eb86fc955c8b288079a Mon Sep 17 00:00:00 2001 From: Joshua Schmitt Date: Tue, 5 Jul 2022 16:08:07 +0000 Subject: [PATCH 019/215] style: :lipstick: fix style --- src/plugins/commands/moderation/modules/prune/index.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/plugins/commands/moderation/modules/prune/index.ts b/src/plugins/commands/moderation/modules/prune/index.ts index c847e47..e556969 100644 --- a/src/plugins/commands/moderation/modules/prune/index.ts +++ b/src/plugins/commands/moderation/modules/prune/index.ts @@ -1,8 +1,5 @@ // Dependencies -import { - CommandInteraction, - Permissions, -} from "discord.js"; +import { CommandInteraction, Permissions } from "discord.js"; // Configurations import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; From aa14252108adebf156e277195b51d892130f3de0 Mon Sep 17 00:00:00 2001 From: Joshua Schmitt Date: Tue, 5 Jul 2022 21:56:46 +0200 Subject: [PATCH 020/215] fix: :construction: fix review files --- .env.docker | 31 ++++++++++++++++++++++++++++ Dockerfile | 7 +++++-- docker-compose.dev.yml | 46 ++++++++++++++++++++++-------------------- docker-compose.yml | 46 ++++++++++++++++++++++-------------------- 4 files changed, 84 insertions(+), 46 deletions(-) create mode 100644 .env.docker diff --git a/.env.docker b/.env.docker new file mode 100644 index 0000000..98657c8 --- /dev/null +++ b/.env.docker @@ -0,0 +1,31 @@ +# RENAME THIS FILE TO .env TO USE IT WITH DOCKER! + +# Discord +DISCORD_TOKEN= +DISCORD_CLIENT_ID= +DISCORD_GUILD_ID= + +# Database +MONGO_USER= +MONGO_PASS= + +# Encryption +ENCRYPTION_ALGORITHM=aes-256-ctr +ENCRYPTION_SECRET=A RANDOM STRING WITH LENGTH OF 32 + +#Embed +EMEBD_COLOR_SUCCESS=#22bb33 +EMBED_COLOR_WAIT=#f0ad4e +EMBED_COLOR_ERROR=#bb2124 +EMBED_FOOTER_TEXT=https://github.com/ZynerOrg/xyter +EMBED_FOOTER_ICON=https://github.com/ZynerOrg.png + +# Log +LOG_LEVEL=silly + +# Reputation +REPUTATION_TIMEOUT=86400 + +# Bot Hoster +BOT_HOSTER_NAME=Zyner +BOT_HOSTER_URL=https://xyter.zyner.org/customization/change-hoster diff --git a/Dockerfile b/Dockerfile index af5581d..a626b7a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM node:16 LABEL maintainer="xyter@zyner.org" -WORKDIR /app +WORKDIR /build COPY package* . RUN npm install @@ -11,6 +11,9 @@ COPY . . RUN npx -y tsc -WORKDIR /app/build +WORKDIR /app + +RUN cp -r /build/build/* . +RUN cp -r /build/node_modules . CMD [ "node", "." ] \ No newline at end of file diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 5765287..fed3dc4 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -5,29 +5,31 @@ services: build: . restart: unless-stopped environment: - - DISCORD_TOKEN=YOUR TOKEN - - DISCORD_CLIENT_ID=YOUR CLIENT ID - - DISCORD_GUILD_ID=YOUR GUILD ID - ### LEAVE THIS AS IT IS! ### - - MONGO_URL=mongodb://mongodb:27017/xyter?retryWrites=true&w=majority - ############################ - - ENCRYPTION_ALGORITHM=aes-256-ctr - - ENCRYPTION_SECRET=A RANDOM STRING WITH LENGTH OF 32 - - EMEBD_COLOR_SUCCESS=#22bb33 - - EMBED_COLOR_WAIT=#f0ad4e - - EMBED_COLOR_ERROR=#bb2124 - - EMBED_FOOTER_TEXT=https://github.com/ZynerOrg/xyter - - EMBED_FOOTER_ICON=https://github.com/ZynerOrg.png - - LOG_LEVEL=silly - - REPUTATION_TIMEOUT=86400 - - BOT_HOSTER_NAME=Zyner - - BOT_HOSTER_URL=https://xyter.zyner.org/customization/change-hoster - - NODE_ENV=production + - DISCORD_TOKEN=${DISCORD_TOKEN} + - DISCORD_CLIENT_ID=${DISCORD_CLIENT_ID} + - DISCORD_GUILD_ID=${DISCORD_GUILD_ID} + - MONGO_URL=mongodb://${MONGO_USER}:${MONGO_PASS}@mongodb:27017/admin?retryWrites=true&w=majority + - ENCRYPTION_ALGORITHM=${ENCRYPTION_ALGORITHM} + - ENCRYPTION_SECRET=${ENCRYPTION_SECRET} + - EMEBD_COLOR_SUCCESS=${EMEBD_COLOR_SUCCESS} + - EMBED_COLOR_WAIT=${EMBED_COLOR_WAIT} + - EMBED_COLOR_ERROR=${EMBED_COLOR_ERROR} + - EMBED_FOOTER_TEXT=${EMBED_FOOTER_TEXT} + - EMBED_FOOTER_ICON=${EMBED_FOOTER_ICON} + - LOG_LEVEL=${LOG_LEVEL} + - REPUTATION_TIMEOUT=${REPUTATION_TIMEOUT} + - BOT_HOSTER_NAME=${BOT_HOSTER_NAME} + - BOT_HOSTER_URL=${BOT_HOSTER_URL} + - NODE_ENV=development stdin_open: true tty: true - mongodb: - image: mongo:4.2.21 - restart: unless-stopped volumes: - - ./logs:/app/build/logs + - ./logs:/app/logs + mongodb: + image: mongo:latest + restart: unless-stopped + environment: + MONGO_INITDB_ROOT_USERNAME: ${MONGO_USER} + MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PASS} + volumes: - ./database:/data/db diff --git a/docker-compose.yml b/docker-compose.yml index 9b08008..7cc272a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,32 +2,34 @@ services: app: depends_on: - mongodb - image: zyner/xyter:2022.07.0 + image: zyner/xyter:latest restart: unless-stopped environment: - - DISCORD_TOKEN=YOUR TOKEN - - DISCORD_CLIENT_ID=YOUR CLIENT ID - - DISCORD_GUILD_ID=YOUR GUILD ID - ### LEAVE THIS AS IT IS! ### - - MONGO_URL=mongodb://mongodb:27017/xyter?retryWrites=true&w=majority - ############################ - - ENCRYPTION_ALGORITHM=aes-256-ctr - - ENCRYPTION_SECRET=A RANDOM STRING WITH LENGTH OF 32 - - EMEBD_COLOR_SUCCESS=#22bb33 - - EMBED_COLOR_WAIT=#f0ad4e - - EMBED_COLOR_ERROR=#bb2124 - - EMBED_FOOTER_TEXT=https://github.com/ZynerOrg/xyter - - EMBED_FOOTER_ICON=https://github.com/ZynerOrg.png - - LOG_LEVEL=silly - - REPUTATION_TIMEOUT=86400 - - BOT_HOSTER_NAME=Zyner - - BOT_HOSTER_URL=https://xyter.zyner.org/customization/change-hoster + - DISCORD_TOKEN=${DISCORD_TOKEN} + - DISCORD_CLIENT_ID=${DISCORD_CLIENT_ID} + - DISCORD_GUILD_ID=${DISCORD_GUILD_ID} + - MONGO_URL=mongodb://${MONGO_USER}:${MONGO_PASS}@mongodb:27017/admin?retryWrites=true&w=majority + - ENCRYPTION_ALGORITHM=${ENCRYPTION_ALGORITHM} + - ENCRYPTION_SECRET=${ENCRYPTION_SECRET} + - EMEBD_COLOR_SUCCESS=${EMEBD_COLOR_SUCCESS} + - EMBED_COLOR_WAIT=${EMBED_COLOR_WAIT} + - EMBED_COLOR_ERROR=${EMBED_COLOR_ERROR} + - EMBED_FOOTER_TEXT=${EMBED_FOOTER_TEXT} + - EMBED_FOOTER_ICON=${EMBED_FOOTER_ICON} + - LOG_LEVEL=${LOG_LEVEL} + - REPUTATION_TIMEOUT=${REPUTATION_TIMEOUT} + - BOT_HOSTER_NAME=${BOT_HOSTER_NAME} + - BOT_HOSTER_URL=${BOT_HOSTER_URL} - NODE_ENV=production stdin_open: true tty: true - mongodb: - image: mongo:4.2.21 - restart: unless-stopped volumes: - - ./logs:/app/build/logs + - ./logs:/app/logs + mongodb: + image: mongo:latest + restart: unless-stopped + environment: + MONGO_INITDB_ROOT_USERNAME: ${MONGO_USER} + MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PASS} + volumes: - ./database:/data/db From b7dc2b6fc6ce111496d3f818aaa9bf1e9c59a1ed Mon Sep 17 00:00:00 2001 From: Joshua Schmitt Date: Wed, 6 Jul 2022 19:03:45 +0200 Subject: [PATCH 021/215] fix: :construction: done review --- .env.docker | 31 ------------------------------- .env.example | 4 ++++ 2 files changed, 4 insertions(+), 31 deletions(-) delete mode 100644 .env.docker diff --git a/.env.docker b/.env.docker deleted file mode 100644 index 98657c8..0000000 --- a/.env.docker +++ /dev/null @@ -1,31 +0,0 @@ -# RENAME THIS FILE TO .env TO USE IT WITH DOCKER! - -# Discord -DISCORD_TOKEN= -DISCORD_CLIENT_ID= -DISCORD_GUILD_ID= - -# Database -MONGO_USER= -MONGO_PASS= - -# Encryption -ENCRYPTION_ALGORITHM=aes-256-ctr -ENCRYPTION_SECRET=A RANDOM STRING WITH LENGTH OF 32 - -#Embed -EMEBD_COLOR_SUCCESS=#22bb33 -EMBED_COLOR_WAIT=#f0ad4e -EMBED_COLOR_ERROR=#bb2124 -EMBED_FOOTER_TEXT=https://github.com/ZynerOrg/xyter -EMBED_FOOTER_ICON=https://github.com/ZynerOrg.png - -# Log -LOG_LEVEL=silly - -# Reputation -REPUTATION_TIMEOUT=86400 - -# Bot Hoster -BOT_HOSTER_NAME=Zyner -BOT_HOSTER_URL=https://xyter.zyner.org/customization/change-hoster diff --git a/.env.example b/.env.example index 51665d3..dde1afc 100644 --- a/.env.example +++ b/.env.example @@ -6,7 +6,11 @@ DISCORD_CLIENT_ID="" DISCORD_GUILD_ID="" # Database +# Comment this if youre using docker-compose MONGO_URL="mongodb+srv://username:password@host/database?retryWrites=true&w=majority" +# Uncomment this if youre using docker-compose +# MONGO_USER=YOUR_DOCKER_COMPOSE_MONGO_USER +# MONGO_PASS=YOUR_DOCKER_COMPOSE_MONGO_PASSWORD # Encryption ENCRYPTION_ALGORITHM="aes-256-ctr" From 66992a75564eafa4ee1b65a9d054ce2be1e433d5 Mon Sep 17 00:00:00 2001 From: Joshua Schmitt Date: Wed, 6 Jul 2022 19:06:04 +0200 Subject: [PATCH 022/215] fix: :art: set docker-compose version --- docker-compose.dev.yml | 2 ++ docker-compose.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index fed3dc4..b88dfdc 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -1,3 +1,5 @@ +version: '3' + services: app: depends_on: diff --git a/docker-compose.yml b/docker-compose.yml index 7cc272a..ef0c445 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,3 +1,5 @@ +version: '3' + services: app: depends_on: From 7867b874bd810dfd7711c8010b7272351c052106 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 13 Jul 2022 16:21:17 +0000 Subject: [PATCH 023/215] Update dependency jest to v28.1.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 08b0c96..d3538e4 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "eslint-plugin-no-loops": "^0.3.0", "eslint-plugin-prettier": "^4.0.0", "husky": "8.0.1", - "jest": "28.1.2", + "jest": "28.1.3", "lint-staged": "13.0.3", "nodemon": "^2.0.16", "prettier": "^2.6.0" From df3ac05ac84d2f45aaedb28ab7f5007f935f1ea1 Mon Sep 17 00:00:00 2001 From: Joshua Schmitt Date: Thu, 14 Jul 2022 20:46:11 +0200 Subject: [PATCH 024/215] fix: :bug: fix env to docker-compose file --- .env.example | 4 ---- docker-compose.dev.yml | 36 ++++++++++++++++++------------------ docker-compose.yml | 36 ++++++++++++++++++------------------ 3 files changed, 36 insertions(+), 40 deletions(-) diff --git a/.env.example b/.env.example index dde1afc..51665d3 100644 --- a/.env.example +++ b/.env.example @@ -6,11 +6,7 @@ DISCORD_CLIENT_ID="" DISCORD_GUILD_ID="" # Database -# Comment this if youre using docker-compose MONGO_URL="mongodb+srv://username:password@host/database?retryWrites=true&w=majority" -# Uncomment this if youre using docker-compose -# MONGO_USER=YOUR_DOCKER_COMPOSE_MONGO_USER -# MONGO_PASS=YOUR_DOCKER_COMPOSE_MONGO_PASSWORD # Encryption ENCRYPTION_ALGORITHM="aes-256-ctr" diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index b88dfdc..ba7a2ba 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -1,4 +1,4 @@ -version: '3' +version: "3" services: app: @@ -7,21 +7,21 @@ services: build: . restart: unless-stopped environment: - - DISCORD_TOKEN=${DISCORD_TOKEN} - - DISCORD_CLIENT_ID=${DISCORD_CLIENT_ID} - - DISCORD_GUILD_ID=${DISCORD_GUILD_ID} - - MONGO_URL=mongodb://${MONGO_USER}:${MONGO_PASS}@mongodb:27017/admin?retryWrites=true&w=majority - - ENCRYPTION_ALGORITHM=${ENCRYPTION_ALGORITHM} - - ENCRYPTION_SECRET=${ENCRYPTION_SECRET} - - EMEBD_COLOR_SUCCESS=${EMEBD_COLOR_SUCCESS} - - EMBED_COLOR_WAIT=${EMBED_COLOR_WAIT} - - EMBED_COLOR_ERROR=${EMBED_COLOR_ERROR} - - EMBED_FOOTER_TEXT=${EMBED_FOOTER_TEXT} - - EMBED_FOOTER_ICON=${EMBED_FOOTER_ICON} - - LOG_LEVEL=${LOG_LEVEL} - - REPUTATION_TIMEOUT=${REPUTATION_TIMEOUT} - - BOT_HOSTER_NAME=${BOT_HOSTER_NAME} - - BOT_HOSTER_URL=${BOT_HOSTER_URL} + - DISCORD_TOKEN=DISCORD_TOKEN + - DISCORD_CLIENT_ID=DISCORD_CLIENT_ID + - DISCORD_GUILD_ID=DISCORD_GUILD_ID + - MONGO_URL=mongodb://MONGO_USER:MONGO_PASS@mongodb:27017/admin?retryWrites=true&w=majority + - ENCRYPTION_ALGORITHM=ENCRYPTION_ALGORITHM + - ENCRYPTION_SECRET=ENCRYPTION_SECRET + - EMEBD_COLOR_SUCCESS=EMEBD_COLOR_SUCCESS + - EMBED_COLOR_WAIT=EMBED_COLOR_WAIT + - EMBED_COLOR_ERROR=EMBED_COLOR_ERROR + - EMBED_FOOTER_TEXT=EMBED_FOOTER_TEXT + - EMBED_FOOTER_ICON=EMBED_FOOTER_ICON + - LOG_LEVEL=LOG_LEVEL + - REPUTATION_TIMEOUT=REPUTATION_TIMEOUT + - BOT_HOSTER_NAME=BOT_HOSTER_NAME + - BOT_HOSTER_URL=BOT_HOSTER_URL - NODE_ENV=development stdin_open: true tty: true @@ -31,7 +31,7 @@ services: image: mongo:latest restart: unless-stopped environment: - MONGO_INITDB_ROOT_USERNAME: ${MONGO_USER} - MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PASS} + MONGO_INITDB_ROOT_USERNAME: MONGO_USER + MONGO_INITDB_ROOT_PASSWORD: MONGO_PASS volumes: - ./database:/data/db diff --git a/docker-compose.yml b/docker-compose.yml index ef0c445..2d67fb5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: '3' +version: "3" services: app: @@ -7,21 +7,21 @@ services: image: zyner/xyter:latest restart: unless-stopped environment: - - DISCORD_TOKEN=${DISCORD_TOKEN} - - DISCORD_CLIENT_ID=${DISCORD_CLIENT_ID} - - DISCORD_GUILD_ID=${DISCORD_GUILD_ID} - - MONGO_URL=mongodb://${MONGO_USER}:${MONGO_PASS}@mongodb:27017/admin?retryWrites=true&w=majority - - ENCRYPTION_ALGORITHM=${ENCRYPTION_ALGORITHM} - - ENCRYPTION_SECRET=${ENCRYPTION_SECRET} - - EMEBD_COLOR_SUCCESS=${EMEBD_COLOR_SUCCESS} - - EMBED_COLOR_WAIT=${EMBED_COLOR_WAIT} - - EMBED_COLOR_ERROR=${EMBED_COLOR_ERROR} - - EMBED_FOOTER_TEXT=${EMBED_FOOTER_TEXT} - - EMBED_FOOTER_ICON=${EMBED_FOOTER_ICON} - - LOG_LEVEL=${LOG_LEVEL} - - REPUTATION_TIMEOUT=${REPUTATION_TIMEOUT} - - BOT_HOSTER_NAME=${BOT_HOSTER_NAME} - - BOT_HOSTER_URL=${BOT_HOSTER_URL} + - DISCORD_TOKEN=DISCORD_TOKEN + - DISCORD_CLIENT_ID=DISCORD_CLIENT_ID + - DISCORD_GUILD_ID=DISCORD_GUILD_ID + - MONGO_URL=mongodb://MONGO_USER:MONGO_PASS@mongodb:27017/admin?retryWrites=true&w=majority + - ENCRYPTION_ALGORITHM=ENCRYPTION_ALGORITHM + - ENCRYPTION_SECRET=ENCRYPTION_SECRET + - EMEBD_COLOR_SUCCESS=EMEBD_COLOR_SUCCESS + - EMBED_COLOR_WAIT=EMBED_COLOR_WAIT + - EMBED_COLOR_ERROR=EMBED_COLOR_ERROR + - EMBED_FOOTER_TEXT=EMBED_FOOTER_TEXT + - EMBED_FOOTER_ICON=EMBED_FOOTER_ICON + - LOG_LEVEL=LOG_LEVEL + - REPUTATION_TIMEOUT=REPUTATION_TIMEOUT + - BOT_HOSTER_NAME=BOT_HOSTER_NAME + - BOT_HOSTER_URL=BOT_HOSTER_URL - NODE_ENV=production stdin_open: true tty: true @@ -31,7 +31,7 @@ services: image: mongo:latest restart: unless-stopped environment: - MONGO_INITDB_ROOT_USERNAME: ${MONGO_USER} - MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PASS} + MONGO_INITDB_ROOT_USERNAME: MONGO_USER + MONGO_INITDB_ROOT_PASSWORD: MONGO_PASS volumes: - ./database:/data/db From 2568cc9c4eb2d6295a794a7e797ff701fd5aa9a5 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 17 Jul 2022 18:41:32 +0000 Subject: [PATCH 025/215] Update dependency @discordjs/builders to ^0.16.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 08b0c96..b1f0a32 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "email": "vermium@zyner.org" }, "dependencies": { - "@discordjs/builders": "^0.15.0", + "@discordjs/builders": "^0.16.0", "@discordjs/rest": "^0.5.0", "@types/i18next-fs-backend": "^1.1.2", "axios": "^0.27.2", From f78790890b71f6949490f0b34d8cf52abd0b557a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 17 Jul 2022 23:03:56 +0000 Subject: [PATCH 026/215] Update dependency discord.js to v14 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 08b0c96..875f5aa 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "common": "^0.2.5", "crypto": "^1.0.1", "discord-api-types": "^0.36.0", - "discord.js": "^13.6.0", + "discord.js": "^14.0.0", "i18n": "^0.15.0", "i18next": "^21.6.13", "i18next-async-backend": "^2.0.0", From cfdeed425abebef4af252b25611783ba7fa343ba Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 1 Aug 2022 07:14:54 +0000 Subject: [PATCH 027/215] Update dependency eslint to v8.21.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 08b0c96..1162664 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "@types/uuid": "^8.3.4", "@typescript-eslint/eslint-plugin": "^5.15.0", "@typescript-eslint/parser": "^5.15.0", - "eslint": "8.19.0", + "eslint": "8.21.0", "eslint-config-airbnb-base": "15.0.0", "eslint-config-prettier": "8.5.0", "eslint-plugin-import": "2.26.0", From 2b199d6fa8c4ec999eda04a68dfb596c79d5188d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 13 Aug 2022 13:51:47 +0000 Subject: [PATCH 028/215] Update dependency @discordjs/rest to ^0.6.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2a17e5a..457d28a 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ }, "dependencies": { "@discordjs/builders": "^0.16.0", - "@discordjs/rest": "^0.5.0", + "@discordjs/rest": "^0.6.0", "@types/i18next-fs-backend": "^1.1.2", "axios": "^0.27.2", "chance": "^1.1.8", From b92e6571ef0a3993a718f598b0633f40a404c42b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 13 Aug 2022 13:52:23 +0000 Subject: [PATCH 029/215] Update dependency discord-api-types to ^0.37.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f59418a..61916ae 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "chance": "^1.1.8", "common": "^0.2.5", "crypto": "^1.0.1", - "discord-api-types": "^0.36.0", + "discord-api-types": "^0.37.0", "discord.js": "^14.0.0", "i18n": "^0.15.0", "i18next": "^21.6.13", From f718ed6bdb8364284a4e6b63d6b6a07bebf2598c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 13 Aug 2022 13:52:50 +0000 Subject: [PATCH 030/215] Update dependency @discordjs/builders to v1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3ca460b..a75e880 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "email": "vermium@zyner.org" }, "dependencies": { - "@discordjs/builders": "^0.16.0", + "@discordjs/builders": "^1.0.0", "@discordjs/rest": "^0.6.0", "@types/i18next-fs-backend": "^1.1.2", "axios": "^0.27.2", From 7843d8a36643e905a0522367f0afe80ab2051a7e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 13 Aug 2022 13:53:34 +0000 Subject: [PATCH 031/215] Update dependency @discordjs/rest to v1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a75e880..5277dde 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ }, "dependencies": { "@discordjs/builders": "^1.0.0", - "@discordjs/rest": "^0.6.0", + "@discordjs/rest": "^1.0.0", "@types/i18next-fs-backend": "^1.1.2", "axios": "^0.27.2", "chance": "^1.1.8", From ee88f579e63a1be0653067a75771c9a39d443a69 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 14 Aug 2022 02:58:22 +0000 Subject: [PATCH 032/215] Update dependency eslint to v8.22.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1d3965b..b6d68af 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "@types/uuid": "^8.3.4", "@typescript-eslint/eslint-plugin": "^5.15.0", "@typescript-eslint/parser": "^5.15.0", - "eslint": "8.21.0", + "eslint": "8.22.0", "eslint-config-airbnb-base": "15.0.0", "eslint-config-prettier": "8.5.0", "eslint-plugin-import": "2.26.0", From bfecdaa289744efdae7e61576c841fd0bc8085ac Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 24 Aug 2022 13:29:13 +0000 Subject: [PATCH 033/215] Pin dependencies --- package.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index a27411e..4c68bd2 100644 --- a/package.json +++ b/package.json @@ -55,22 +55,22 @@ "winston-daily-rotate-file": "^4.6.1" }, "devDependencies": { - "@types/chance": "^1.1.3", + "@types/chance": "1.1.3", "@types/node-schedule": "2.1.0", - "@types/uuid": "^8.3.4", - "@typescript-eslint/eslint-plugin": "^5.15.0", - "@typescript-eslint/parser": "^5.15.0", + "@types/uuid": "8.3.4", + "@typescript-eslint/eslint-plugin": "5.34.0", + "@typescript-eslint/parser": "5.34.0", "eslint": "8.22.0", "eslint-config-airbnb-base": "15.0.0", "eslint-config-prettier": "8.5.0", "eslint-plugin-import": "2.26.0", - "eslint-plugin-no-loops": "^0.3.0", - "eslint-plugin-prettier": "^4.0.0", + "eslint-plugin-no-loops": "0.3.0", + "eslint-plugin-prettier": "4.2.1", "husky": "8.0.1", "jest": "28.1.3", "lint-staged": "13.0.3", - "nodemon": "^2.0.16", - "prettier": "^2.6.0" + "nodemon": "2.0.19", + "prettier": "2.7.1" }, "lint-staged": { "*.ts": "eslint --cache --fix" From 11308872e3dda686cdcc19660acc3ef21586be7b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 24 Aug 2022 13:29:17 +0000 Subject: [PATCH 034/215] Update Node.js to v18 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index a626b7a..ed75827 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:16 +FROM node:18 LABEL maintainer="xyter@zyner.org" From 3ad43d28d0a8f3c5a73c42922dbf44439815a413 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 24 Aug 2022 15:32:56 +0200 Subject: [PATCH 035/215] =?UTF-8?q?=F0=9F=94=A7=20remove=20awful=20looking?= =?UTF-8?q?=20font=20from=20settings.json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 1 - 1 file changed, 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index edd979a..b38ac9d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,7 +4,6 @@ "editor.cursorBlinking": "phase", "editor.cursorSmoothCaretAnimation": true, "editor.defaultFormatter": "esbenp.prettier-vscode", - "editor.fontFamily": "Cascadia Code", "editor.fontLigatures": true, "editor.formatOnSave": true, "editor.guides.bracketPairs": "active", From de0d416a0dae573e25e475c3a587ad32f3762a0b Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 24 Aug 2022 15:33:47 +0200 Subject: [PATCH 036/215] =?UTF-8?q?=F0=9F=94=A7=20added=20Vtrois.gitmoji-v?= =?UTF-8?q?scode=20to=20recommended=20extensions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/extensions.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index a17e74d..65197a8 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -45,7 +45,8 @@ "sonarsource.sonarlint-vscode", "nicoespeon.hocus-pocus", "aaron-bond.better-comments", - "oouo-diogo-perdigao.docthis" + "oouo-diogo-perdigao.docthis", + "Vtrois.gitmoji-vscode" ], // List of extensions recommended by VS Code that should not be recommended for users of this workspace. "unwantedRecommendations": [] From e3c05c8a21599211c42540cc5ce352d240f6dfac Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 24 Aug 2022 15:39:22 +0200 Subject: [PATCH 037/215] =?UTF-8?q?=F0=9F=9A=9A=20move=20logger=20to=20mid?= =?UTF-8?q?dlewares?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/handlers/deployCommands/index.ts | 2 +- src/handlers/devMode/index.ts | 2 +- src/helpers/cooldown/index.ts | 2 +- src/helpers/dropGuild/index.ts | 2 +- src/helpers/dropUser/index.ts | 2 +- src/helpers/fetchGuild/index.ts | 2 +- src/helpers/fetchUser/index.ts | 2 +- src/helpers/pluralize/index.ts | 2 +- src/helpers/updatePresence/index.ts | 2 +- src/jobs/shop/modules/roles/components/dueForPayment.ts | 2 +- src/jobs/shop/modules/roles/components/overDueForPayment.ts | 2 +- src/jobs/timeouts/index.ts | 2 +- src/managers/command/index.ts | 2 +- src/managers/event/index.ts | 2 +- src/managers/schedule/index.ts | 2 +- src/{ => middlewares}/logger/index.ts | 0 src/plugins/buttons/primary/index.ts | 2 +- src/plugins/commands/config/modules/audits/index.ts | 2 +- src/plugins/commands/config/modules/cpgg/index.ts | 2 +- src/plugins/commands/config/modules/credits/index.ts | 2 +- src/plugins/commands/config/modules/embeds/index.ts | 2 +- src/plugins/commands/config/modules/points/index.ts | 2 +- src/plugins/commands/config/modules/shop/index.ts | 2 +- src/plugins/commands/config/modules/welcome/index.ts | 2 +- src/plugins/commands/credits/index.ts | 2 +- src/plugins/commands/credits/modules/balance/index.ts | 2 +- src/plugins/commands/credits/modules/gift/index.ts | 2 +- src/plugins/commands/credits/modules/top/index.ts | 2 +- src/plugins/commands/credits/modules/work/index.ts | 2 +- src/plugins/commands/fun/index.ts | 2 +- src/plugins/commands/manage/modules/counters/index.ts | 2 +- .../commands/manage/modules/counters/modules/add/index.ts | 2 +- .../commands/manage/modules/counters/modules/remove/index.ts | 2 +- .../commands/manage/modules/credits/modules/give/index.ts | 2 +- .../commands/manage/modules/credits/modules/set/index.ts | 2 +- .../commands/manage/modules/credits/modules/take/index.ts | 2 +- .../commands/manage/modules/credits/modules/transfer/index.ts | 2 +- src/plugins/commands/profile/index.ts | 2 +- src/plugins/commands/profile/modules/view/index.ts | 2 +- src/plugins/commands/reputation/modules/give/index.ts | 2 +- src/plugins/commands/shop/index.ts | 2 +- src/plugins/commands/shop/modules/cpgg/index.ts | 2 +- src/plugins/commands/shop/modules/roles/index.ts | 2 +- src/plugins/commands/shop/modules/roles/modules/buy/index.ts | 2 +- src/plugins/commands/shop/modules/roles/modules/cancel/index.ts | 2 +- src/plugins/events/guildCreate/index.ts | 2 +- src/plugins/events/guildDelete/index.ts | 2 +- src/plugins/events/guildMemberAdd/audits.ts | 2 +- src/plugins/events/guildMemberAdd/index.ts | 2 +- src/plugins/events/guildMemberRemove/audits.ts | 2 +- src/plugins/events/guildMemberRemove/index.ts | 2 +- src/plugins/events/interactionCreate/audits.ts | 2 +- src/plugins/events/interactionCreate/index.ts | 2 +- src/plugins/events/messageCreate/modules/counters/index.ts | 2 +- src/plugins/events/messageCreate/modules/credits/index.ts | 2 +- src/plugins/events/messageCreate/modules/points/index.ts | 2 +- src/plugins/events/messageDelete/audits.ts | 2 +- src/plugins/events/messageDelete/modules/counter.ts | 2 +- src/plugins/events/messageUpdate/audits.ts | 2 +- src/plugins/events/messageUpdate/index.ts | 2 +- src/plugins/events/messageUpdate/modules/counter.ts | 2 +- src/plugins/events/rateLimit/index.ts | 2 +- src/plugins/events/ready/index.ts | 2 +- 63 files changed, 62 insertions(+), 62 deletions(-) rename src/{ => middlewares}/logger/index.ts (100%) diff --git a/src/handlers/deployCommands/index.ts b/src/handlers/deployCommands/index.ts index 9491db5..e7662e3 100644 --- a/src/handlers/deployCommands/index.ts +++ b/src/handlers/deployCommands/index.ts @@ -1,4 +1,4 @@ -import logger from "../../logger"; +import logger from "../../middlewares/logger"; import { Client } from "discord.js"; import { REST } from "@discordjs/rest"; import { Routes } from "discord-api-types/v9"; diff --git a/src/handlers/devMode/index.ts b/src/handlers/devMode/index.ts index ba36b50..6757156 100644 --- a/src/handlers/devMode/index.ts +++ b/src/handlers/devMode/index.ts @@ -1,5 +1,5 @@ import { Client } from "discord.js"; -import logger from "../../logger"; +import logger from "../../middlewares/logger"; export default async (client: Client) => { if (process.env.NODE_ENV !== "production") { diff --git a/src/helpers/cooldown/index.ts b/src/helpers/cooldown/index.ts index f574f57..42b40ab 100644 --- a/src/helpers/cooldown/index.ts +++ b/src/helpers/cooldown/index.ts @@ -1,7 +1,7 @@ // Dependencies import { CommandInteraction, ButtonInteraction, Message } from "discord.js"; -import logger from "../../logger"; +import logger from "../../middlewares/logger"; import timeoutSchema from "../../models/timeout"; import addSeconds from "../../helpers/addSeconds"; diff --git a/src/helpers/dropGuild/index.ts b/src/helpers/dropGuild/index.ts index 0c0e2ab..d07c62c 100644 --- a/src/helpers/dropGuild/index.ts +++ b/src/helpers/dropGuild/index.ts @@ -5,7 +5,7 @@ import counterSchema from "../../models/counter"; import shopRoleSchema from "../../models/shopRole"; import timeoutSchema from "../../models/timeout"; -import logger from "../../logger"; +import logger from "../../middlewares/logger"; import { Guild } from "discord.js"; diff --git a/src/helpers/dropUser/index.ts b/src/helpers/dropUser/index.ts index 3093048..035661a 100644 --- a/src/helpers/dropUser/index.ts +++ b/src/helpers/dropUser/index.ts @@ -1,6 +1,6 @@ import userSchema from "../../models/user"; -import logger from "../../logger"; +import logger from "../../middlewares/logger"; import { Guild, User } from "discord.js"; diff --git a/src/helpers/fetchGuild/index.ts b/src/helpers/fetchGuild/index.ts index a89e840..a5c1dd4 100644 --- a/src/helpers/fetchGuild/index.ts +++ b/src/helpers/fetchGuild/index.ts @@ -5,7 +5,7 @@ import { Guild } from "discord.js"; import guildSchema from "../../models/guild"; // Handlers -import logger from "../../logger"; +import logger from "../../middlewares/logger"; // Function export default async (guild: Guild) => { diff --git a/src/helpers/fetchUser/index.ts b/src/helpers/fetchUser/index.ts index 3837f24..acd3b02 100644 --- a/src/helpers/fetchUser/index.ts +++ b/src/helpers/fetchUser/index.ts @@ -5,7 +5,7 @@ import { Guild, User } from "discord.js"; import userSchema from "../../models/user"; // Handlers -import logger from "../../logger"; +import logger from "../../middlewares/logger"; // Function export default async (user: User, guild: Guild) => { diff --git a/src/helpers/pluralize/index.ts b/src/helpers/pluralize/index.ts index d6e266d..10a6796 100644 --- a/src/helpers/pluralize/index.ts +++ b/src/helpers/pluralize/index.ts @@ -1,4 +1,4 @@ -import logger from "../../logger"; +import logger from "../../middlewares/logger"; export default (count: number, noun: string, suffix?: string): string => { const result = `${count} ${noun}${count !== 1 ? suffix || "s" : ""}`; diff --git a/src/helpers/updatePresence/index.ts b/src/helpers/updatePresence/index.ts index 334a3e2..2b25c37 100644 --- a/src/helpers/updatePresence/index.ts +++ b/src/helpers/updatePresence/index.ts @@ -1,6 +1,6 @@ // Dependencies import { Client } from "discord.js"; -import logger from "../../logger"; +import logger from "../../middlewares/logger"; // Function export default async (client: Client) => { diff --git a/src/jobs/shop/modules/roles/components/dueForPayment.ts b/src/jobs/shop/modules/roles/components/dueForPayment.ts index ad8a59c..f2b487d 100644 --- a/src/jobs/shop/modules/roles/components/dueForPayment.ts +++ b/src/jobs/shop/modules/roles/components/dueForPayment.ts @@ -1,5 +1,5 @@ import { Client } from "discord.js"; -import logger from "../../../../../logger"; +import logger from "../../../../../middlewares/logger"; import { IShopRole } from "../../../../../interfaces/ShopRole"; diff --git a/src/jobs/shop/modules/roles/components/overDueForPayment.ts b/src/jobs/shop/modules/roles/components/overDueForPayment.ts index 77ab6e0..e33b810 100644 --- a/src/jobs/shop/modules/roles/components/overDueForPayment.ts +++ b/src/jobs/shop/modules/roles/components/overDueForPayment.ts @@ -1,5 +1,5 @@ import { Client } from "discord.js"; -import logger from "../../../../../logger"; +import logger from "../../../../../middlewares/logger"; import { IShopRole } from "../../../../../interfaces/ShopRole"; import guildSchema from "../../../../../models/guild"; diff --git a/src/jobs/timeouts/index.ts b/src/jobs/timeouts/index.ts index ce18f09..9684a7c 100644 --- a/src/jobs/timeouts/index.ts +++ b/src/jobs/timeouts/index.ts @@ -1,4 +1,4 @@ -import logger from "../../logger"; +import logger from "../../middlewares/logger"; import timeoutSchema from "../../models/timeout"; diff --git a/src/managers/command/index.ts b/src/managers/command/index.ts index 508aea6..71306a6 100644 --- a/src/managers/command/index.ts +++ b/src/managers/command/index.ts @@ -1,6 +1,6 @@ import { Collection, Client } from "discord.js"; import listDir from "../../helpers/listDir"; -import logger from "../../logger"; +import logger from "../../middlewares/logger"; import { ICommand } from "../../interfaces/Command"; diff --git a/src/managers/event/index.ts b/src/managers/event/index.ts index 41f5484..9a58e18 100644 --- a/src/managers/event/index.ts +++ b/src/managers/event/index.ts @@ -2,7 +2,7 @@ import { Client } from "discord.js"; import listDir from "../../helpers/listDir"; import { IEvent } from "../../interfaces/Event"; -import logger from "../../logger"; +import logger from "../../middlewares/logger"; export const register = async (client: Client) => { const eventNames = await listDir("plugins/events"); diff --git a/src/managers/schedule/index.ts b/src/managers/schedule/index.ts index 753d099..18bf6ee 100644 --- a/src/managers/schedule/index.ts +++ b/src/managers/schedule/index.ts @@ -1,4 +1,4 @@ -import logger from "../../logger"; +import logger from "../../middlewares/logger"; import { Client } from "discord.js"; import { IJob } from "../../interfaces/Job"; diff --git a/src/logger/index.ts b/src/middlewares/logger/index.ts similarity index 100% rename from src/logger/index.ts rename to src/middlewares/logger/index.ts diff --git a/src/plugins/buttons/primary/index.ts b/src/plugins/buttons/primary/index.ts index 83162a6..c889d64 100644 --- a/src/plugins/buttons/primary/index.ts +++ b/src/plugins/buttons/primary/index.ts @@ -1,5 +1,5 @@ import { ButtonInteraction } from "discord.js"; -import logger from "../../../logger"; +import logger from "../../../middlewares/logger"; export const metadata = { guildOnly: false, ephemeral: false }; diff --git a/src/plugins/commands/config/modules/audits/index.ts b/src/plugins/commands/config/modules/audits/index.ts index f090b45..7c9c313 100644 --- a/src/plugins/commands/config/modules/audits/index.ts +++ b/src/plugins/commands/config/modules/audits/index.ts @@ -2,7 +2,7 @@ import { CommandInteraction, Permissions } from "discord.js"; import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; -import logger from "../../../../../logger"; +import logger from "../../../../../middlewares/logger"; import guildSchema from "../../../../../models/guild"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; diff --git a/src/plugins/commands/config/modules/cpgg/index.ts b/src/plugins/commands/config/modules/cpgg/index.ts index 4ba34e0..e7568ff 100644 --- a/src/plugins/commands/config/modules/cpgg/index.ts +++ b/src/plugins/commands/config/modules/cpgg/index.ts @@ -2,7 +2,7 @@ import { CommandInteraction, Permissions } from "discord.js"; import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; -import logger from "../../../../../logger"; +import logger from "../../../../../middlewares/logger"; import apiSchema from "../../../../../models/api"; import encryption from "../../../../../handlers/encryption"; diff --git a/src/plugins/commands/config/modules/credits/index.ts b/src/plugins/commands/config/modules/credits/index.ts index f8b344f..22924c1 100644 --- a/src/plugins/commands/config/modules/credits/index.ts +++ b/src/plugins/commands/config/modules/credits/index.ts @@ -2,7 +2,7 @@ import { CommandInteraction, Permissions } from "discord.js"; import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; -import logger from "../../../../../logger"; +import logger from "../../../../../middlewares/logger"; import guildSchema from "../../../../../models/guild"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; diff --git a/src/plugins/commands/config/modules/embeds/index.ts b/src/plugins/commands/config/modules/embeds/index.ts index db8bef0..e36b125 100644 --- a/src/plugins/commands/config/modules/embeds/index.ts +++ b/src/plugins/commands/config/modules/embeds/index.ts @@ -5,7 +5,7 @@ import { Permissions, } from "discord.js"; -import logger from "../../../../../logger"; +import logger from "../../../../../middlewares/logger"; import guildSchema from "../../../../../models/guild"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; diff --git a/src/plugins/commands/config/modules/points/index.ts b/src/plugins/commands/config/modules/points/index.ts index 8813cf6..f782f00 100644 --- a/src/plugins/commands/config/modules/points/index.ts +++ b/src/plugins/commands/config/modules/points/index.ts @@ -2,7 +2,7 @@ import { CommandInteraction, Permissions } from "discord.js"; import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; -import logger from "../../../../../logger"; +import logger from "../../../../../middlewares/logger"; import guildSchema from "../../../../../models/guild"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; diff --git a/src/plugins/commands/config/modules/shop/index.ts b/src/plugins/commands/config/modules/shop/index.ts index 328b169..b346d72 100644 --- a/src/plugins/commands/config/modules/shop/index.ts +++ b/src/plugins/commands/config/modules/shop/index.ts @@ -2,7 +2,7 @@ import { CommandInteraction, Permissions } from "discord.js"; import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; -import logger from "../../../../../logger"; +import logger from "../../../../../middlewares/logger"; import guildSchema from "../../../../../models/guild"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; diff --git a/src/plugins/commands/config/modules/welcome/index.ts b/src/plugins/commands/config/modules/welcome/index.ts index f77dd4e..fd0cb84 100644 --- a/src/plugins/commands/config/modules/welcome/index.ts +++ b/src/plugins/commands/config/modules/welcome/index.ts @@ -2,7 +2,7 @@ import { CommandInteraction, Permissions } from "discord.js"; import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; -import logger from "../../../../../logger"; +import logger from "../../../../../middlewares/logger"; import guildSchema from "../../../../../models/guild"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; diff --git a/src/plugins/commands/credits/index.ts b/src/plugins/commands/credits/index.ts index 9d1a3b4..6af41f7 100644 --- a/src/plugins/commands/credits/index.ts +++ b/src/plugins/commands/credits/index.ts @@ -1,6 +1,6 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { CommandInteraction } from "discord.js"; -import logger from "../../../logger"; +import logger from "../../../middlewares/logger"; import modules from "./modules"; diff --git a/src/plugins/commands/credits/modules/balance/index.ts b/src/plugins/commands/credits/modules/balance/index.ts index 0e646c2..40e3668 100644 --- a/src/plugins/commands/credits/modules/balance/index.ts +++ b/src/plugins/commands/credits/modules/balance/index.ts @@ -2,7 +2,7 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; import { CommandInteraction, MessageEmbed } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import logger from "../../../../../logger"; +import logger from "../../../../../middlewares/logger"; import fetchUser from "../../../../../helpers/fetchUser"; diff --git a/src/plugins/commands/credits/modules/gift/index.ts b/src/plugins/commands/credits/modules/gift/index.ts index 84b2350..c1bb320 100644 --- a/src/plugins/commands/credits/modules/gift/index.ts +++ b/src/plugins/commands/credits/modules/gift/index.ts @@ -5,7 +5,7 @@ import { CommandInteraction, MessageEmbed } from "discord.js"; import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; // Handlers -import logger from "../../../../../logger"; +import logger from "../../../../../middlewares/logger"; import mongoose from "mongoose"; diff --git a/src/plugins/commands/credits/modules/top/index.ts b/src/plugins/commands/credits/modules/top/index.ts index 54478aa..1fb6019 100644 --- a/src/plugins/commands/credits/modules/top/index.ts +++ b/src/plugins/commands/credits/modules/top/index.ts @@ -2,7 +2,7 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; import { CommandInteraction, MessageEmbed } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import logger from "../../../../../logger"; +import logger from "../../../../../middlewares/logger"; import userSchema, { IUser } from "../../../../../models/user"; diff --git a/src/plugins/commands/credits/modules/work/index.ts b/src/plugins/commands/credits/modules/work/index.ts index ef0a550..156b49c 100644 --- a/src/plugins/commands/credits/modules/work/index.ts +++ b/src/plugins/commands/credits/modules/work/index.ts @@ -7,7 +7,7 @@ import Chance from "chance"; import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; // Handlers -import logger from "../../../../../logger"; +import logger from "../../../../../middlewares/logger"; // Models import * as cooldown from "../../../../../helpers/cooldown"; diff --git a/src/plugins/commands/fun/index.ts b/src/plugins/commands/fun/index.ts index e0337a6..3c546ed 100644 --- a/src/plugins/commands/fun/index.ts +++ b/src/plugins/commands/fun/index.ts @@ -1,6 +1,6 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { CommandInteraction } from "discord.js"; -import logger from "../../../logger"; +import logger from "../../../middlewares/logger"; import modules from "../../commands/fun/modules"; diff --git a/src/plugins/commands/manage/modules/counters/index.ts b/src/plugins/commands/manage/modules/counters/index.ts index dbafa9f..d8b3c52 100644 --- a/src/plugins/commands/manage/modules/counters/index.ts +++ b/src/plugins/commands/manage/modules/counters/index.ts @@ -2,7 +2,7 @@ import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders"; import { CommandInteraction } from "discord.js"; -import logger from "../../../../../logger"; +import logger from "../../../../../middlewares/logger"; // Modules import modules from "./modules"; diff --git a/src/plugins/commands/manage/modules/counters/modules/add/index.ts b/src/plugins/commands/manage/modules/counters/modules/add/index.ts index d00a319..3c73f75 100644 --- a/src/plugins/commands/manage/modules/counters/modules/add/index.ts +++ b/src/plugins/commands/manage/modules/counters/modules/add/index.ts @@ -6,7 +6,7 @@ import { ChannelType } from "discord-api-types/v10"; // Configurations import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; -import logger from "../../../../../../../logger"; +import logger from "../../../../../../../middlewares/logger"; // Models import counterSchema from "../../../../../../../models/counter"; diff --git a/src/plugins/commands/manage/modules/counters/modules/remove/index.ts b/src/plugins/commands/manage/modules/counters/modules/remove/index.ts index 563829b..07f374f 100644 --- a/src/plugins/commands/manage/modules/counters/modules/remove/index.ts +++ b/src/plugins/commands/manage/modules/counters/modules/remove/index.ts @@ -5,7 +5,7 @@ import { CommandInteraction, MessageEmbed, Permissions } from "discord.js"; import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; // Handlers -import logger from "../../../../../../../logger"; +import logger from "../../../../../../../middlewares/logger"; // Models import counterSchema from "../../../../../../../models/counter"; diff --git a/src/plugins/commands/manage/modules/credits/modules/give/index.ts b/src/plugins/commands/manage/modules/credits/modules/give/index.ts index 9615f73..e6a83f0 100644 --- a/src/plugins/commands/manage/modules/credits/modules/give/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/give/index.ts @@ -6,7 +6,7 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; // Handlers -import logger from "../../../../../../../logger"; +import logger from "../../../../../../../middlewares/logger"; // Helpers import pluralize from "../../../../../../../helpers/pluralize"; diff --git a/src/plugins/commands/manage/modules/credits/modules/set/index.ts b/src/plugins/commands/manage/modules/credits/modules/set/index.ts index a3be389..6ca7e8b 100644 --- a/src/plugins/commands/manage/modules/credits/modules/set/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/set/index.ts @@ -5,7 +5,7 @@ import { CommandInteraction, MessageEmbed, Permissions } from "discord.js"; import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; // Handlers -import logger from "../../../../../../../logger"; +import logger from "../../../../../../../middlewares/logger"; // Helpers diff --git a/src/plugins/commands/manage/modules/credits/modules/take/index.ts b/src/plugins/commands/manage/modules/credits/modules/take/index.ts index fd3076b..b977b73 100644 --- a/src/plugins/commands/manage/modules/credits/modules/take/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/take/index.ts @@ -5,7 +5,7 @@ import { CommandInteraction, MessageEmbed, Permissions } from "discord.js"; import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; // Handlers -import logger from "../../../../../../../logger"; +import logger from "../../../../../../../middlewares/logger"; // Helpers import pluralize from "../../../../../../../helpers/pluralize"; diff --git a/src/plugins/commands/manage/modules/credits/modules/transfer/index.ts b/src/plugins/commands/manage/modules/credits/modules/transfer/index.ts index dca0091..74cf0d6 100644 --- a/src/plugins/commands/manage/modules/credits/modules/transfer/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/transfer/index.ts @@ -7,7 +7,7 @@ import mongoose from "mongoose"; import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; // Handlers -import logger from "../../../../../../../logger"; +import logger from "../../../../../../../middlewares/logger"; // Models import fetchUser from "../../../../../../../helpers/fetchUser"; diff --git a/src/plugins/commands/profile/index.ts b/src/plugins/commands/profile/index.ts index 68cdc73..eeec469 100644 --- a/src/plugins/commands/profile/index.ts +++ b/src/plugins/commands/profile/index.ts @@ -6,7 +6,7 @@ import { CommandInteraction } from "discord.js"; import modules from "../../commands/profile/modules"; // Handlers -import logger from "../../../logger"; +import logger from "../../../middlewares/logger"; export const moduleData = modules; diff --git a/src/plugins/commands/profile/modules/view/index.ts b/src/plugins/commands/profile/modules/view/index.ts index 4fbd5c6..bee47bc 100644 --- a/src/plugins/commands/profile/modules/view/index.ts +++ b/src/plugins/commands/profile/modules/view/index.ts @@ -7,7 +7,7 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; // Models import fetchUser from "../../../../../helpers/fetchUser"; -import logger from "../../../../../logger"; +import logger from "../../../../../middlewares/logger"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Function diff --git a/src/plugins/commands/reputation/modules/give/index.ts b/src/plugins/commands/reputation/modules/give/index.ts index 5416ee1..1eb8c0b 100644 --- a/src/plugins/commands/reputation/modules/give/index.ts +++ b/src/plugins/commands/reputation/modules/give/index.ts @@ -1,6 +1,6 @@ import { CommandInteraction } from "discord.js"; import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; -import logger from "../../../../../logger"; +import logger from "../../../../../middlewares/logger"; import fetchUser from "../../../../../helpers/fetchUser"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import * as cooldown from "../../../../../helpers/cooldown"; diff --git a/src/plugins/commands/shop/index.ts b/src/plugins/commands/shop/index.ts index 697c94e..20fa7dd 100644 --- a/src/plugins/commands/shop/index.ts +++ b/src/plugins/commands/shop/index.ts @@ -6,7 +6,7 @@ import { CommandInteraction } from "discord.js"; import modules from "./modules"; // Handlers -import logger from "../../../logger"; +import logger from "../../../middlewares/logger"; export const moduleData = modules; diff --git a/src/plugins/commands/shop/modules/cpgg/index.ts b/src/plugins/commands/shop/modules/cpgg/index.ts index 365753f..38d67b6 100644 --- a/src/plugins/commands/shop/modules/cpgg/index.ts +++ b/src/plugins/commands/shop/modules/cpgg/index.ts @@ -8,7 +8,7 @@ import axios from "axios"; import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; -import logger from "../../../../../logger"; +import logger from "../../../../../middlewares/logger"; import encryption from "../../../../../handlers/encryption"; import pluralize from "../../../../../helpers/pluralize"; diff --git a/src/plugins/commands/shop/modules/roles/index.ts b/src/plugins/commands/shop/modules/roles/index.ts index f16a962..ed0c190 100644 --- a/src/plugins/commands/shop/modules/roles/index.ts +++ b/src/plugins/commands/shop/modules/roles/index.ts @@ -3,7 +3,7 @@ import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders"; import { CommandInteraction } from "discord.js"; // Handlers -import logger from "../../../../../logger"; +import logger from "../../../../../middlewares/logger"; import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; diff --git a/src/plugins/commands/shop/modules/roles/modules/buy/index.ts b/src/plugins/commands/shop/modules/roles/modules/buy/index.ts index 23f91dc..e9197f8 100644 --- a/src/plugins/commands/shop/modules/roles/modules/buy/index.ts +++ b/src/plugins/commands/shop/modules/roles/modules/buy/index.ts @@ -12,7 +12,7 @@ import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; import shopRolesSchema from "../../../../../../../models/shopRole"; import guildSchema from "../../../../../../../models/guild"; -import logger from "../../../../../../../logger"; +import logger from "../../../../../../../middlewares/logger"; // Helpers import pluralize from "../../../../../../../helpers/pluralize"; diff --git a/src/plugins/commands/shop/modules/roles/modules/cancel/index.ts b/src/plugins/commands/shop/modules/roles/modules/cancel/index.ts index 5ff483e..e983dd3 100644 --- a/src/plugins/commands/shop/modules/roles/modules/cancel/index.ts +++ b/src/plugins/commands/shop/modules/roles/modules/cancel/index.ts @@ -7,7 +7,7 @@ import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; // Models import shopRolesSchema from "../../../../../../../models/shopRole"; -import logger from "../../../../../../../logger"; +import logger from "../../../../../../../middlewares/logger"; // Helpers import pluralize from "../../../../../../../helpers/pluralize"; diff --git a/src/plugins/events/guildCreate/index.ts b/src/plugins/events/guildCreate/index.ts index 60d5a3c..918ac59 100644 --- a/src/plugins/events/guildCreate/index.ts +++ b/src/plugins/events/guildCreate/index.ts @@ -1,7 +1,7 @@ import { Guild } from "discord.js"; import updatePresence from "../../../helpers/updatePresence"; import fetchGuild from "../../../helpers/fetchGuild"; -import logger from "../../../logger"; +import logger from "../../../middlewares/logger"; import { IEventOptions } from "../../../interfaces/EventOptions"; export const options: IEventOptions = { diff --git a/src/plugins/events/guildDelete/index.ts b/src/plugins/events/guildDelete/index.ts index 146351f..7c15b30 100644 --- a/src/plugins/events/guildDelete/index.ts +++ b/src/plugins/events/guildDelete/index.ts @@ -4,7 +4,7 @@ import { Guild } from "discord.js"; // Dependencies import updatePresence from "../../../helpers/updatePresence"; import dropGuild from "../../../helpers/dropGuild"; -import logger from "../../../logger"; +import logger from "../../../middlewares/logger"; import { IEventOptions } from "../../../interfaces/EventOptions"; export const options: IEventOptions = { diff --git a/src/plugins/events/guildMemberAdd/audits.ts b/src/plugins/events/guildMemberAdd/audits.ts index 9f94282..0194c53 100644 --- a/src/plugins/events/guildMemberAdd/audits.ts +++ b/src/plugins/events/guildMemberAdd/audits.ts @@ -1,4 +1,4 @@ -import logger from "../../../logger"; +import logger from "../../../middlewares/logger"; import { GuildMember, MessageEmbed } from "discord.js"; import guildSchema from "../../../models/guild"; diff --git a/src/plugins/events/guildMemberAdd/index.ts b/src/plugins/events/guildMemberAdd/index.ts index 8310579..ec349c4 100644 --- a/src/plugins/events/guildMemberAdd/index.ts +++ b/src/plugins/events/guildMemberAdd/index.ts @@ -4,7 +4,7 @@ import { GuildMember } from "discord.js"; // Dependencies import updatePresence from "../../../helpers/updatePresence"; import fetchUser from "../../../helpers/fetchUser"; -import logger from "../../../logger"; +import logger from "../../../middlewares/logger"; import joinMessage from "./joinMessage"; import audits from "./audits"; diff --git a/src/plugins/events/guildMemberRemove/audits.ts b/src/plugins/events/guildMemberRemove/audits.ts index 5ce4849..ee2a33c 100644 --- a/src/plugins/events/guildMemberRemove/audits.ts +++ b/src/plugins/events/guildMemberRemove/audits.ts @@ -1,4 +1,4 @@ -import logger from "../../../logger"; +import logger from "../../../middlewares/logger"; import { GuildMember, MessageEmbed } from "discord.js"; import guildSchema from "../../../models/guild"; diff --git a/src/plugins/events/guildMemberRemove/index.ts b/src/plugins/events/guildMemberRemove/index.ts index b900a12..3ac50e6 100644 --- a/src/plugins/events/guildMemberRemove/index.ts +++ b/src/plugins/events/guildMemberRemove/index.ts @@ -4,7 +4,7 @@ import { GuildMember } from "discord.js"; // Dependencies import updatePresence from "../../../helpers/updatePresence"; import dropUser from "../../../helpers/dropUser"; -import logger from "../../../logger"; +import logger from "../../../middlewares/logger"; import leaveMessage from "./leaveMessage"; import audits from "./audits"; import { IEventOptions } from "../../../interfaces/EventOptions"; diff --git a/src/plugins/events/interactionCreate/audits.ts b/src/plugins/events/interactionCreate/audits.ts index 183ff5a..dec6aeb 100644 --- a/src/plugins/events/interactionCreate/audits.ts +++ b/src/plugins/events/interactionCreate/audits.ts @@ -1,4 +1,4 @@ -import logger from "../../../logger"; +import logger from "../../../middlewares/logger"; import { Interaction, MessageEmbed, TextChannel } from "discord.js"; import guildSchema from "../../../models/guild"; diff --git a/src/plugins/events/interactionCreate/index.ts b/src/plugins/events/interactionCreate/index.ts index aa6e763..feb030e 100644 --- a/src/plugins/events/interactionCreate/index.ts +++ b/src/plugins/events/interactionCreate/index.ts @@ -4,7 +4,7 @@ import { CommandInteraction, MessageEmbed } from "discord.js"; // Dependencies import * as handlers from "./handlers"; -import logger from "../../../logger"; +import logger from "../../../middlewares/logger"; import audits from "./audits"; import { IEventOptions } from "../../../interfaces/EventOptions"; import capitalizeFirstLetter from "../../../helpers/capitalizeFirstLetter"; diff --git a/src/plugins/events/messageCreate/modules/counters/index.ts b/src/plugins/events/messageCreate/modules/counters/index.ts index 1a3c7a3..6ff4af4 100644 --- a/src/plugins/events/messageCreate/modules/counters/index.ts +++ b/src/plugins/events/messageCreate/modules/counters/index.ts @@ -1,6 +1,6 @@ import { Message } from "discord.js"; -import logger from "../../../../../logger"; +import logger from "../../../../../middlewares/logger"; import counterSchema from "../../../../../models/counter"; export default { diff --git a/src/plugins/events/messageCreate/modules/credits/index.ts b/src/plugins/events/messageCreate/modules/credits/index.ts index 24a5ce2..711afa6 100644 --- a/src/plugins/events/messageCreate/modules/credits/index.ts +++ b/src/plugins/events/messageCreate/modules/credits/index.ts @@ -1,4 +1,4 @@ -import logger from "../../../../../logger"; +import logger from "../../../../../middlewares/logger"; import { Message } from "discord.js"; import fetchUser from "../../../../../helpers/fetchUser"; diff --git a/src/plugins/events/messageCreate/modules/points/index.ts b/src/plugins/events/messageCreate/modules/points/index.ts index ed18003..353c622 100644 --- a/src/plugins/events/messageCreate/modules/points/index.ts +++ b/src/plugins/events/messageCreate/modules/points/index.ts @@ -1,4 +1,4 @@ -import logger from "../../../../../logger"; +import logger from "../../../../../middlewares/logger"; import * as cooldown from "../../../../../helpers/cooldown"; diff --git a/src/plugins/events/messageDelete/audits.ts b/src/plugins/events/messageDelete/audits.ts index 4b5d5a2..0e1b7f6 100644 --- a/src/plugins/events/messageDelete/audits.ts +++ b/src/plugins/events/messageDelete/audits.ts @@ -1,4 +1,4 @@ -import logger from "../../../logger"; +import logger from "../../../middlewares/logger"; import { Message, MessageEmbed, TextChannel } from "discord.js"; import guildSchema from "../../../models/guild"; diff --git a/src/plugins/events/messageDelete/modules/counter.ts b/src/plugins/events/messageDelete/modules/counter.ts index 5681da8..e5533c3 100644 --- a/src/plugins/events/messageDelete/modules/counter.ts +++ b/src/plugins/events/messageDelete/modules/counter.ts @@ -3,7 +3,7 @@ import { Message } from "discord.js"; // Models import counterSchema from "../../../../models/counter"; -import logger from "../../../../logger"; +import logger from "../../../../middlewares/logger"; export default async (message: Message) => { const { guild, channel, author, content } = message; diff --git a/src/plugins/events/messageUpdate/audits.ts b/src/plugins/events/messageUpdate/audits.ts index 515a090..a9adeec 100644 --- a/src/plugins/events/messageUpdate/audits.ts +++ b/src/plugins/events/messageUpdate/audits.ts @@ -1,5 +1,5 @@ /* eslint-disable no-loops/no-loops */ -import logger from "../../../logger"; +import logger from "../../../middlewares/logger"; import { Message, MessageEmbed, TextChannel } from "discord.js"; import guildSchema from "../../../models/guild"; diff --git a/src/plugins/events/messageUpdate/index.ts b/src/plugins/events/messageUpdate/index.ts index 9c9bf47..273a2b4 100644 --- a/src/plugins/events/messageUpdate/index.ts +++ b/src/plugins/events/messageUpdate/index.ts @@ -1,6 +1,6 @@ // Dependencies import { Message } from "discord.js"; -import logger from "../../../logger"; +import logger from "../../../middlewares/logger"; // Modules import counter from "./modules/counter"; diff --git a/src/plugins/events/messageUpdate/modules/counter.ts b/src/plugins/events/messageUpdate/modules/counter.ts index 4a01749..15d3dc1 100644 --- a/src/plugins/events/messageUpdate/modules/counter.ts +++ b/src/plugins/events/messageUpdate/modules/counter.ts @@ -3,7 +3,7 @@ import { Message } from "discord.js"; // Models import counterSchema from "../../../../models/counter"; -import logger from "../../../../logger"; +import logger from "../../../../middlewares/logger"; export default async (message: Message) => { const { guild, channel, author, content } = message; diff --git a/src/plugins/events/rateLimit/index.ts b/src/plugins/events/rateLimit/index.ts index ca9aab5..a96b144 100644 --- a/src/plugins/events/rateLimit/index.ts +++ b/src/plugins/events/rateLimit/index.ts @@ -1,6 +1,6 @@ // Dependencies import { Client } from "discord.js"; -import logger from "../../../logger"; +import logger from "../../../middlewares/logger"; // Helpers import { IEventOptions } from "../../../interfaces/EventOptions"; diff --git a/src/plugins/events/ready/index.ts b/src/plugins/events/ready/index.ts index 125bdc8..b7d5809 100644 --- a/src/plugins/events/ready/index.ts +++ b/src/plugins/events/ready/index.ts @@ -1,6 +1,6 @@ // Dependencies import { Client } from "discord.js"; -import logger from "../../../logger"; +import logger from "../../../middlewares/logger"; // Helpers import updatePresence from "../../../helpers/updatePresence"; From e491102487a21b14ed8dde3aa2529ebe704fc012 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 24 Aug 2022 21:26:54 +0000 Subject: [PATCH 038/215] Update typescript-eslint monorepo to v5.35.1 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4c68bd2..e3ecb34 100644 --- a/package.json +++ b/package.json @@ -58,8 +58,8 @@ "@types/chance": "1.1.3", "@types/node-schedule": "2.1.0", "@types/uuid": "8.3.4", - "@typescript-eslint/eslint-plugin": "5.34.0", - "@typescript-eslint/parser": "5.34.0", + "@typescript-eslint/eslint-plugin": "5.35.1", + "@typescript-eslint/parser": "5.35.1", "eslint": "8.22.0", "eslint-config-airbnb-base": "15.0.0", "eslint-config-prettier": "8.5.0", From 5a09d9a5cf69cfd2ecbce40a553b555ae7c68562 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Thu, 25 Aug 2022 11:27:25 +0200 Subject: [PATCH 039/215] =?UTF-8?q?=F0=9F=91=BD=EF=B8=8F=20discord.js=20v1?= =?UTF-8?q?4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 3 +- src/helpers/cooldown/index.ts | 4 +- src/helpers/deferReply/index.ts | 6 +- src/helpers/embedBuilder/index.ts | 4 +- src/helpers/getDiscordCommandJSON/index.ts | 47 +++++++ src/helpers/getEmbedConfig/index.ts | 2 + src/helpers/getPluginCommandBuilder/index.ts | 12 ++ src/helpers/getPluginCommandOptions/index.ts | 11 ++ src/helpers/getPluginCommands/index.ts | 24 ++++ src/helpers/getPluginMetadata/index.ts | 8 ++ src/helpers/getPluginStructure/index.ts | 35 +++++ src/helpers/getPlugins/index.ts | 10 ++ src/helpers/registerDiscordCommands/index.ts | 22 ++++ src/index.ts | 10 +- src/managers/index.ts | 1 - src/plugins/commands/config/index.ts | 4 +- .../commands/config/modules/audits/index.ts | 55 ++++---- .../commands/config/modules/cpgg/index.ts | 45 ++++--- .../commands/config/modules/credits/index.ts | 97 +++++++------- .../embeds/components/getValues/index.ts | 8 +- .../commands/config/modules/embeds/index.ts | 11 +- .../commands/config/modules/points/index.ts | 76 ++++++----- .../commands/config/modules/shop/index.ts | 57 ++++---- .../commands/config/modules/welcome/index.ts | 124 +++++++++++++----- .../commands/counters/modules/view/index.ts | 41 +++--- .../commands/credits/modules/balance/index.ts | 4 +- .../commands/credits/modules/gift/index.ts | 4 +- .../commands/credits/modules/top/index.ts | 4 +- .../commands/credits/modules/work/index.ts | 4 +- .../commands/dns/modules/lookup/index.ts | 6 +- .../commands/fun/modules/meme/index.ts | 4 +- .../commands/manage/modules/counters/index.ts | 4 +- .../modules/counters/modules/add/index.ts | 12 +- .../modules/counters/modules/remove/index.ts | 14 +- .../modules/credits/modules/give/index.ts | 26 ++-- .../modules/credits/modules/giveaway/index.ts | 26 ++-- .../modules/credits/modules/set/index.ts | 23 ++-- .../modules/credits/modules/take/index.ts | 26 ++-- .../modules/credits/modules/transfer/index.ts | 32 +++-- .../moderation/modules/prune/index.ts | 56 ++++---- .../commands/shop/modules/cpgg/index.ts | 8 +- .../commands/utility/modules/about/index.ts | 59 +++++---- .../commands/utility/modules/avatar/index.ts | 4 +- .../commands/utility/modules/stats/index.ts | 26 ++-- src/plugins/events/guildMemberAdd/audits.ts | 6 +- .../events/guildMemberAdd/joinMessage.ts | 4 +- .../events/guildMemberRemove/audits.ts | 6 +- .../events/guildMemberRemove/leaveMessage.ts | 4 +- .../events/interactionCreate/audits.ts | 6 +- .../handlers/button/index.ts | 4 +- .../handlers/command/index.ts | 9 +- .../interactionCreate/handlers/index.ts | 28 +++- src/plugins/events/interactionCreate/index.ts | 37 ++---- .../messageCreate/modules/counters/index.ts | 4 +- .../messageCreate/modules/credits/index.ts | 7 +- .../messageCreate/modules/points/index.ts | 7 +- src/plugins/events/messageDelete/audits.ts | 4 +- src/plugins/events/messageUpdate/audits.ts | 4 +- 58 files changed, 749 insertions(+), 440 deletions(-) create mode 100644 src/helpers/getDiscordCommandJSON/index.ts create mode 100644 src/helpers/getPluginCommandBuilder/index.ts create mode 100644 src/helpers/getPluginCommandOptions/index.ts create mode 100644 src/helpers/getPluginCommands/index.ts create mode 100644 src/helpers/getPluginMetadata/index.ts create mode 100644 src/helpers/getPluginStructure/index.ts create mode 100644 src/helpers/getPlugins/index.ts create mode 100644 src/helpers/registerDiscordCommands/index.ts diff --git a/package.json b/package.json index 4c68bd2..4d6b52e 100644 --- a/package.json +++ b/package.json @@ -30,16 +30,15 @@ "email": "vermium@zyner.org" }, "dependencies": { - "@discordjs/builders": "^1.0.0", "@discordjs/rest": "^1.0.0", "@types/i18next-fs-backend": "^1.1.2", "axios": "^0.27.2", "chance": "^1.1.8", "common": "^0.2.5", "crypto": "^1.0.1", - "dotenv": "^16.0.1", "discord-api-types": "^0.37.0", "discord.js": "^14.0.0", + "dotenv": "^16.0.1", "i18n": "^0.15.0", "i18next": "^21.6.13", "i18next-async-backend": "^2.0.0", diff --git a/src/helpers/cooldown/index.ts b/src/helpers/cooldown/index.ts index 42b40ab..b8f3a55 100644 --- a/src/helpers/cooldown/index.ts +++ b/src/helpers/cooldown/index.ts @@ -127,9 +127,7 @@ export const message = async (msg: Message, cooldown: number, id: string) => { (new Date(hasTimeout.createdAt).getTime() - new Date().getTime()) / 1000 ); - throw new Error( - `User: ${userId} on timeout-id: ${id} with cooldown: ${cooldown} secs with remaining: ${diff} secs.` - ); + return `User: ${userId} on timeout-id: ${id} with cooldown: ${cooldown} secs with remaining: ${diff} secs.`; } // Delete timeout diff --git a/src/helpers/deferReply/index.ts b/src/helpers/deferReply/index.ts index 02cc413..790df34 100644 --- a/src/helpers/deferReply/index.ts +++ b/src/helpers/deferReply/index.ts @@ -1,7 +1,7 @@ -import { Interaction, MessageEmbed } from "discord.js"; +import { BaseInteraction, EmbedBuilder } from "discord.js"; import getEmbedConfig from "../../helpers/getEmbedConfig"; -export default async (interaction: Interaction, ephemeral: boolean) => { +export default async (interaction: BaseInteraction, ephemeral: boolean) => { if (!interaction.isRepliable()) throw new Error(`Cannot reply to an interaction that is not repliable`); @@ -13,7 +13,7 @@ export default async (interaction: Interaction, ephemeral: boolean) => { await interaction.editReply({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setFooter({ text: embedConfig.footerText, iconURL: embedConfig.footerIcon, diff --git a/src/helpers/embedBuilder/index.ts b/src/helpers/embedBuilder/index.ts index 6d6a51d..ef36024 100644 --- a/src/helpers/embedBuilder/index.ts +++ b/src/helpers/embedBuilder/index.ts @@ -1,6 +1,6 @@ -import { MessageEmbed } from "discord.js"; +import { EmbedBuilder } from "discord.js"; -export default new MessageEmbed() +export default new EmbedBuilder() .setFooter({ text: process.env.EMBED_FOOTER_TEXT, iconURL: process.env.EMBED_FOOTER_ICON, diff --git a/src/helpers/getDiscordCommandJSON/index.ts b/src/helpers/getDiscordCommandJSON/index.ts new file mode 100644 index 0000000..2fcf06f --- /dev/null +++ b/src/helpers/getDiscordCommandJSON/index.ts @@ -0,0 +1,47 @@ +/* eslint-disable no-loops/no-loops */ +import path from "path"; + +import listDir from "../listDir"; +import getPlugins from "../getPlugins"; +import getPluginCommands from "../getPluginCommands"; +import getPluginMetadata from "../getPluginMetadata"; +import getPluginCommandBuilder from "../getPluginCommandBuilder"; +import { SlashCommandBuilder } from "discord.js"; +import logger from "../../middlewares/logger"; + +export default async () => { + logger.debug("Processing complete builder for plugins"); + const plugins = await getPlugins("plugins"); + const pluginBuilders = []; + + for await (const plugin of plugins) { + logger.debug(`Processing builder for plugin: ${plugin}`); + + const commands = await getPluginCommands(plugin); + + const builderStructure = new SlashCommandBuilder() + .setName(plugin) + .setDescription("Get info about a user or a server!"); + + for await (const command of commands) { + logger.debug(`Processing builder of command: ${command.name}`); + if (command?.options?.group) { + logger.debug(`Processing subcommand group: ${command.builder.name}`); + builderStructure.addSubcommandGroup(command.builder); + logger.verbose(`Processed subcommand group: ${command.builder.name}!`); + } else { + logger.debug(`Processing subcommand: ${command.builder.name}`); + builderStructure.addSubcommand(command.builder); + logger.verbose(`Processed subcommand: ${command.builder.name}!`); + } + logger.verbose(`Processed builder of command: ${command.name}!`); + } + + pluginBuilders.push(builderStructure); + + logger.verbose(`Processed builder for plugin: ${plugin}!`); + } + + logger.verbose("Processed complete builder for plugins!"); + return pluginBuilders; +}; diff --git a/src/helpers/getEmbedConfig/index.ts b/src/helpers/getEmbedConfig/index.ts index 0d88716..3ac9ac8 100644 --- a/src/helpers/getEmbedConfig/index.ts +++ b/src/helpers/getEmbedConfig/index.ts @@ -18,6 +18,7 @@ export default async (guild?: Guild | null) => { footerText: EMBED_FOOTER_TEXT, footerIcon: EMBED_FOOTER_ICON, }; + if (!guild) { return defaultEmbedConfig; } @@ -26,5 +27,6 @@ export default async (guild?: Guild | null) => { if (!guildConfig) { return defaultEmbedConfig; } + return guildConfig.embeds; }; diff --git a/src/helpers/getPluginCommandBuilder/index.ts b/src/helpers/getPluginCommandBuilder/index.ts new file mode 100644 index 0000000..f474ac4 --- /dev/null +++ b/src/helpers/getPluginCommandBuilder/index.ts @@ -0,0 +1,12 @@ +import logger from "../../middlewares/logger"; +import listDir from "../listDir"; + +export default async (plugin: string, command: string) => { + logger.debug(`Processing builder for command: ${command}`); + const { builder } = await import( + `../../plugins/${plugin}/commands/${command}` + ); + logger.verbose(`Processed builder for command: ${command}!`); + + return builder; +}; diff --git a/src/helpers/getPluginCommandOptions/index.ts b/src/helpers/getPluginCommandOptions/index.ts new file mode 100644 index 0000000..ba41950 --- /dev/null +++ b/src/helpers/getPluginCommandOptions/index.ts @@ -0,0 +1,11 @@ +import logger from "../../middlewares/logger"; +import listDir from "../listDir"; + +export default async (plugin: string, command: string) => { + logger.debug(`Processing options for command: ${command}`); + const { options } = + (await import(`../../plugins/${plugin}/commands/${command}`)) || []; + logger.verbose(`Processed options for command: ${command}!`); + + return options; +}; diff --git a/src/helpers/getPluginCommands/index.ts b/src/helpers/getPluginCommands/index.ts new file mode 100644 index 0000000..93bae18 --- /dev/null +++ b/src/helpers/getPluginCommands/index.ts @@ -0,0 +1,24 @@ +/* eslint-disable no-loops/no-loops */ +import getPluginCommandBuilder from "../getPluginCommandBuilder"; +import listDir from "../listDir"; +import getPluginCommandOptions from "../getPluginCommandOptions"; +import logger from "../../middlewares/logger"; + +export default async (plugin: string) => { + logger.debug(`Processing commands for plugin: ${plugin}`); + const commands = (await listDir(`plugins/${plugin}/commands`)) || []; + const commandStructure = []; + + for await (const command of commands) { + logger.debug(`Processing command: ${command}`); + + const builder = await getPluginCommandBuilder(plugin, command); + const options = await getPluginCommandOptions(plugin, command); + + commandStructure.push({ name: command, builder, options }); + logger.verbose(`Processed command: ${command}!`); + } + + logger.verbose(`Processed commands for plugin: ${plugin}!`); + return commandStructure; +}; diff --git a/src/helpers/getPluginMetadata/index.ts b/src/helpers/getPluginMetadata/index.ts new file mode 100644 index 0000000..36a1eaf --- /dev/null +++ b/src/helpers/getPluginMetadata/index.ts @@ -0,0 +1,8 @@ +import logger from "../../middlewares/logger"; + +export default async (plugin: string) => { + logger.debug(`Processing metadata for plugin: ${plugin}`); + const metadata = await import(`../../plugins/${plugin}/metadata`); + logger.verbose(`Processed metadata for plugin: ${plugin}!`); + return metadata.default; +}; diff --git a/src/helpers/getPluginStructure/index.ts b/src/helpers/getPluginStructure/index.ts new file mode 100644 index 0000000..0bba6f4 --- /dev/null +++ b/src/helpers/getPluginStructure/index.ts @@ -0,0 +1,35 @@ +/* eslint-disable no-loops/no-loops */ +import path from "path"; + +import listDir from "../listDir"; +import getPlugins from "../getPlugins"; +import getPluginCommands from "../getPluginCommands"; +import getPluginMetadata from "../getPluginMetadata"; +import logger from "../../middlewares/logger"; + +export default async (client, dir: string) => { + const plugins = await getPlugins(dir); + const pluginStructure = []; + + logger.debug("Processing structure of plugins..."); + + for await (const plugin of plugins) { + logger.debug(`Processing structure of plugin: ${plugin}`); + const commands = await getPluginCommands(plugin); + const metadata = await getPluginMetadata(plugin); + + pluginStructure.push({ + plugin, + commands, + metadata, + }); + + client.commands.set(plugin, commands); + + logger.verbose(`Processed structure of plugin: ${plugin}!`); + } + + logger.verbose("Processed structure of plugins!"); + + return pluginStructure; +}; diff --git a/src/helpers/getPlugins/index.ts b/src/helpers/getPlugins/index.ts new file mode 100644 index 0000000..fbf9daa --- /dev/null +++ b/src/helpers/getPlugins/index.ts @@ -0,0 +1,10 @@ +import logger from "../../middlewares/logger"; +import listDir from "../listDir"; + +export default async (dir: string) => { + logger.debug("Processing list of plugins..."); + const plugins = await listDir(dir); + logger.verbose("Processed list of plugins!"); + + return plugins || []; +}; diff --git a/src/helpers/registerDiscordCommands/index.ts b/src/helpers/registerDiscordCommands/index.ts new file mode 100644 index 0000000..4ef501b --- /dev/null +++ b/src/helpers/registerDiscordCommands/index.ts @@ -0,0 +1,22 @@ +import { Routes } from "discord.js"; +import { REST } from "@discordjs/rest"; +import logger from "../../middlewares/logger"; + +export default async (builder: any) => { + const rest = new REST({ version: "10" }).setToken(process.env.DISCORD_TOKEN); + + await rest.put( + Routes.applicationGuildCommands( + process.env.DISCORD_CLIENT_ID, + process.env.DISCORD_GUILD_ID + ), + { body: builder } + ); + + await rest + .put(Routes.applicationCommands(process.env.DISCORD_CLIENT_ID as string), { + body: builder, + }) + .then(() => logger.info("Successfully deployed to Discord")) + .catch(() => logger.error("Failed to deployed to Discord")); +}; diff --git a/src/index.ts b/src/index.ts index a33abb5..4f1efba 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,5 @@ -import { Client, Collection } from "discord.js"; // discord.js +import "dotenv/config"; +import { Client, Collection, GatewayIntentBits } from "discord.js"; // discord.js import * as managers from "./managers"; @@ -6,7 +7,12 @@ import * as managers from "./managers"; const main = async () => { // Initiate client object const client = new Client({ - intents: ["GUILDS", "GUILD_MEMBERS", "GUILD_MESSAGES"], + intents: [ + GatewayIntentBits.Guilds, + GatewayIntentBits.GuildMembers, + GatewayIntentBits.GuildMessages, + GatewayIntentBits.MessageContent, + ], }); // Create command collection diff --git a/src/managers/index.ts b/src/managers/index.ts index 4e74859..a1f3dad 100644 --- a/src/managers/index.ts +++ b/src/managers/index.ts @@ -1,4 +1,3 @@ -import "dotenv/config"; import { Client } from "discord.js"; import * as database from "./database"; diff --git a/src/plugins/commands/config/index.ts b/src/plugins/commands/config/index.ts index 3e8b585..5d9fd42 100644 --- a/src/plugins/commands/config/index.ts +++ b/src/plugins/commands/config/index.ts @@ -1,5 +1,5 @@ import { SlashCommandBuilder } from "@discordjs/builders"; -import { CommandInteraction } from "discord.js"; +import { ChatInputCommandInteraction } from "discord.js"; import modules from "./modules"; @@ -17,7 +17,7 @@ export const builder = new SlashCommandBuilder() export const moduleData = modules; -export const execute = async (interaction: CommandInteraction) => { +export const execute = async (interaction: ChatInputCommandInteraction) => { switch (interaction.options?.getSubcommand()) { case "cpgg": return modules.cpgg.execute(interaction); diff --git a/src/plugins/commands/config/modules/audits/index.ts b/src/plugins/commands/config/modules/audits/index.ts index 7c9c313..b7f14ad 100644 --- a/src/plugins/commands/config/modules/audits/index.ts +++ b/src/plugins/commands/config/modules/audits/index.ts @@ -1,4 +1,8 @@ -import { CommandInteraction, Permissions } from "discord.js"; +import { + ChatInputCommandInteraction, + EmbedBuilder, + PermissionsBitField, +} from "discord.js"; import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; @@ -12,7 +16,7 @@ export default { metadata: { guildOnly: true, ephemeral: true, - permissions: [Permissions.FLAGS.MANAGE_GUILD], + permissions: [PermissionsBitField.Flags.ManageGuild], }, builder: (command: SlashCommandSubcommandBuilder) => { @@ -29,7 +33,7 @@ export default { .addChannelTypes(ChannelType.GuildText) ); }, - execute: async (interaction: CommandInteraction) => { + execute: async (interaction: ChatInputCommandInteraction) => { const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild ); @@ -54,31 +58,30 @@ export default { await guildDB?.save()?.then(async () => { logger?.silly(`Guild audits updated.`); - return interaction?.editReply({ - embeds: [ + const interactionEmbed = new EmbedBuilder() + .setTitle("[:hammer:] Audits") + .setDescription("Audit settings updated!") + .setColor(successColor) + .addFields( { - title: ":hammer: Settings - Guild [Audits]", - description: `Audits settings updated.`, - color: successColor, - fields: [ - { - name: "🤖 Status", - value: `${guildDB?.audits?.status}`, - inline: true, - }, - { - name: "🌊 Channel", - value: `${guildDB?.audits?.channelId}`, - inline: true, - }, - ], - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, + name: "🤖 Status", + value: `${guildDB?.audits?.status}`, + inline: true, }, - ], + { + name: "🌊 Channel", + value: `${guildDB?.audits?.channelId}`, + inline: true, + } + ) + .setTimestamp() + .setFooter({ + iconURL: footerIcon, + text: footerText, + }); + + return interaction?.editReply({ + embeds: [interactionEmbed], }); }); }, diff --git a/src/plugins/commands/config/modules/cpgg/index.ts b/src/plugins/commands/config/modules/cpgg/index.ts index e7568ff..3cc4731 100644 --- a/src/plugins/commands/config/modules/cpgg/index.ts +++ b/src/plugins/commands/config/modules/cpgg/index.ts @@ -1,4 +1,10 @@ -import { CommandInteraction, Permissions } from "discord.js"; +import { + ChatInputCommandInteraction, + CommandInteraction, + EmbedBuilder, + Permissions, + PermissionsBitField, +} from "discord.js"; import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; @@ -12,7 +18,7 @@ export default { metadata: { guildOnly: true, ephemeral: true, - permissions: [Permissions.FLAGS.MANAGE_GUILD], + permissions: [PermissionsBitField.Flags.ManageGuild], }, builder: (command: SlashCommandSubcommandBuilder) => { @@ -42,7 +48,7 @@ export default { .setRequired(true) ); }, - execute: async (interaction: CommandInteraction) => { + execute: async (interaction: ChatInputCommandInteraction) => { const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild ); @@ -63,23 +69,24 @@ export default { .then(async () => { logger?.silly(`Updated API credentials.`); - return interaction?.editReply({ - embeds: [ - { - title: "[:tools:] CPGG", - description: `The following configuration will be used. + const interactionEmbed = new EmbedBuilder() + .setTitle("[:tools:] CPGG") + .setDescription( + `The following configuration will be used. - **Scheme**: ${scheme} - **Domain**: ${domain} - **Token**: ends with ${tokenData?.slice(-4)}`, - color: successColor, - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }, - ], +**Scheme**: ${scheme} +**Domain**: ${domain} +**Token**: ends with ${tokenData?.slice(-4)}` + ) + .setColor(successColor) + .setTimestamp() + .setFooter({ + iconURL: footerIcon, + text: footerText, + }); + + return interaction?.editReply({ + embeds: [interactionEmbed], }); }); }, diff --git a/src/plugins/commands/config/modules/credits/index.ts b/src/plugins/commands/config/modules/credits/index.ts index 22924c1..3d67301 100644 --- a/src/plugins/commands/config/modules/credits/index.ts +++ b/src/plugins/commands/config/modules/credits/index.ts @@ -1,4 +1,10 @@ -import { CommandInteraction, Permissions } from "discord.js"; +import { + ChatInputCommandInteraction, + CommandInteraction, + EmbedBuilder, + Permissions, + PermissionsBitField, +} from "discord.js"; import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; @@ -11,7 +17,7 @@ export default { metadata: { guildOnly: true, ephemeral: true, - permissions: [Permissions.FLAGS.MANAGE_GUILD], + permissions: [PermissionsBitField.Flags.ManageGuild], }, builder: (command: SlashCommandSubcommandBuilder) => { @@ -45,7 +51,7 @@ export default { .setDescription("Timeout between earning credits (seconds).") ); }, - execute: async (interaction: CommandInteraction) => { + execute: async (interaction: ChatInputCommandInteraction) => { const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild ); @@ -83,51 +89,50 @@ export default { await guildDB?.save()?.then(async () => { logger?.silly(`Guild saved`); - return interaction?.editReply({ - embeds: [ + const interactionEmbed = new EmbedBuilder() + .setTitle("[:tools:] Credits") + .setDescription("Credits settings updated") + .setColor(successColor) + .addFields( { - title: ":tools: Settings - Guild [Credits]", - description: `Credits settings updated.`, - color: successColor, - fields: [ - { - name: "🤖 Status", - value: `${guildDB?.credits?.status}`, - inline: true, - }, - { - name: "📈 Rate", - value: `${guildDB?.credits?.rate}`, - inline: true, - }, - { - name: "📈 Work Rate", - value: `${guildDB?.credits?.workRate}`, - inline: true, - }, - { - name: "🔨 Minimum Length", - value: `${guildDB?.credits?.minimumLength}`, - inline: true, - }, - { - name: "⏰ Timeout", - value: `${guildDB?.credits?.timeout}`, - inline: true, - }, - { - name: "⏰ Work Timeout", - value: `${guildDB?.credits?.workTimeout}`, - inline: true, - }, - ], - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, + name: "🤖 Status", + value: `${guildDB?.credits?.status}`, + inline: true, }, - ], + { + name: "📈 Rate", + value: `${guildDB?.credits?.rate}`, + inline: true, + }, + { + name: "📈 Work Rate", + value: `${guildDB?.credits?.workRate}`, + inline: true, + }, + { + name: "🔨 Minimum Length", + value: `${guildDB?.credits?.minimumLength}`, + inline: true, + }, + { + name: "⏰ Timeout", + value: `${guildDB?.credits?.timeout}`, + inline: true, + }, + { + name: "⏰ Work Timeout", + value: `${guildDB?.credits?.workTimeout}`, + inline: true, + } + ) + .setTimestamp() + .setFooter({ + iconURL: footerIcon, + text: footerText, + }); + + return interaction?.editReply({ + embeds: [interactionEmbed], }); }); }, diff --git a/src/plugins/commands/config/modules/embeds/components/getValues/index.ts b/src/plugins/commands/config/modules/embeds/components/getValues/index.ts index a61ecb3..f8decdd 100644 --- a/src/plugins/commands/config/modules/embeds/components/getValues/index.ts +++ b/src/plugins/commands/config/modules/embeds/components/getValues/index.ts @@ -1,8 +1,12 @@ -import { ColorResolvable, CommandInteraction } from "discord.js"; +import { + ChatInputCommandInteraction, + ColorResolvable, + CommandInteraction, +} from "discord.js"; import guildSchema from "../../../../../../../models/guild"; import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; -export default async (interaction: CommandInteraction) => { +export default async (interaction: ChatInputCommandInteraction) => { const { options, guild } = interaction; if (!guild) throw new Error("Guild not found"); diff --git a/src/plugins/commands/config/modules/embeds/index.ts b/src/plugins/commands/config/modules/embeds/index.ts index e36b125..f868f49 100644 --- a/src/plugins/commands/config/modules/embeds/index.ts +++ b/src/plugins/commands/config/modules/embeds/index.ts @@ -1,8 +1,9 @@ import { ColorResolvable, - CommandInteraction, - MessageEmbed, + ChatInputCommandInteraction, + EmbedBuilder, Permissions, + PermissionsBitField, } from "discord.js"; import logger from "../../../../../middlewares/logger"; @@ -16,7 +17,7 @@ export default { metadata: { guildOnly: true, ephemeral: true, - permissions: [Permissions.FLAGS.MANAGE_GUILD], + permissions: [PermissionsBitField.Flags.ManageGuild], }, builder: (command: SlashCommandSubcommandBuilder) => { @@ -41,14 +42,14 @@ export default { option.setName("footer-text").setDescription("No provided description") ); }, - execute: async (interaction: CommandInteraction) => { + execute: async (interaction: ChatInputCommandInteraction) => { const { guild } = interaction; if (!guild) throw new Error("Guild not found"); const { successColor, waitColor, errorColor, footerText, footerIcon } = await getValues(interaction); - const embed = new MessageEmbed() + const embed = new EmbedBuilder() .setTitle("[:tools:] Embeds") .setFooter({ text: footerText, iconURL: footerIcon }) .setTimestamp(new Date()); diff --git a/src/plugins/commands/config/modules/points/index.ts b/src/plugins/commands/config/modules/points/index.ts index f782f00..e1a0704 100644 --- a/src/plugins/commands/config/modules/points/index.ts +++ b/src/plugins/commands/config/modules/points/index.ts @@ -1,4 +1,9 @@ -import { CommandInteraction, Permissions } from "discord.js"; +import { + ChatInputCommandInteraction, + EmbedBuilder, + Permissions, + PermissionsBitField, +} from "discord.js"; import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; @@ -11,7 +16,7 @@ export default { metadata: { guildOnly: true, ephemeral: true, - permissions: [Permissions.FLAGS.MANAGE_GUILD], + permissions: [PermissionsBitField.Flags.ManageGuild], }, builder: (command: SlashCommandSubcommandBuilder) => { @@ -35,7 +40,7 @@ export default { .setDescription("Timeout between earning credits (milliseconds).") ); }, - execute: async (interaction: CommandInteraction) => { + execute: async (interaction: ChatInputCommandInteraction) => { const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild ); @@ -65,41 +70,40 @@ export default { await guildDB?.save()?.then(async () => { logger?.silly(`Guild points updated.`); - return interaction?.editReply({ - embeds: [ + const interactionEmbed = new EmbedBuilder() + .setTitle("[:tools:] Points") + .setDescription("Points settings updated") + .setColor(successColor) + .addFields( { - title: ":hammer: Settings - Guild [Points]", - description: `Points settings updated.`, - color: successColor, - fields: [ - { - name: "🤖 Status", - value: `${guildDB?.points?.status}`, - inline: true, - }, - { - name: "📈 Rate", - value: `${guildDB?.points?.rate}`, - inline: true, - }, - { - name: "🔨 Minimum Length", - value: `${guildDB?.points?.minimumLength}`, - inline: true, - }, - { - name: "⏰ Timeout", - value: `${guildDB?.points?.timeout}`, - inline: true, - }, - ], - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, + name: "🤖 Status", + value: `${guildDB?.points?.status}`, + inline: true, }, - ], + { + name: "📈 Rate", + value: `${guildDB?.points?.rate}`, + inline: true, + }, + { + name: "🔨 Minimum Length", + value: `${guildDB?.points?.minimumLength}`, + inline: true, + }, + { + name: "⏰ Timeout", + value: `${guildDB?.points?.timeout}`, + inline: true, + } + ) + .setTimestamp() + .setFooter({ + iconURL: footerIcon, + text: footerText, + }); + + return interaction?.editReply({ + embeds: [interactionEmbed], }); }); }, diff --git a/src/plugins/commands/config/modules/shop/index.ts b/src/plugins/commands/config/modules/shop/index.ts index b346d72..8624b26 100644 --- a/src/plugins/commands/config/modules/shop/index.ts +++ b/src/plugins/commands/config/modules/shop/index.ts @@ -1,4 +1,10 @@ -import { CommandInteraction, Permissions } from "discord.js"; +import { + ChatInputCommandInteraction, + CommandInteraction, + EmbedBuilder, + Permissions, + PermissionsBitField, +} from "discord.js"; import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; @@ -11,7 +17,7 @@ export default { metadata: { guildOnly: true, ephemeral: true, - permissions: [Permissions.FLAGS.MANAGE_GUILD], + permissions: [PermissionsBitField.Flags.ManageGuild], }, builder: (command: SlashCommandSubcommandBuilder) => { @@ -29,7 +35,7 @@ export default { .setDescription("Price per hour for roles.") ); }, - execute: async (interaction: CommandInteraction) => { + execute: async (interaction: ChatInputCommandInteraction) => { const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild ); @@ -56,31 +62,30 @@ export default { await guildDB?.save()?.then(async () => { logger?.silly(`Guild shop updated.`); - return interaction?.editReply({ - embeds: [ + const interactionEmbed = new EmbedBuilder() + .setTitle("[:tools:] Shop") + .setDescription("Shop settings updated") + .setColor(successColor) + .addFields( { - title: ":hammer: Settings - Guild [Shop]", - description: `Shop settings updated.`, - color: successColor, - fields: [ - { - name: "🤖 Roles Status", - value: `${guildDB?.shop?.roles.status}`, - inline: true, - }, - { - name: "🌊 Roles Price Per Hour", - value: `${guildDB?.shop?.roles.pricePerHour}`, - inline: true, - }, - ], - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, + name: "🤖 Roles Status", + value: `${guildDB?.shop?.roles.status}`, + inline: true, }, - ], + { + name: "🌊 Roles Price Per Hour", + value: `${guildDB?.shop?.roles.pricePerHour}`, + inline: true, + } + ) + .setTimestamp() + .setFooter({ + iconURL: footerIcon, + text: footerText, + }); + + return interaction?.editReply({ + embeds: [interactionEmbed], }); }); }, diff --git a/src/plugins/commands/config/modules/welcome/index.ts b/src/plugins/commands/config/modules/welcome/index.ts index fd0cb84..cd55b16 100644 --- a/src/plugins/commands/config/modules/welcome/index.ts +++ b/src/plugins/commands/config/modules/welcome/index.ts @@ -1,4 +1,10 @@ -import { CommandInteraction, Permissions } from "discord.js"; +import { + ChatInputCommandInteraction, + CommandInteraction, + EmbedBuilder, + Permissions, + PermissionsBitField, +} from "discord.js"; import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; @@ -12,7 +18,7 @@ export default { metadata: { guildOnly: true, ephemeral: true, - permissions: [Permissions.FLAGS.MANAGE_GUILD], + permissions: [PermissionsBitField.Flags.ManageGuild], }, builder: (command: SlashCommandSubcommandBuilder) => { @@ -47,7 +53,7 @@ export default { .setDescription("Message for join messages.") ); }, - execute: async (interaction: CommandInteraction) => { + execute: async (interaction: ChatInputCommandInteraction) => { const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild ); @@ -86,46 +92,92 @@ export default { await guildDB?.save()?.then(async () => { logger?.silly(`Guild welcome updated.`); + const interactionEmbedDisabled = new EmbedBuilder() + .setTitle("[:tools:] Welcome") + .setDescription( + "This module is currently disabled, please enable it to continue." + ) + .setColor(successColor) + .addFields( + { + name: "🤖 Status", + value: `${guildDB?.points?.status}`, + inline: true, + }, + { + name: "📈 Rate", + value: `${guildDB?.points?.rate}`, + inline: true, + }, + { + name: "🔨 Minimum Length", + value: `${guildDB?.points?.minimumLength}`, + inline: true, + }, + { + name: "⏰ Timeout", + value: `${guildDB?.points?.timeout}`, + inline: true, + } + ) + .setTimestamp() + .setFooter({ + iconURL: footerIcon, + text: footerText, + }); + if (!guildDB?.welcome?.status) { return interaction?.editReply({ - embeds: [ - { - title: "[:tools:] Welcome", - description: `This module is currently disabled, please enable it to continue.`, - color: successColor, - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }, - ], + embeds: [interactionEmbedDisabled], }); } - return interaction?.editReply({ - embeds: [ + const interactionEmbed = new EmbedBuilder() + .setTitle("[:tools:] Welcome") + .setDescription( + `The following configuration will be used. + + [👋] **Welcome** + + ㅤ**Channel**: <#${guildDB?.welcome?.joinChannel}> + ㅤ**Message**: ${guildDB?.welcome?.joinChannelMessage} + + [🚪] **Leave** + + ㅤ**Channel**: <#${guildDB?.welcome?.leaveChannel}> + ㅤ**Message**: ${guildDB?.welcome?.leaveChannelMessage}` + ) + .setColor(successColor) + .addFields( { - title: "[:tools:] Welcome", - description: `The following configuration will be used. - - [👋] **Welcome** - - ㅤ**Channel**: <#${guildDB?.welcome?.joinChannel}> - ㅤ**Message**: ${guildDB?.welcome?.joinChannelMessage} - - [🚪] **Leave** - - ㅤ**Channel**: <#${guildDB?.welcome?.leaveChannel}> - ㅤ**Message**: ${guildDB?.welcome?.leaveChannelMessage}`, - color: successColor, - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, + name: "🤖 Status", + value: `${guildDB?.points?.status}`, + inline: true, }, - ], + { + name: "📈 Rate", + value: `${guildDB?.points?.rate}`, + inline: true, + }, + { + name: "🔨 Minimum Length", + value: `${guildDB?.points?.minimumLength}`, + inline: true, + }, + { + name: "⏰ Timeout", + value: `${guildDB?.points?.timeout}`, + inline: true, + } + ) + .setTimestamp() + .setFooter({ + iconURL: footerIcon, + text: footerText, + }); + + return interaction?.editReply({ + embeds: [interactionEmbed], }); }); }, diff --git a/src/plugins/commands/counters/modules/view/index.ts b/src/plugins/commands/counters/modules/view/index.ts index 77e1714..695008d 100644 --- a/src/plugins/commands/counters/modules/view/index.ts +++ b/src/plugins/commands/counters/modules/view/index.ts @@ -1,6 +1,6 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; -import { CommandInteraction, MessageEmbed } from "discord.js"; +import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChannelType } from "discord-api-types/v10"; @@ -24,14 +24,18 @@ export default { ); }, - execute: async (interaction: CommandInteraction) => { - const { errorColor, successColor, footerText, footerIcon } = - await getEmbedConfig(interaction.guild); + execute: async (interaction: ChatInputCommandInteraction) => { + const { successColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); const { options, guild } = interaction; - const discordChannel = options?.getChannel("channel"); + const discordChannel = options.getChannel("channel"); - const embed = new MessageEmbed() + if (!guild) throw new Error(`Guild not found`); + if (!discordChannel) throw new Error(`Channel not found`); + + const embed = new EmbedBuilder() .setTitle("[:1234:] Counters (View)") .setTimestamp(new Date()) .setFooter({ @@ -39,22 +43,21 @@ export default { iconURL: footerIcon, }); - const counter = await counterSchema?.findOne({ - guildId: guild?.id, - channelId: discordChannel?.id, + const counter = await counterSchema.findOne({ + guildId: guild.id, + channelId: discordChannel.id, }); - if (counter === null) { - return interaction?.editReply({ - embeds: [ - embed - .setDescription(`No counter found for channel ${discordChannel}!`) - .setColor(errorColor), - ], - }); - } + const counters = await counterSchema.find(); - return interaction?.editReply({ + console.log(counters, { + guildId: guild.id, + channelId: discordChannel.id, + }); + + if (!counter) throw new Error("No counter found for channel"); + + return interaction.editReply({ embeds: [ embed .setDescription( diff --git a/src/plugins/commands/credits/modules/balance/index.ts b/src/plugins/commands/credits/modules/balance/index.ts index 40e3668..0bef3a7 100644 --- a/src/plugins/commands/credits/modules/balance/index.ts +++ b/src/plugins/commands/credits/modules/balance/index.ts @@ -1,6 +1,6 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; -import { CommandInteraction, MessageEmbed } from "discord.js"; +import { CommandInteraction, EmbedBuilder } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import logger from "../../../../../middlewares/logger"; @@ -25,7 +25,7 @@ export default { const discordUser = options.getUser("user"); - const embed = new MessageEmbed() + const embed = new EmbedBuilder() .setTitle("[:dollar:] Balance") .setTimestamp(new Date()) .setFooter({ text: footerText, iconURL: footerIcon }); diff --git a/src/plugins/commands/credits/modules/gift/index.ts b/src/plugins/commands/credits/modules/gift/index.ts index c1bb320..7272ec2 100644 --- a/src/plugins/commands/credits/modules/gift/index.ts +++ b/src/plugins/commands/credits/modules/gift/index.ts @@ -1,5 +1,5 @@ // Dependencies -import { CommandInteraction, MessageEmbed } from "discord.js"; +import { CommandInteraction, EmbedBuilder } from "discord.js"; // Configurations import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; @@ -46,7 +46,7 @@ export default { const optionAmount = options.getInteger("amount"); const optionReason = options.getString("reason"); - const embed = new MessageEmbed() + const embed = new EmbedBuilder() .setTitle("[:dollar:] Gift") .setTimestamp(new Date()) .setFooter({ text: footerText, iconURL: footerIcon }); diff --git a/src/plugins/commands/credits/modules/top/index.ts b/src/plugins/commands/credits/modules/top/index.ts index 1fb6019..53b386e 100644 --- a/src/plugins/commands/credits/modules/top/index.ts +++ b/src/plugins/commands/credits/modules/top/index.ts @@ -1,6 +1,6 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; -import { CommandInteraction, MessageEmbed } from "discord.js"; +import { CommandInteraction, EmbedBuilder } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import logger from "../../../../../middlewares/logger"; @@ -17,7 +17,7 @@ export default { await getEmbedConfig(interaction.guild); const { guild } = interaction; - const embed = new MessageEmbed() + const embed = new EmbedBuilder() .setTitle("[:dollar:] Top") .setTimestamp(new Date()) .setFooter({ text: footerText, iconURL: footerIcon }); diff --git a/src/plugins/commands/credits/modules/work/index.ts b/src/plugins/commands/credits/modules/work/index.ts index 156b49c..185a8d5 100644 --- a/src/plugins/commands/credits/modules/work/index.ts +++ b/src/plugins/commands/credits/modules/work/index.ts @@ -1,5 +1,5 @@ // Dependencies -import { CommandInteraction, MessageEmbed } from "discord.js"; +import { CommandInteraction, EmbedBuilder } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import Chance from "chance"; @@ -28,7 +28,7 @@ export default { ); // Destructure member const { guild, user } = interaction; - const embed = new MessageEmbed() + const embed = new EmbedBuilder() .setTitle("[:dollar:] Work") .setTimestamp(new Date()) .setFooter({ diff --git a/src/plugins/commands/dns/modules/lookup/index.ts b/src/plugins/commands/dns/modules/lookup/index.ts index ea56b83..f3d443d 100644 --- a/src/plugins/commands/dns/modules/lookup/index.ts +++ b/src/plugins/commands/dns/modules/lookup/index.ts @@ -1,5 +1,5 @@ import axios from "axios"; -import { CommandInteraction, MessageEmbed } from "discord.js"; +import { CommandInteraction, EmbedBuilder } from "discord.js"; import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; @@ -35,7 +35,7 @@ export default { if (response.data.status !== "success") { await interaction.editReply({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setTitle(embedTitle) .setFooter({ text: footerText, @@ -54,7 +54,7 @@ export default { await interaction.editReply({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setTitle(embedTitle) .setFooter({ text: footerText, diff --git a/src/plugins/commands/fun/modules/meme/index.ts b/src/plugins/commands/fun/modules/meme/index.ts index 88b2304..a374ee9 100644 --- a/src/plugins/commands/fun/modules/meme/index.ts +++ b/src/plugins/commands/fun/modules/meme/index.ts @@ -1,7 +1,7 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; import axios from "axios"; -import { CommandInteraction, MessageEmbed } from "discord.js"; +import { CommandInteraction, EmbedBuilder } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; export default { @@ -22,7 +22,7 @@ export default { const response = res.data[0].data.children; const content = response[0].data; - const embed = new MessageEmbed() + const embed = new EmbedBuilder() .setAuthor({ name: content.title, iconURL: diff --git a/src/plugins/commands/manage/modules/counters/index.ts b/src/plugins/commands/manage/modules/counters/index.ts index d8b3c52..a6f351d 100644 --- a/src/plugins/commands/manage/modules/counters/index.ts +++ b/src/plugins/commands/manage/modules/counters/index.ts @@ -1,6 +1,6 @@ // Dependencies import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders"; -import { CommandInteraction } from "discord.js"; +import { ChatInputCommandInteraction, CommandInteraction } from "discord.js"; import logger from "../../../../../middlewares/logger"; @@ -18,7 +18,7 @@ export const builder = (group: SlashCommandSubcommandGroupBuilder) => { .addSubcommand(modules.remove.builder); }; -export const execute = async (interaction: CommandInteraction) => { +export const execute = async (interaction: ChatInputCommandInteraction) => { const { options } = interaction; if (options?.getSubcommand() === "add") { diff --git a/src/plugins/commands/manage/modules/counters/modules/add/index.ts b/src/plugins/commands/manage/modules/counters/modules/add/index.ts index 3c73f75..c1b022f 100644 --- a/src/plugins/commands/manage/modules/counters/modules/add/index.ts +++ b/src/plugins/commands/manage/modules/counters/modules/add/index.ts @@ -1,5 +1,9 @@ // Dependencies -import { MessageEmbed, CommandInteraction, Permissions } from "discord.js"; +import { + EmbedBuilder, + ChatInputCommandInteraction, + PermissionsBitField, +} from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChannelType } from "discord-api-types/v10"; @@ -16,7 +20,7 @@ export default { metadata: { guildOnly: true, ephemeral: true, - permissions: [Permissions.FLAGS.MANAGE_GUILD], + permissions: [PermissionsBitField.Flags.ManageGuild], }, builder: (command: SlashCommandSubcommandBuilder) => { @@ -42,7 +46,7 @@ export default { .setDescription("The starting value of the counter.") ); }, - execute: async (interaction: CommandInteraction) => { + execute: async (interaction: ChatInputCommandInteraction) => { const { errorColor, successColor, footerText, footerIcon } = await getEmbedConfig(interaction.guild); const { options, guild } = interaction; @@ -51,7 +55,7 @@ export default { const countingWord = options?.getString("word"); const startValue = options?.getNumber("start"); - const embed = new MessageEmbed() + const embed = new EmbedBuilder() .setTitle("[:toolbox:] Counters - Add") .setTimestamp(new Date()) .setFooter({ text: footerText, iconURL: footerIcon }); diff --git a/src/plugins/commands/manage/modules/counters/modules/remove/index.ts b/src/plugins/commands/manage/modules/counters/modules/remove/index.ts index 07f374f..018ae94 100644 --- a/src/plugins/commands/manage/modules/counters/modules/remove/index.ts +++ b/src/plugins/commands/manage/modules/counters/modules/remove/index.ts @@ -1,5 +1,11 @@ // Dependencies -import { CommandInteraction, MessageEmbed, Permissions } from "discord.js"; +import { + ChatInputCommandInteraction, + CommandInteraction, + EmbedBuilder, + Permissions, + PermissionsBitField, +} from "discord.js"; // Configurations import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; @@ -17,7 +23,7 @@ export default { metadata: { guildOnly: true, ephemeral: true, - permissions: [Permissions.FLAGS.MANAGE_GUILD], + permissions: [PermissionsBitField.Flags.ManageGuild], }, builder: (command: SlashCommandSubcommandBuilder) => { @@ -32,14 +38,14 @@ export default { .addChannelTypes(ChannelType.GuildText) ); }, - execute: async (interaction: CommandInteraction) => { + execute: async (interaction: ChatInputCommandInteraction) => { const { errorColor, successColor, footerText, footerIcon } = await getEmbedConfig(interaction.guild); const { options, guild } = interaction; const discordChannel = options?.getChannel("channel"); - const embed = new MessageEmbed() + const embed = new EmbedBuilder() .setTitle("[:toolbox:] Counters - Remove") .setTimestamp(new Date()) .setFooter({ text: footerText, iconURL: footerIcon }); diff --git a/src/plugins/commands/manage/modules/credits/modules/give/index.ts b/src/plugins/commands/manage/modules/credits/modules/give/index.ts index e6a83f0..2eadb62 100644 --- a/src/plugins/commands/manage/modules/credits/modules/give/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/give/index.ts @@ -1,5 +1,11 @@ // Dependencies -import { CommandInteraction, MessageEmbed, Permissions } from "discord.js"; +import { + ChatInputCommandInteraction, + CommandInteraction, + EmbedBuilder, + Permissions, + PermissionsBitField, +} from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Configurations @@ -19,7 +25,7 @@ export default { metadata: { guildOnly: true, ephemeral: true, - permissions: [Permissions.FLAGS.MANAGE_GUILD], + permissions: [PermissionsBitField.Flags.ManageGuild], }, builder: (command: SlashCommandSubcommandBuilder) => { @@ -39,7 +45,7 @@ export default { .setRequired(true) ); }, - execute: async (interaction: CommandInteraction) => { + execute: async (interaction: ChatInputCommandInteraction) => { const { errorColor, successColor, footerText, footerIcon } = await getEmbedConfig(interaction.guild); // Destructure const { guild, options } = interaction; @@ -53,7 +59,7 @@ export default { return interaction?.editReply({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Give)") .setDescription(`You must provide an amount.`) .setTimestamp(new Date()) @@ -69,7 +75,7 @@ export default { return interaction?.editReply({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Give)") .setDescription(`You must provide an amount greater than zero.`) .setTimestamp(new Date()) @@ -84,7 +90,7 @@ export default { return interaction?.editReply({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Give)") .setDescription(`You must provide a user.`) .setTimestamp(new Date()) @@ -98,7 +104,7 @@ export default { return interaction?.editReply({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Give)") .setDescription(`You must be in a guild.`) .setTimestamp(new Date()) @@ -115,7 +121,7 @@ export default { return interaction?.editReply({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Give)") .setDescription(`The user you provided could not be found.`) .setTimestamp(new Date()) @@ -128,7 +134,7 @@ export default { if (toUser?.credits === null) { return interaction?.editReply({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Give)") .setDescription(`The user you provided does not have any credits.`) .setTimestamp(new Date()) @@ -147,7 +153,7 @@ export default { return interaction?.editReply({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Give)") .setDescription( `Successfully gave ${pluralize(creditAmount, "credit")}` diff --git a/src/plugins/commands/manage/modules/credits/modules/giveaway/index.ts b/src/plugins/commands/manage/modules/credits/modules/giveaway/index.ts index 5c08048..6d8decc 100644 --- a/src/plugins/commands/manage/modules/credits/modules/giveaway/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/giveaway/index.ts @@ -1,10 +1,12 @@ // Dependencies import { CommandInteraction, - MessageActionRow, - MessageButton, - MessageEmbed, + ActionRowBuilder, + ButtonBuilder, + EmbedBuilder, Permissions, + PermissionsBitField, + ChatInputCommandInteraction, } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { v4 as uuidv4 } from "uuid"; @@ -15,14 +17,14 @@ import encryption from "../../../../../../../handlers/encryption"; // Configurations import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; -import { ChannelType } from "discord-api-types/v10"; +import { ButtonStyle, ChannelType } from "discord-api-types/v10"; // Function export default { metadata: { guildOnly: true, ephemeral: true, - permissions: [Permissions.FLAGS.MANAGE_GUILD], + permissions: [PermissionsBitField.Flags.ManageGuild], }, builder: (command: SlashCommandSubcommandBuilder) => { @@ -49,7 +51,7 @@ export default { .addChannelTypes(ChannelType.GuildText) ); }, - execute: async (interaction: CommandInteraction) => { + execute: async (interaction: ChatInputCommandInteraction) => { const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild ); // Destructure @@ -63,7 +65,7 @@ export default { if (!creditAmount) throw new Error("Amount of credits is required."); if (!channel) throw new Error("Channel is required."); - const embed = new MessageEmbed() + const embed = new EmbedBuilder() .setTitle("[:toolbox:] Giveaway") .setFooter({ text: footerText, iconURL: footerIcon }); @@ -102,10 +104,10 @@ export default { ], }); - const buttons = new MessageActionRow().addComponents( - new MessageButton() + const buttons = new ActionRowBuilder().addComponents( + new ButtonBuilder() .setLabel("Redeem it here") - .setStyle("LINK") + .setStyle(ButtonStyle.Link) .setEmoji("🏦") .setURL(`${shopUrl}?voucher=${code}`) ); @@ -114,11 +116,11 @@ export default { if (!discordChannel) return; - if (discordChannel.type !== "GUILD_TEXT") return; + if (discordChannel.type !== ChannelType.GuildText) return; discordChannel.send({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setTitle("[:parachute:] Credits!") .addFields([ { diff --git a/src/plugins/commands/manage/modules/credits/modules/set/index.ts b/src/plugins/commands/manage/modules/credits/modules/set/index.ts index 6ca7e8b..57de608 100644 --- a/src/plugins/commands/manage/modules/credits/modules/set/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/set/index.ts @@ -1,5 +1,10 @@ // Dependencies -import { CommandInteraction, MessageEmbed, Permissions } from "discord.js"; +import { + CommandInteraction, + EmbedBuilder, + Permissions, + PermissionsBitField, +} from "discord.js"; // Configurations import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; @@ -18,7 +23,7 @@ export default { metadata: { guildOnly: true, ephemeral: true, - permissions: [Permissions.FLAGS.MANAGE_GUILD], + permissions: [PermissionsBitField.Flags.ManageGuild], }, builder: (command: SlashCommandSubcommandBuilder) => { @@ -38,7 +43,7 @@ export default { .setRequired(true) ); }, - execute: async (interaction: CommandInteraction) => { + execute: async (interaction: ChatInputCommandInteraction) => { const { errorColor, successColor, footerText, footerIcon } = await getEmbedConfig(interaction.guild); const { options, guild } = interaction; @@ -52,7 +57,7 @@ export default { return interaction?.editReply({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Set)") .setDescription(`You must provide an amount.`) .setTimestamp(new Date()) @@ -67,7 +72,7 @@ export default { return interaction?.editReply({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Set)") .setDescription(`You must provide a user.`) .setTimestamp(new Date()) @@ -81,7 +86,7 @@ export default { return interaction?.editReply({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Set)") .setDescription(`You must provide a guild.`) .setTimestamp(new Date()) @@ -100,7 +105,7 @@ export default { return interaction?.editReply({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Set)") .setDescription(`The user you provided does not exist.`) .setTimestamp(new Date()) @@ -116,7 +121,7 @@ export default { return interaction?.editReply({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Set)") .setDescription(`The user you provided does not have any credits.`) .setTimestamp(new Date()) @@ -135,7 +140,7 @@ export default { return interaction?.editReply({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Set)") .setDescription( `Set **${discordUser}**'s credits to **${creditAmount}**.` diff --git a/src/plugins/commands/manage/modules/credits/modules/take/index.ts b/src/plugins/commands/manage/modules/credits/modules/take/index.ts index b977b73..b2dae44 100644 --- a/src/plugins/commands/manage/modules/credits/modules/take/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/take/index.ts @@ -1,5 +1,11 @@ // Dependencies -import { CommandInteraction, MessageEmbed, Permissions } from "discord.js"; +import { + ChatInputCommandInteraction, + CommandInteraction, + EmbedBuilder, + Permissions, + PermissionsBitField, +} from "discord.js"; // Configurations import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; @@ -19,7 +25,7 @@ export default { metadata: { guildOnly: true, ephemeral: true, - permissions: [Permissions.FLAGS.MANAGE_GUILD], + permissions: [PermissionsBitField.Flags.ManageGuild], }, builder: (command: SlashCommandSubcommandBuilder) => { @@ -39,7 +45,7 @@ export default { .setRequired(true) ); }, - execute: async (interaction: CommandInteraction) => { + execute: async (interaction: ChatInputCommandInteraction) => { const { errorColor, successColor, footerText, footerIcon } = await getEmbedConfig(interaction.guild); // Destructure const { guild, options } = interaction; @@ -56,7 +62,7 @@ export default { return interaction?.editReply({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Take)") .setDescription(`You must provide an amount.`) .setTimestamp(new Date()) @@ -72,7 +78,7 @@ export default { return interaction?.editReply({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Take)") .setDescription(`You must provide an amount greater than zero.`) .setTimestamp(new Date()) @@ -87,7 +93,7 @@ export default { return interaction?.editReply({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Take)") .setDescription(`You must provide a user.`) .setTimestamp(new Date()) @@ -101,7 +107,7 @@ export default { return interaction?.editReply({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Take)") .setDescription(`You must be in a guild.`) .setTimestamp(new Date()) @@ -120,7 +126,7 @@ export default { return interaction?.editReply({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Take)") .setDescription(`The user you provided does not exist.`) .setTimestamp(new Date()) @@ -136,7 +142,7 @@ export default { return interaction?.editReply({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Take)") .setDescription(`The user you provided does not have credits.`) .setTimestamp(new Date()) @@ -155,7 +161,7 @@ export default { return interaction?.editReply({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Take)") .setDescription( `Took ${pluralize(optionAmount, "credit")} from ${optionUser}.` diff --git a/src/plugins/commands/manage/modules/credits/modules/transfer/index.ts b/src/plugins/commands/manage/modules/credits/modules/transfer/index.ts index 74cf0d6..0108f26 100644 --- a/src/plugins/commands/manage/modules/credits/modules/transfer/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/transfer/index.ts @@ -1,5 +1,11 @@ // Dependencies -import { CommandInteraction, MessageEmbed, Permissions } from "discord.js"; +import { + ChatInputCommandInteraction, + CommandInteraction, + EmbedBuilder, + Permissions, + PermissionsBitField, +} from "discord.js"; import mongoose from "mongoose"; @@ -18,7 +24,7 @@ export default { metadata: { guildOnly: true, ephemeral: true, - permissions: [Permissions.FLAGS.MANAGE_GUILD], + permissions: [PermissionsBitField.Flags.ManageGuild], }, builder: (command: SlashCommandSubcommandBuilder) => { @@ -44,7 +50,7 @@ export default { .setRequired(true) ); }, - execute: async (interaction: CommandInteraction) => { + execute: async (interaction: ChatInputCommandInteraction) => { const { errorColor, successColor, footerText, footerIcon } = await getEmbedConfig(interaction.guild); // Destructure member const { guild, options } = interaction; @@ -60,7 +66,7 @@ export default { return interaction?.editReply({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Transfer)") .setDescription(`You must provide an amount.`) .setTimestamp(new Date()) @@ -75,7 +81,7 @@ export default { return interaction?.editReply({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Transfer)") .setDescription(`You must be in a guild.`) .setTimestamp(new Date()) @@ -89,7 +95,7 @@ export default { return interaction?.editReply({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Transfer)") .setDescription(`You must provide a user to transfer from.`) .setTimestamp(new Date()) @@ -103,7 +109,7 @@ export default { return interaction?.editReply({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Transfer)") .setDescription(`You must provide a user to transfer to.`) .setTimestamp(new Date()) @@ -125,7 +131,7 @@ export default { return interaction?.editReply({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Transfer)") .setDescription( `The user you provided to transfer from does not exist.` @@ -143,7 +149,7 @@ export default { return interaction?.editReply({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Transfer)") .setDescription( `The user you provided to transfer from does not have credits.` @@ -161,7 +167,7 @@ export default { return interaction?.editReply({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Transfer)") .setDescription( `The user you provided to transfer to does not exist.` @@ -179,7 +185,7 @@ export default { return interaction?.editReply({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Transfer)") .setDescription( `The user you provided to transfer to does not have credits.` @@ -214,7 +220,7 @@ export default { return interaction.editReply({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Transfer)") .setDescription( "An error occurred while trying to gift credits. Please try again." @@ -232,7 +238,7 @@ export default { return interaction?.editReply({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Transfer)") .setDescription(`Transferred ${optionAmount} credits.`) .addFields( diff --git a/src/plugins/commands/moderation/modules/prune/index.ts b/src/plugins/commands/moderation/modules/prune/index.ts index e556969..9745ca0 100644 --- a/src/plugins/commands/moderation/modules/prune/index.ts +++ b/src/plugins/commands/moderation/modules/prune/index.ts @@ -1,5 +1,12 @@ // Dependencies -import { CommandInteraction, Permissions } from "discord.js"; +import { + ChannelType, + ChatInputCommandInteraction, + CommandInteraction, + EmbedBuilder, + Permissions, + PermissionsBitField, +} from "discord.js"; // Configurations import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; @@ -11,7 +18,7 @@ export default { metadata: { guildOnly: true, ephemeral: false, - permissions: [Permissions.FLAGS.MANAGE_MESSAGES], + permissions: [PermissionsBitField.Flags.ManageMessages], }, builder: (command: SlashCommandSubcommandBuilder) => { @@ -28,33 +35,29 @@ export default { option.setName("bots").setDescription("Include bots.") ); }, - execute: async (interaction: CommandInteraction) => { - const { successColor, footerText, footerIcon } = await getEmbedConfig( - interaction.guild - ); + execute: async (interaction: ChatInputCommandInteraction) => { + const { errorColor, successColor, footerText, footerIcon } = + await getEmbedConfig(interaction.guild); const count = interaction.options.getInteger("count"); if (count == null) return; const bots = interaction.options.getBoolean("bots"); if (count < 1 || count > 100) { - const interactionEmbed = { - title: "[:police_car:] Prune", - description: `You can only prune between 1 and 100 messages.`, - color: successColor, - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }; + const interactionEmbed = new EmbedBuilder() + .setTitle("[:police_car:] Prune") + .setDescription(`You can only prune between 1 and 100 messages.`) + .setTimestamp() + .setColor(errorColor) + .setFooter({ text: footerText, iconURL: footerIcon }); + await interaction.editReply({ embeds: [interactionEmbed], }); return; } - if (interaction?.channel?.type !== "GUILD_TEXT") return; + if (interaction?.channel?.type !== ChannelType.GuildText) return; await interaction.channel.messages.fetch().then(async (messages) => { const messagesToDelete = ( bots @@ -65,20 +68,17 @@ export default { ) ).first(count); - if (interaction?.channel?.type !== "GUILD_TEXT") return; + if (interaction?.channel?.type !== ChannelType.GuildText) return; await interaction.channel .bulkDelete(messagesToDelete, true) .then(async () => { - const interactionEmbed = { - title: "[:police_car:] Prune", - description: `Successfully pruned \`${count}\` messages.`, - color: successColor, - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }; + const interactionEmbed = new EmbedBuilder() + .setTitle("[:police_car:] Prune") + .setDescription(`Successfully pruned \`${count}\` messages.`) + .setTimestamp() + .setColor(errorColor) + .setFooter({ text: footerText, iconURL: footerIcon }); + await interaction.editReply({ embeds: [interactionEmbed], }); diff --git a/src/plugins/commands/shop/modules/cpgg/index.ts b/src/plugins/commands/shop/modules/cpgg/index.ts index 38d67b6..5655d7a 100644 --- a/src/plugins/commands/shop/modules/cpgg/index.ts +++ b/src/plugins/commands/shop/modules/cpgg/index.ts @@ -1,7 +1,7 @@ import { CommandInteraction, - MessageActionRow, - MessageButton, + ActionRowBuilder, + ButtonBuilder, } from "discord.js"; import { v4 as uuidv4 } from "uuid"; import axios from "axios"; @@ -163,8 +163,8 @@ export default { const shopUrl = `${url}/store`; - const buttons = new MessageActionRow().addComponents( - new MessageButton() + const buttons = new ActionRowBuilder().addComponents( + new ButtonBuilder() .setLabel("Redeem it here") .setStyle("LINK") .setEmoji("🏦") diff --git a/src/plugins/commands/utility/modules/about/index.ts b/src/plugins/commands/utility/modules/about/index.ts index e3670b3..3dc1deb 100644 --- a/src/plugins/commands/utility/modules/about/index.ts +++ b/src/plugins/commands/utility/modules/about/index.ts @@ -1,8 +1,10 @@ // Dependencies import { CommandInteraction, - MessageActionRow, - MessageButton, + ActionRowBuilder, + ButtonBuilder, + ButtonStyle, + EmbedBuilder, } from "discord.js"; // Configurations @@ -22,51 +24,50 @@ export default { interaction.guild ); - const buttons = new MessageActionRow().addComponents( - new MessageButton() + const buttons = new ActionRowBuilder().addComponents( + new ButtonBuilder() .setLabel("Source Code") - .setStyle("LINK") + .setStyle(ButtonStyle.Link) .setEmoji("📄") .setURL("https://github.com/ZynerOrg/xyter"), - new MessageButton() + new ButtonBuilder() .setLabel("Documentation") - .setStyle("LINK") + .setStyle(ButtonStyle.Link) .setEmoji("📚") .setURL("https://xyter.zyner.org"), - new MessageButton() + new ButtonBuilder() .setLabel("Website") - .setStyle("LINK") + .setStyle(ButtonStyle.Link) .setEmoji("🌐") .setURL("https://zyner.org"), - new MessageButton() + new ButtonBuilder() .setLabel("Get Help") - .setStyle("LINK") + .setStyle(ButtonStyle.Link) .setEmoji("💬") .setURL("https://discord.zyner.org"), - new MessageButton() + new ButtonBuilder() .setLabel(`Hosted by ${process.env.BOT_HOSTER_NAME}`) - .setStyle("LINK") + .setStyle(ButtonStyle.Link) .setEmoji("⚒️") .setURL(`${process.env.BOT_HOSTER_URL}`) ); - const interactionEmbed = { - title: "[:tools:] About", - description: ` - **Xyter**'s goal is to provide a __privacy-friendly__ discord bot. - We created **Xyter** to **replace the mess** of having a dozen or so bots in __your__ community. - On top of this, you can also see our **source code** for **security** and **privacy** issues. - As well as making your own **fork** of the bot, you can also get **help** from our community. + const interactionEmbed = new EmbedBuilder() + .setColor(successColor) + .setTitle("[:tools:] About") + .setDescription( + ` +**Xyter**'s goal is to provide a __privacy-friendly__ discord bot. +We created **Xyter** to **replace the mess** of having a dozen or so bots in __your__ community. +On top of this, you can also see our **source code** for **security** and **privacy** issues. +As well as making your own **fork** of the bot, you can also get **help** from our community. + +Developed with ❤️ by **Zyner**, a non-profit project by teens. + ` + ) + .setTimestamp() + .setFooter({ text: footerText, iconURL: footerIcon }); - Developed with ❤️ by **Zyner**, a non-profit project by teens. - `, - color: successColor, - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }; await interaction.editReply({ embeds: [interactionEmbed], components: [buttons], diff --git a/src/plugins/commands/utility/modules/avatar/index.ts b/src/plugins/commands/utility/modules/avatar/index.ts index 24ab6c1..3d69414 100644 --- a/src/plugins/commands/utility/modules/avatar/index.ts +++ b/src/plugins/commands/utility/modules/avatar/index.ts @@ -1,6 +1,6 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; -import { CommandInteraction, MessageEmbed } from "discord.js"; +import { CommandInteraction, EmbedBuilder } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; export default { @@ -24,7 +24,7 @@ export default { const targetUser = userOption || interaction.user; - const embed = new MessageEmbed() + const embed = new EmbedBuilder() .setTitle("[:tools:] Avatar") .setTimestamp(new Date()) .setFooter({ text: footerText, iconURL: footerIcon }); diff --git a/src/plugins/commands/utility/modules/stats/index.ts b/src/plugins/commands/utility/modules/stats/index.ts index a2a8282..a90c289 100644 --- a/src/plugins/commands/utility/modules/stats/index.ts +++ b/src/plugins/commands/utility/modules/stats/index.ts @@ -1,7 +1,7 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import { CommandInteraction } from "discord.js"; +import { CommandInteraction, EmbedBuilder } from "discord.js"; export default { metadata: { guildOnly: false, ephemeral: false }, @@ -12,6 +12,7 @@ export default { const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild ); + const { client } = interaction; if (client?.uptime === null) return; let totalSeconds = client?.uptime / 1000; @@ -24,10 +25,12 @@ export default { const uptime = `${days} days, ${hours} hours, ${minutes} minutes and ${seconds} seconds`; - const interactionEmbed = { - title: ":hammer: Utilities - Stats", - description: "Below you can see a list of statistics about the bot.", - fields: [ + const interactionEmbed = new EmbedBuilder() + .setColor(successColor) + .setTitle("[:hammer:] Stats") + .setDescription("Below you can see a list of statistics about the bot.") + .setTimestamp() + .addFields( { name: "⏰ Latency", value: `${Date?.now() - interaction?.createdTimestamp} ms`, @@ -55,15 +58,10 @@ export default { 0 )}`, inline: true, - }, - ], - color: successColor, - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }; + } + ) + .setFooter({ text: footerText, iconURL: footerIcon }); + interaction?.editReply({ embeds: [interactionEmbed] }); }, }; diff --git a/src/plugins/events/guildMemberAdd/audits.ts b/src/plugins/events/guildMemberAdd/audits.ts index 0194c53..ab29c86 100644 --- a/src/plugins/events/guildMemberAdd/audits.ts +++ b/src/plugins/events/guildMemberAdd/audits.ts @@ -1,5 +1,5 @@ import logger from "../../../middlewares/logger"; -import { GuildMember, MessageEmbed } from "discord.js"; +import { GuildMember, EmbedBuilder, ChannelType } from "discord.js"; import guildSchema from "../../../models/guild"; @@ -21,11 +21,11 @@ export default { const embedConfig = await getEmbedConfig(guild); const channel = client.channels.cache.get(guildData.audits.channelId); - if (channel?.type !== "GUILD_TEXT") { + if (channel?.type !== ChannelType.GuildText) { throw new Error("Channel must be a text channel"); } - const embed = new MessageEmbed() + const embed = new EmbedBuilder() .setTimestamp(new Date()) .setAuthor({ name: "Member Joined", diff --git a/src/plugins/events/guildMemberAdd/joinMessage.ts b/src/plugins/events/guildMemberAdd/joinMessage.ts index 47f9043..c6abae8 100644 --- a/src/plugins/events/guildMemberAdd/joinMessage.ts +++ b/src/plugins/events/guildMemberAdd/joinMessage.ts @@ -1,4 +1,4 @@ -import { GuildMember, MessageEmbed, TextChannel } from "discord.js"; +import { GuildMember, EmbedBuilder, TextChannel } from "discord.js"; import guildSchema from "../../../models/guild"; @@ -27,7 +27,7 @@ export default { (channel as TextChannel).send({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setColor(successColor) .setTitle(`${member.user.username} has joined the server!`) .setThumbnail(member.user.displayAvatarURL()) diff --git a/src/plugins/events/guildMemberRemove/audits.ts b/src/plugins/events/guildMemberRemove/audits.ts index ee2a33c..52affa3 100644 --- a/src/plugins/events/guildMemberRemove/audits.ts +++ b/src/plugins/events/guildMemberRemove/audits.ts @@ -1,5 +1,5 @@ import logger from "../../../middlewares/logger"; -import { GuildMember, MessageEmbed } from "discord.js"; +import { GuildMember, EmbedBuilder, ChannelType } from "discord.js"; import guildSchema from "../../../models/guild"; @@ -21,11 +21,11 @@ export default { const embedConfig = await getEmbedConfig(guild); const channel = client.channels.cache.get(guildData.audits.channelId); - if (channel?.type !== "GUILD_TEXT") { + if (channel?.type !== ChannelType.GuildText) { throw new Error("Channel must be a text channel"); } - const embed = new MessageEmbed() + const embed = new EmbedBuilder() .setTimestamp(new Date()) .setAuthor({ name: "Member Left", diff --git a/src/plugins/events/guildMemberRemove/leaveMessage.ts b/src/plugins/events/guildMemberRemove/leaveMessage.ts index daae364..815e0f9 100644 --- a/src/plugins/events/guildMemberRemove/leaveMessage.ts +++ b/src/plugins/events/guildMemberRemove/leaveMessage.ts @@ -1,4 +1,4 @@ -import { GuildMember, MessageEmbed, TextChannel } from "discord.js"; +import { GuildMember, EmbedBuilder, TextChannel } from "discord.js"; import guildSchema from "../../../models/guild"; @@ -27,7 +27,7 @@ export default { (channel as TextChannel).send({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setColor(errorColor) .setTitle(`${member.user.username} has left the server!`) .setThumbnail(member.user.displayAvatarURL()) diff --git a/src/plugins/events/interactionCreate/audits.ts b/src/plugins/events/interactionCreate/audits.ts index dec6aeb..a6ce76c 100644 --- a/src/plugins/events/interactionCreate/audits.ts +++ b/src/plugins/events/interactionCreate/audits.ts @@ -1,12 +1,12 @@ import logger from "../../../middlewares/logger"; -import { Interaction, MessageEmbed, TextChannel } from "discord.js"; +import { BaseInteraction, EmbedBuilder, TextChannel } from "discord.js"; import guildSchema from "../../../models/guild"; import getEmbedConfig from "../../../helpers/getEmbedConfig"; export default { - execute: async (interaction: Interaction) => { + execute: async (interaction: BaseInteraction) => { if (interaction === null) return; if (interaction.guild === null) return; @@ -33,7 +33,7 @@ export default { (channel as TextChannel) .send({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setColor(successColor) .setDescription( ` diff --git a/src/plugins/events/interactionCreate/handlers/button/index.ts b/src/plugins/events/interactionCreate/handlers/button/index.ts index 3373f09..85ee639 100644 --- a/src/plugins/events/interactionCreate/handlers/button/index.ts +++ b/src/plugins/events/interactionCreate/handlers/button/index.ts @@ -1,10 +1,10 @@ // Dependencies -import { Interaction } from "discord.js"; +import { BaseInteraction } from "discord.js"; import deferReply from "../../../../../helpers/deferReply"; import * as cooldown from "../../../../../helpers/cooldown"; -export default async (interaction: Interaction) => { +export default async (interaction: BaseInteraction) => { if (!interaction.isButton()) return; const { guild, customId, memberPermissions } = interaction; diff --git a/src/plugins/events/interactionCreate/handlers/command/index.ts b/src/plugins/events/interactionCreate/handlers/command/index.ts index b6b30ec..797b6bd 100644 --- a/src/plugins/events/interactionCreate/handlers/command/index.ts +++ b/src/plugins/events/interactionCreate/handlers/command/index.ts @@ -1,11 +1,11 @@ // Dependencies -import { Interaction } from "discord.js"; +import { BaseInteraction } from "discord.js"; import deferReply from "../../../../../helpers/deferReply"; import getCommandMetadata from "../../../../../helpers/getCommandMetadata"; import * as cooldown from "../../../../../helpers/cooldown"; -export default async (interaction: Interaction) => { +export default async (interaction: BaseInteraction) => { if (!interaction.isCommand()) return; const { client, commandName } = interaction; @@ -28,7 +28,8 @@ export default async (interaction: Interaction) => { if (metadata.dmOnly && interaction.guild) throw new Error("This command is only available in DM"); - if (metadata.cooldown) await cooldown.command(interaction, metadata.cooldown); - + if (metadata.cooldown) { + await cooldown.command(interaction, metadata.cooldown); + } await currentCommand.execute(interaction); }; diff --git a/src/plugins/events/interactionCreate/handlers/index.ts b/src/plugins/events/interactionCreate/handlers/index.ts index 85f1e7a..186b3d1 100644 --- a/src/plugins/events/interactionCreate/handlers/index.ts +++ b/src/plugins/events/interactionCreate/handlers/index.ts @@ -1,9 +1,33 @@ -import { Interaction } from "discord.js"; +import { BaseInteraction, CommandInteraction, EmbedBuilder } from "discord.js"; +import getEmbedConfig from "../../../../helpers/getEmbedConfig"; +import capitalizeFirstLetter from "../../../../helpers/capitalizeFirstLetter"; +import logger from "../../../../middlewares/logger"; import button from "./button"; import command from "./command"; -export const execute = async (interaction: Interaction) => { +export const execute = async (interaction: BaseInteraction) => { await button(interaction); await command(interaction); }; + +export const handleCommandInteraction = async ( + interaction: CommandInteraction +) => { + const { errorColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); + + await command(interaction).catch(async (err) => { + return interaction.editReply({ + embeds: [ + new EmbedBuilder() + .setTitle(`[:x:] ${capitalizeFirstLetter(interaction.commandName)}`) + .setDescription(`${"``"}${err}${"``"}`) + .setColor(errorColor) + .setTimestamp(new Date()) + .setFooter({ text: footerText, iconURL: footerIcon }), + ], + }); + }); +}; diff --git a/src/plugins/events/interactionCreate/index.ts b/src/plugins/events/interactionCreate/index.ts index feb030e..3d78060 100644 --- a/src/plugins/events/interactionCreate/index.ts +++ b/src/plugins/events/interactionCreate/index.ts @@ -1,5 +1,10 @@ // 3rd party dependencies -import { CommandInteraction, MessageEmbed } from "discord.js"; +import { + BaseInteraction, + CommandInteraction, + EmbedBuilder, + InteractionType, +} from "discord.js"; // Dependencies import * as handlers from "./handlers"; @@ -14,35 +19,21 @@ export const options: IEventOptions = { type: "on", }; -export const execute = async (interaction: CommandInteraction) => { +export const execute = async (interaction: BaseInteraction) => { const { guild, id } = interaction; logger?.silly( `New interaction: ${id} in guild: ${guild?.name} (${guild?.id})` ); - const { errorColor, footerText, footerIcon } = await getEmbedConfig( - interaction.guild - ); - await audits.execute(interaction); - await handlers.execute(interaction).catch(async (err) => { - logger.debug(`${err}`); + switch (interaction.type) { + case InteractionType.ApplicationCommand: + await handlers.handleCommandInteraction(interaction); + break; - return interaction.editReply({ - embeds: [ - new MessageEmbed() - .setTitle( - `[:x:] ${capitalizeFirstLetter( - interaction.options.getSubcommand() - )}` - ) - .setDescription(`${"``"}${err}${"``"}`) - .setColor(errorColor) - .setTimestamp(new Date()) - .setFooter({ text: footerText, iconURL: footerIcon }), - ], - }); - }); + default: + logger?.error(`Unknown interaction type: ${interaction.type}`); + } }; diff --git a/src/plugins/events/messageCreate/modules/counters/index.ts b/src/plugins/events/messageCreate/modules/counters/index.ts index 6ff4af4..c99c030 100644 --- a/src/plugins/events/messageCreate/modules/counters/index.ts +++ b/src/plugins/events/messageCreate/modules/counters/index.ts @@ -1,4 +1,4 @@ -import { Message } from "discord.js"; +import { ChannelType, Message } from "discord.js"; import logger from "../../../../../middlewares/logger"; import counterSchema from "../../../../../models/counter"; @@ -9,7 +9,7 @@ export default { if (guild == null) return; if (author.bot) return; - if (channel?.type !== "GUILD_TEXT") return; + if (channel?.type !== ChannelType.GuildText) return; const messages = await message.channel.messages.fetch({ limit: 2 }); const lastMessage = messages.last(); diff --git a/src/plugins/events/messageCreate/modules/credits/index.ts b/src/plugins/events/messageCreate/modules/credits/index.ts index 711afa6..0d1ddcf 100644 --- a/src/plugins/events/messageCreate/modules/credits/index.ts +++ b/src/plugins/events/messageCreate/modules/credits/index.ts @@ -1,5 +1,5 @@ import logger from "../../../../../middlewares/logger"; -import { Message } from "discord.js"; +import { ChannelType, Message } from "discord.js"; import fetchUser from "../../../../../helpers/fetchUser"; import fetchGuild from "../../../../../helpers/fetchGuild"; @@ -12,7 +12,7 @@ export default { if (guild == null) return; if (author.bot) return; - if (channel?.type !== "GUILD_TEXT") return; + if (channel.type !== ChannelType.GuildText) return; const { id: guildId } = guild; const { id: userId } = author; @@ -22,11 +22,12 @@ export default { if (content.length < guildData.credits.minimumLength) return; - await cooldown.message( + const isOnCooldown = await cooldown.message( message, guildData.credits.timeout, "messageCreate-credits" ); + if (isOnCooldown) return; userData.credits += guildData.credits.rate; diff --git a/src/plugins/events/messageCreate/modules/points/index.ts b/src/plugins/events/messageCreate/modules/points/index.ts index 353c622..9750ddb 100644 --- a/src/plugins/events/messageCreate/modules/points/index.ts +++ b/src/plugins/events/messageCreate/modules/points/index.ts @@ -5,25 +5,26 @@ import * as cooldown from "../../../../../helpers/cooldown"; import fetchUser from "../../../../../helpers/fetchUser"; import fetchGuild from "../../../../../helpers/fetchGuild"; -import { Message } from "discord.js"; +import { ChannelType, Message } from "discord.js"; export default { execute: async (message: Message) => { const { guild, author, content, channel } = message; if (guild == null) return; if (author.bot) return; - if (channel?.type !== "GUILD_TEXT") return; + if (channel.type !== ChannelType.GuildText) return; const guildData = await fetchGuild(guild); const userData = await fetchUser(author, guild); if (content.length < guildData.credits.minimumLength) return; - await cooldown.message( + const isOnCooldown = await cooldown.message( message, guildData.credits.timeout, "messageCreate-points" ); + if (isOnCooldown) return; userData.points += guildData.points.rate; diff --git a/src/plugins/events/messageDelete/audits.ts b/src/plugins/events/messageDelete/audits.ts index 0e1b7f6..3ce3a37 100644 --- a/src/plugins/events/messageDelete/audits.ts +++ b/src/plugins/events/messageDelete/audits.ts @@ -1,5 +1,5 @@ import logger from "../../../middlewares/logger"; -import { Message, MessageEmbed, TextChannel } from "discord.js"; +import { Message, EmbedBuilder, TextChannel } from "discord.js"; import guildSchema from "../../../models/guild"; @@ -33,7 +33,7 @@ export default { (channel as TextChannel) .send({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setColor(successColor) .setAuthor({ name: message.author.username, diff --git a/src/plugins/events/messageUpdate/audits.ts b/src/plugins/events/messageUpdate/audits.ts index a9adeec..b34a85f 100644 --- a/src/plugins/events/messageUpdate/audits.ts +++ b/src/plugins/events/messageUpdate/audits.ts @@ -1,6 +1,6 @@ /* eslint-disable no-loops/no-loops */ import logger from "../../../middlewares/logger"; -import { Message, MessageEmbed, TextChannel } from "discord.js"; +import { Message, EmbedBuilder, TextChannel } from "discord.js"; import guildSchema from "../../../models/guild"; @@ -36,7 +36,7 @@ export default { (channel as TextChannel) .send({ embeds: [ - new MessageEmbed() + new EmbedBuilder() .setColor(successColor) .setAuthor({ name: newMessage.author.username, From 741c33f41d5d5bb03769e8de595df347e178cdd9 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Thu, 25 Aug 2022 11:52:58 +0200 Subject: [PATCH 040/215] =?UTF-8?q?=F0=9F=94=A7=20organize=20imports=20on?= =?UTF-8?q?=20save?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.vscode/settings.json b/.vscode/settings.json index b38ac9d..8a724b8 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -14,6 +14,9 @@ "editor.wordWrapColumn": 100, "files.eol": "\n", "files.trimTrailingWhitespace": true, + "editor.codeActionsOnSave": { + "source.organizeImports": true + }, "cSpell.customDictionaries": { "custom-dictionary-workspace": { "name": "custom-dictionary-workspace", From 6a7f6f33a68f3c9abe504b0dabd9ee7db1014e19 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Thu, 25 Aug 2022 11:53:05 +0200 Subject: [PATCH 041/215] =?UTF-8?q?=E2=9A=B0=EF=B8=8F=20remove=20unused=20?= =?UTF-8?q?imports?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.ts | 2 +- .../commands/config/modules/audits/index.ts | 2 +- .../commands/config/modules/cpgg/index.ts | 6 +- .../commands/config/modules/credits/index.ts | 4 +- .../embeds/components/getValues/index.ts | 8 +- .../commands/config/modules/embeds/index.ts | 7 +- src/plugins/commands/config/modules/index.ts | 6 +- .../commands/config/modules/points/index.ts | 3 +- .../commands/config/modules/shop/index.ts | 4 +- .../commands/config/modules/welcome/index.ts | 4 +- src/plugins/commands/counters/index.ts | 4 +- .../commands/counters/modules/view/index.ts | 2 +- src/plugins/commands/credits/index.ts | 4 +- .../commands/credits/modules/balance/index.ts | 2 +- .../commands/credits/modules/gift/index.ts | 6 +- .../commands/credits/modules/top/index.ts | 2 +- .../commands/credits/modules/work/index.ts | 4 +- src/plugins/commands/dns/index.ts | 4 +- .../commands/dns/modules/lookup/index.ts | 4 +- src/plugins/commands/fun/index.ts | 4 +- .../commands/fun/modules/meme/index.ts | 5 +- src/plugins/commands/manage/index.ts | 4 +- .../commands/manage/modules/counters/index.ts | 2 +- .../modules/counters/modules/add/index.ts | 10 +- .../modules/counters/modules/remove/index.ts | 4 +- .../commands/manage/modules/credits/index.ts | 4 +- .../modules/credits/modules/give/index.ts | 4 +- .../modules/credits/modules/giveaway/index.ts | 12 +- .../manage/modules/credits/modules/index.ts | 2 +- .../modules/credits/modules/set/index.ts | 5 +- .../modules/credits/modules/take/index.ts | 4 +- .../modules/credits/modules/transfer/index.ts | 4 +- src/plugins/commands/moderation/index.ts | 4 +- .../moderation/modules/prune/index.ts | 7 +- src/plugins/commands/profile/index.ts | 4 +- .../commands/profile/modules/view/index.ts | 31 +-- src/plugins/commands/reputation/index.ts | 4 +- .../give/components/noSelfReputation.ts | 1 + .../commands/reputation/modules/give/index.ts | 32 ++- src/plugins/commands/shop/index.ts | 4 +- .../commands/shop/modules/cpgg/index.ts | 236 ++++++++---------- .../commands/shop/modules/roles/index.ts | 30 +-- .../shop/modules/roles/modules/buy/index.ts | 70 ++---- .../modules/roles/modules/cancel/index.ts | 69 ++--- src/plugins/commands/utility/index.ts | 4 +- .../commands/utility/modules/about/index.ts | 2 +- .../commands/utility/modules/avatar/index.ts | 2 +- src/plugins/commands/utility/modules/index.ts | 4 +- .../commands/utility/modules/ping/index.ts | 23 +- src/types/common/environment.d.ts | 2 +- 50 files changed, 268 insertions(+), 403 deletions(-) diff --git a/src/index.ts b/src/index.ts index 4f1efba..ec86855 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ -import "dotenv/config"; import { Client, Collection, GatewayIntentBits } from "discord.js"; // discord.js +import "dotenv/config"; import * as managers from "./managers"; diff --git a/src/plugins/commands/config/modules/audits/index.ts b/src/plugins/commands/config/modules/audits/index.ts index b7f14ad..b440562 100644 --- a/src/plugins/commands/config/modules/audits/index.ts +++ b/src/plugins/commands/config/modules/audits/index.ts @@ -8,9 +8,9 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; import logger from "../../../../../middlewares/logger"; -import guildSchema from "../../../../../models/guild"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChannelType } from "discord-api-types/v10"; +import guildSchema from "../../../../../models/guild"; export default { metadata: { diff --git a/src/plugins/commands/config/modules/cpgg/index.ts b/src/plugins/commands/config/modules/cpgg/index.ts index 3cc4731..80caa14 100644 --- a/src/plugins/commands/config/modules/cpgg/index.ts +++ b/src/plugins/commands/config/modules/cpgg/index.ts @@ -1,8 +1,6 @@ import { ChatInputCommandInteraction, - CommandInteraction, EmbedBuilder, - Permissions, PermissionsBitField, } from "discord.js"; @@ -10,9 +8,9 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; import logger from "../../../../../middlewares/logger"; -import apiSchema from "../../../../../models/api"; -import encryption from "../../../../../handlers/encryption"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import encryption from "../../../../../handlers/encryption"; +import apiSchema from "../../../../../models/api"; export default { metadata: { diff --git a/src/plugins/commands/config/modules/credits/index.ts b/src/plugins/commands/config/modules/credits/index.ts index 3d67301..4535d74 100644 --- a/src/plugins/commands/config/modules/credits/index.ts +++ b/src/plugins/commands/config/modules/credits/index.ts @@ -1,8 +1,6 @@ import { ChatInputCommandInteraction, - CommandInteraction, EmbedBuilder, - Permissions, PermissionsBitField, } from "discord.js"; @@ -10,8 +8,8 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; import logger from "../../../../../middlewares/logger"; -import guildSchema from "../../../../../models/guild"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import guildSchema from "../../../../../models/guild"; export default { metadata: { diff --git a/src/plugins/commands/config/modules/embeds/components/getValues/index.ts b/src/plugins/commands/config/modules/embeds/components/getValues/index.ts index f8decdd..bc49e1f 100644 --- a/src/plugins/commands/config/modules/embeds/components/getValues/index.ts +++ b/src/plugins/commands/config/modules/embeds/components/getValues/index.ts @@ -1,10 +1,6 @@ -import { - ChatInputCommandInteraction, - ColorResolvable, - CommandInteraction, -} from "discord.js"; -import guildSchema from "../../../../../../../models/guild"; +import { ChatInputCommandInteraction, ColorResolvable } from "discord.js"; import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; +import guildSchema from "../../../../../../../models/guild"; export default async (interaction: ChatInputCommandInteraction) => { const { options, guild } = interaction; diff --git a/src/plugins/commands/config/modules/embeds/index.ts b/src/plugins/commands/config/modules/embeds/index.ts index f868f49..3e667c6 100644 --- a/src/plugins/commands/config/modules/embeds/index.ts +++ b/src/plugins/commands/config/modules/embeds/index.ts @@ -1,16 +1,11 @@ import { - ColorResolvable, ChatInputCommandInteraction, EmbedBuilder, - Permissions, PermissionsBitField, } from "discord.js"; -import logger from "../../../../../middlewares/logger"; - -import guildSchema from "../../../../../models/guild"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; +import guildSchema from "../../../../../models/guild"; import getValues from "./components/getValues"; export default { diff --git a/src/plugins/commands/config/modules/index.ts b/src/plugins/commands/config/modules/index.ts index 45d8a9f..7d8ba77 100644 --- a/src/plugins/commands/config/modules/index.ts +++ b/src/plugins/commands/config/modules/index.ts @@ -1,9 +1,9 @@ import audits from "./audits"; -import credits from "./credits"; -import points from "./points"; import cpgg from "./cpgg"; +import credits from "./credits"; +import embeds from "./embeds"; +import points from "./points"; import shop from "./shop"; import welcome from "./welcome"; -import embeds from "./embeds"; export default { audits, credits, points, cpgg, shop, welcome, embeds }; diff --git a/src/plugins/commands/config/modules/points/index.ts b/src/plugins/commands/config/modules/points/index.ts index e1a0704..9b73eb1 100644 --- a/src/plugins/commands/config/modules/points/index.ts +++ b/src/plugins/commands/config/modules/points/index.ts @@ -1,7 +1,6 @@ import { ChatInputCommandInteraction, EmbedBuilder, - Permissions, PermissionsBitField, } from "discord.js"; @@ -9,8 +8,8 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; import logger from "../../../../../middlewares/logger"; -import guildSchema from "../../../../../models/guild"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import guildSchema from "../../../../../models/guild"; export default { metadata: { diff --git a/src/plugins/commands/config/modules/shop/index.ts b/src/plugins/commands/config/modules/shop/index.ts index 8624b26..0e10d9f 100644 --- a/src/plugins/commands/config/modules/shop/index.ts +++ b/src/plugins/commands/config/modules/shop/index.ts @@ -1,8 +1,6 @@ import { ChatInputCommandInteraction, - CommandInteraction, EmbedBuilder, - Permissions, PermissionsBitField, } from "discord.js"; @@ -10,8 +8,8 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; import logger from "../../../../../middlewares/logger"; -import guildSchema from "../../../../../models/guild"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import guildSchema from "../../../../../models/guild"; export default { metadata: { diff --git a/src/plugins/commands/config/modules/welcome/index.ts b/src/plugins/commands/config/modules/welcome/index.ts index cd55b16..919711e 100644 --- a/src/plugins/commands/config/modules/welcome/index.ts +++ b/src/plugins/commands/config/modules/welcome/index.ts @@ -1,8 +1,6 @@ import { ChatInputCommandInteraction, - CommandInteraction, EmbedBuilder, - Permissions, PermissionsBitField, } from "discord.js"; @@ -10,9 +8,9 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; import logger from "../../../../../middlewares/logger"; -import guildSchema from "../../../../../models/guild"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChannelType } from "discord-api-types/v10"; +import guildSchema from "../../../../../models/guild"; export default { metadata: { diff --git a/src/plugins/commands/counters/index.ts b/src/plugins/commands/counters/index.ts index 9626b99..eb1e4f3 100644 --- a/src/plugins/commands/counters/index.ts +++ b/src/plugins/commands/counters/index.ts @@ -1,5 +1,5 @@ -import { CommandInteraction } from "discord.js"; import { SlashCommandBuilder } from "@discordjs/builders"; +import { ChatInputCommandInteraction } from "discord.js"; import modules from "../../commands/counters/modules"; @@ -11,7 +11,7 @@ export const builder = new SlashCommandBuilder() export const moduleData = modules; -export const execute = async (interaction: CommandInteraction) => { +export const execute = async (interaction: ChatInputCommandInteraction) => { if (interaction.options.getSubcommand() === "view") { await modules.view.execute(interaction); } diff --git a/src/plugins/commands/counters/modules/view/index.ts b/src/plugins/commands/counters/modules/view/index.ts index 695008d..81e1147 100644 --- a/src/plugins/commands/counters/modules/view/index.ts +++ b/src/plugins/commands/counters/modules/view/index.ts @@ -1,8 +1,8 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; -import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChannelType } from "discord-api-types/v10"; +import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js"; import counterSchema from "../../../../../models/counter"; diff --git a/src/plugins/commands/credits/index.ts b/src/plugins/commands/credits/index.ts index 6af41f7..4e30065 100644 --- a/src/plugins/commands/credits/index.ts +++ b/src/plugins/commands/credits/index.ts @@ -1,5 +1,5 @@ import { SlashCommandBuilder } from "@discordjs/builders"; -import { CommandInteraction } from "discord.js"; +import { ChatInputCommandInteraction } from "discord.js"; import logger from "../../../middlewares/logger"; import modules from "./modules"; @@ -15,7 +15,7 @@ export const builder = new SlashCommandBuilder() export const moduleData = modules; -export const execute = async (interaction: CommandInteraction) => { +export const execute = async (interaction: ChatInputCommandInteraction) => { const { options } = interaction; switch (options.getSubcommand()) { diff --git a/src/plugins/commands/credits/modules/balance/index.ts b/src/plugins/commands/credits/modules/balance/index.ts index 0bef3a7..57afd75 100644 --- a/src/plugins/commands/credits/modules/balance/index.ts +++ b/src/plugins/commands/credits/modules/balance/index.ts @@ -1,7 +1,7 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; -import { CommandInteraction, EmbedBuilder } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import { CommandInteraction, EmbedBuilder } from "discord.js"; import logger from "../../../../../middlewares/logger"; import fetchUser from "../../../../../helpers/fetchUser"; diff --git a/src/plugins/commands/credits/modules/gift/index.ts b/src/plugins/commands/credits/modules/gift/index.ts index 7272ec2..fba20f1 100644 --- a/src/plugins/commands/credits/modules/gift/index.ts +++ b/src/plugins/commands/credits/modules/gift/index.ts @@ -1,5 +1,5 @@ // Dependencies -import { CommandInteraction, EmbedBuilder } from "discord.js"; +import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js"; // Configurations import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; @@ -10,8 +10,8 @@ import logger from "../../../../../middlewares/logger"; import mongoose from "mongoose"; // Models -import fetchUser from "../../../../../helpers/fetchUser"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import fetchUser from "../../../../../helpers/fetchUser"; // Function export default { @@ -37,7 +37,7 @@ export default { option.setName("reason").setDescription("Your reason.") ); }, - execute: async (interaction: CommandInteraction) => { + execute: async (interaction: ChatInputCommandInteraction) => { const { errorColor, successColor, footerText, footerIcon } = await getEmbedConfig(interaction.guild); const { options, user, guild, client } = interaction; diff --git a/src/plugins/commands/credits/modules/top/index.ts b/src/plugins/commands/credits/modules/top/index.ts index 53b386e..6c3bec7 100644 --- a/src/plugins/commands/credits/modules/top/index.ts +++ b/src/plugins/commands/credits/modules/top/index.ts @@ -1,7 +1,7 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; -import { CommandInteraction, EmbedBuilder } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import { CommandInteraction, EmbedBuilder } from "discord.js"; import logger from "../../../../../middlewares/logger"; import userSchema, { IUser } from "../../../../../models/user"; diff --git a/src/plugins/commands/credits/modules/work/index.ts b/src/plugins/commands/credits/modules/work/index.ts index 185a8d5..5354752 100644 --- a/src/plugins/commands/credits/modules/work/index.ts +++ b/src/plugins/commands/credits/modules/work/index.ts @@ -1,7 +1,7 @@ // Dependencies -import { CommandInteraction, EmbedBuilder } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import Chance from "chance"; +import { CommandInteraction, EmbedBuilder } from "discord.js"; // Configurations import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; @@ -13,8 +13,8 @@ import logger from "../../../../../middlewares/logger"; import * as cooldown from "../../../../../helpers/cooldown"; // Helpers -import fetchUser from "../../../../../helpers/fetchUser"; import fetchGuild from "../../../../../helpers/fetchGuild"; +import fetchUser from "../../../../../helpers/fetchUser"; export default { metadata: { guildOnly: true, ephemeral: true }, diff --git a/src/plugins/commands/dns/index.ts b/src/plugins/commands/dns/index.ts index ee623ec..abfb718 100644 --- a/src/plugins/commands/dns/index.ts +++ b/src/plugins/commands/dns/index.ts @@ -1,5 +1,5 @@ import { SlashCommandBuilder } from "@discordjs/builders"; -import { CommandInteraction } from "discord.js"; +import { ChatInputCommandInteraction } from "discord.js"; import modules from "./modules"; export const moduleData = modules; @@ -10,7 +10,7 @@ export const builder = new SlashCommandBuilder() .addSubcommand(modules.lookup.builder); -export const execute = async (interaction: CommandInteraction) => { +export const execute = async (interaction: ChatInputCommandInteraction) => { switch (interaction.options.getSubcommand()) { case "lookup": return modules.lookup.execute(interaction); diff --git a/src/plugins/commands/dns/modules/lookup/index.ts b/src/plugins/commands/dns/modules/lookup/index.ts index f3d443d..54635e1 100644 --- a/src/plugins/commands/dns/modules/lookup/index.ts +++ b/src/plugins/commands/dns/modules/lookup/index.ts @@ -1,5 +1,5 @@ import axios from "axios"; -import { CommandInteraction, EmbedBuilder } from "discord.js"; +import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js"; import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; @@ -21,7 +21,7 @@ export default { .setRequired(true) ); }, - execute: async (interaction: CommandInteraction) => { + execute: async (interaction: ChatInputCommandInteraction) => { const { errorColor, successColor, footerText, footerIcon } = await getEmbedConfig(interaction.guild); const embedTitle = "[:hammer:] Utility (Lookup)"; diff --git a/src/plugins/commands/fun/index.ts b/src/plugins/commands/fun/index.ts index 3c546ed..7b0d4ba 100644 --- a/src/plugins/commands/fun/index.ts +++ b/src/plugins/commands/fun/index.ts @@ -1,5 +1,5 @@ import { SlashCommandBuilder } from "@discordjs/builders"; -import { CommandInteraction } from "discord.js"; +import { ChatInputCommandInteraction } from "discord.js"; import logger from "../../../middlewares/logger"; import modules from "../../commands/fun/modules"; @@ -12,7 +12,7 @@ export const builder = new SlashCommandBuilder() export const moduleData = modules; -export const execute = async (interaction: CommandInteraction) => { +export const execute = async (interaction: ChatInputCommandInteraction) => { const { options } = interaction; if (options.getSubcommand() === "meme") { diff --git a/src/plugins/commands/fun/modules/meme/index.ts b/src/plugins/commands/fun/modules/meme/index.ts index a374ee9..9ad5a48 100644 --- a/src/plugins/commands/fun/modules/meme/index.ts +++ b/src/plugins/commands/fun/modules/meme/index.ts @@ -1,8 +1,7 @@ -import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; - +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import axios from "axios"; import { CommandInteraction, EmbedBuilder } from "discord.js"; -import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; export default { metadata: { guildOnly: false, ephemeral: false, cooldown: 15 }, diff --git a/src/plugins/commands/manage/index.ts b/src/plugins/commands/manage/index.ts index 1b61f39..01b6508 100644 --- a/src/plugins/commands/manage/index.ts +++ b/src/plugins/commands/manage/index.ts @@ -1,6 +1,6 @@ //Dependencies import { SlashCommandBuilder } from "@discordjs/builders"; -import { CommandInteraction } from "discord.js"; +import { ChatInputCommandInteraction } from "discord.js"; // Groups import modules from "../../commands/manage/modules"; @@ -14,7 +14,7 @@ export const builder = new SlashCommandBuilder() .addSubcommandGroup(modules.counters.builder) .addSubcommandGroup(modules.credits.builder); -export const execute = async (interaction: CommandInteraction) => { +export const execute = async (interaction: ChatInputCommandInteraction) => { // Destructure const { options } = interaction; diff --git a/src/plugins/commands/manage/modules/counters/index.ts b/src/plugins/commands/manage/modules/counters/index.ts index a6f351d..04580e5 100644 --- a/src/plugins/commands/manage/modules/counters/index.ts +++ b/src/plugins/commands/manage/modules/counters/index.ts @@ -1,6 +1,6 @@ // Dependencies import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders"; -import { ChatInputCommandInteraction, CommandInteraction } from "discord.js"; +import { ChatInputCommandInteraction } from "discord.js"; import logger from "../../../../../middlewares/logger"; diff --git a/src/plugins/commands/manage/modules/counters/modules/add/index.ts b/src/plugins/commands/manage/modules/counters/modules/add/index.ts index c1b022f..2b95f9a 100644 --- a/src/plugins/commands/manage/modules/counters/modules/add/index.ts +++ b/src/plugins/commands/manage/modules/counters/modules/add/index.ts @@ -1,11 +1,11 @@ // Dependencies -import { - EmbedBuilder, - ChatInputCommandInteraction, - PermissionsBitField, -} from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChannelType } from "discord-api-types/v10"; +import { + ChatInputCommandInteraction, + EmbedBuilder, + PermissionsBitField, +} from "discord.js"; // Configurations import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; diff --git a/src/plugins/commands/manage/modules/counters/modules/remove/index.ts b/src/plugins/commands/manage/modules/counters/modules/remove/index.ts index 018ae94..096fda7 100644 --- a/src/plugins/commands/manage/modules/counters/modules/remove/index.ts +++ b/src/plugins/commands/manage/modules/counters/modules/remove/index.ts @@ -1,9 +1,7 @@ // Dependencies import { ChatInputCommandInteraction, - CommandInteraction, EmbedBuilder, - Permissions, PermissionsBitField, } from "discord.js"; @@ -14,9 +12,9 @@ import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; import logger from "../../../../../../../middlewares/logger"; // Models -import counterSchema from "../../../../../../../models/counter"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChannelType } from "discord-api-types/v10"; +import counterSchema from "../../../../../../../models/counter"; // Function export default { diff --git a/src/plugins/commands/manage/modules/credits/index.ts b/src/plugins/commands/manage/modules/credits/index.ts index 92efd12..0ed9837 100644 --- a/src/plugins/commands/manage/modules/credits/index.ts +++ b/src/plugins/commands/manage/modules/credits/index.ts @@ -1,5 +1,5 @@ -import { CommandInteraction } from "discord.js"; import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders"; +import { ChatInputCommandInteraction } from "discord.js"; import modules from "./modules"; @@ -16,7 +16,7 @@ export const builder = (group: SlashCommandSubcommandGroupBuilder) => { .addSubcommand(modules.giveaway.builder); }; -export const execute = async (interaction: CommandInteraction) => { +export const execute = async (interaction: ChatInputCommandInteraction) => { switch (interaction.options.getSubcommand()) { case "give": return modules.give.execute(interaction); diff --git a/src/plugins/commands/manage/modules/credits/modules/give/index.ts b/src/plugins/commands/manage/modules/credits/modules/give/index.ts index 2eadb62..e797afd 100644 --- a/src/plugins/commands/manage/modules/credits/modules/give/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/give/index.ts @@ -1,12 +1,10 @@ // Dependencies +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction, - CommandInteraction, EmbedBuilder, - Permissions, PermissionsBitField, } from "discord.js"; -import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Configurations import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; diff --git a/src/plugins/commands/manage/modules/credits/modules/giveaway/index.ts b/src/plugins/commands/manage/modules/credits/modules/giveaway/index.ts index 6d8decc..246b00a 100644 --- a/src/plugins/commands/manage/modules/credits/modules/giveaway/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/giveaway/index.ts @@ -1,18 +1,16 @@ // Dependencies +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import axios from "axios"; import { - CommandInteraction, ActionRowBuilder, ButtonBuilder, - EmbedBuilder, - Permissions, - PermissionsBitField, ChatInputCommandInteraction, + EmbedBuilder, + PermissionsBitField, } from "discord.js"; -import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { v4 as uuidv4 } from "uuid"; -import axios from "axios"; -import apiSchema from "../../../../../../../models/api"; import encryption from "../../../../../../../handlers/encryption"; +import apiSchema from "../../../../../../../models/api"; // Configurations import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; diff --git a/src/plugins/commands/manage/modules/credits/modules/index.ts b/src/plugins/commands/manage/modules/credits/modules/index.ts index 96acc29..c82650d 100644 --- a/src/plugins/commands/manage/modules/credits/modules/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/index.ts @@ -1,7 +1,7 @@ import give from "./give"; +import giveaway from "./giveaway"; import set from "./set"; import take from "./take"; import transfer from "./transfer"; -import giveaway from "./giveaway"; export default { give, set, take, transfer, giveaway }; diff --git a/src/plugins/commands/manage/modules/credits/modules/set/index.ts b/src/plugins/commands/manage/modules/credits/modules/set/index.ts index 57de608..9e2a63c 100644 --- a/src/plugins/commands/manage/modules/credits/modules/set/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/set/index.ts @@ -1,8 +1,7 @@ // Dependencies import { - CommandInteraction, + ChatInputCommandInteraction, EmbedBuilder, - Permissions, PermissionsBitField, } from "discord.js"; @@ -15,8 +14,8 @@ import logger from "../../../../../../../middlewares/logger"; // Helpers // Models -import fetchUser from "../../../../../../../helpers/fetchUser"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import fetchUser from "../../../../../../../helpers/fetchUser"; // Function export default { diff --git a/src/plugins/commands/manage/modules/credits/modules/take/index.ts b/src/plugins/commands/manage/modules/credits/modules/take/index.ts index b2dae44..707a149 100644 --- a/src/plugins/commands/manage/modules/credits/modules/take/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/take/index.ts @@ -1,9 +1,7 @@ // Dependencies import { ChatInputCommandInteraction, - CommandInteraction, EmbedBuilder, - Permissions, PermissionsBitField, } from "discord.js"; @@ -17,8 +15,8 @@ import logger from "../../../../../../../middlewares/logger"; import pluralize from "../../../../../../../helpers/pluralize"; // Models -import fetchUser from "../../../../../../../helpers/fetchUser"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import fetchUser from "../../../../../../../helpers/fetchUser"; // Function export default { diff --git a/src/plugins/commands/manage/modules/credits/modules/transfer/index.ts b/src/plugins/commands/manage/modules/credits/modules/transfer/index.ts index 0108f26..e8a1c00 100644 --- a/src/plugins/commands/manage/modules/credits/modules/transfer/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/transfer/index.ts @@ -1,9 +1,7 @@ // Dependencies import { ChatInputCommandInteraction, - CommandInteraction, EmbedBuilder, - Permissions, PermissionsBitField, } from "discord.js"; @@ -16,8 +14,8 @@ import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; import logger from "../../../../../../../middlewares/logger"; // Models -import fetchUser from "../../../../../../../helpers/fetchUser"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import fetchUser from "../../../../../../../helpers/fetchUser"; // Function export default { diff --git a/src/plugins/commands/moderation/index.ts b/src/plugins/commands/moderation/index.ts index 73b4994..c9a2bec 100644 --- a/src/plugins/commands/moderation/index.ts +++ b/src/plugins/commands/moderation/index.ts @@ -1,5 +1,5 @@ import { SlashCommandBuilder } from "@discordjs/builders"; -import { CommandInteraction } from "discord.js"; +import { ChatInputCommandInteraction } from "discord.js"; import modules from "./modules"; export const moduleData = modules; @@ -10,7 +10,7 @@ export const builder = new SlashCommandBuilder() .addSubcommand(modules.prune.builder); -export const execute = async (interaction: CommandInteraction) => { +export const execute = async (interaction: ChatInputCommandInteraction) => { switch (interaction.options.getSubcommand()) { case "prune": return modules.prune.execute(interaction); diff --git a/src/plugins/commands/moderation/modules/prune/index.ts b/src/plugins/commands/moderation/modules/prune/index.ts index 9745ca0..8abc31b 100644 --- a/src/plugins/commands/moderation/modules/prune/index.ts +++ b/src/plugins/commands/moderation/modules/prune/index.ts @@ -2,9 +2,7 @@ import { ChannelType, ChatInputCommandInteraction, - CommandInteraction, EmbedBuilder, - Permissions, PermissionsBitField, } from "discord.js"; @@ -36,8 +34,9 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { - const { errorColor, successColor, footerText, footerIcon } = - await getEmbedConfig(interaction.guild); + const { errorColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); const count = interaction.options.getInteger("count"); if (count == null) return; diff --git a/src/plugins/commands/profile/index.ts b/src/plugins/commands/profile/index.ts index eeec469..3a9305e 100644 --- a/src/plugins/commands/profile/index.ts +++ b/src/plugins/commands/profile/index.ts @@ -1,6 +1,6 @@ // Dependencies import { SlashCommandBuilder } from "@discordjs/builders"; -import { CommandInteraction } from "discord.js"; +import { ChatInputCommandInteraction } from "discord.js"; // Modules import modules from "../../commands/profile/modules"; @@ -16,7 +16,7 @@ export const builder = new SlashCommandBuilder() .setDescription("Check a profile.") .addSubcommand(modules.view.builder); -export const execute = async (interaction: CommandInteraction) => { +export const execute = async (interaction: ChatInputCommandInteraction) => { const { options } = interaction; if (options?.getSubcommand() === "view") { diff --git a/src/plugins/commands/profile/modules/view/index.ts b/src/plugins/commands/profile/modules/view/index.ts index bee47bc..fe4474b 100644 --- a/src/plugins/commands/profile/modules/view/index.ts +++ b/src/plugins/commands/profile/modules/view/index.ts @@ -1,5 +1,5 @@ // Dependencies -import { CommandInteraction } from "discord.js"; +import { CommandInteraction, EmbedBuilder } from "discord.js"; // Configurations import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; @@ -7,8 +7,8 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; // Models import fetchUser from "../../../../../helpers/fetchUser"; -import logger from "../../../../../middlewares/logger"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import logger from "../../../../../middlewares/logger"; // Function export default { @@ -24,7 +24,7 @@ export default { }, execute: async (interaction: CommandInteraction) => { - const { successColor, footerText, footerIcon } = await getEmbedConfig( + const { errorColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild ); // Destructure const { client, options, user, guild } = interaction; @@ -44,14 +44,12 @@ export default { // User Information const userObj = await fetchUser(discordUser, guild); - // Embed object - const embed = { - author: { + const embed = new EmbedBuilder() + .setAuthor({ name: `${discordUser?.username}#${discordUser?.discriminator}`, - icon_url: discordUser?.displayAvatarURL(), - }, - color: successColor, - fields: [ + iconURL: discordUser?.displayAvatarURL(), + }) + .addFields( { name: `:dollar: Credits`, value: `${userObj?.credits || "Not found"}`, @@ -76,14 +74,11 @@ export default { name: `:rainbow_flag: Language`, value: `${userObj?.language || "Not found"}`, inline: true, - }, - ], - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }; + } + ) + .setTimestamp() + .setColor(errorColor) + .setFooter({ text: footerText, iconURL: footerIcon }); // Return interaction reply return interaction?.editReply({ embeds: [embed] }); diff --git a/src/plugins/commands/reputation/index.ts b/src/plugins/commands/reputation/index.ts index d667343..3a4fd77 100644 --- a/src/plugins/commands/reputation/index.ts +++ b/src/plugins/commands/reputation/index.ts @@ -1,6 +1,6 @@ // Dependencies import { SlashCommandBuilder } from "@discordjs/builders"; -import { CommandInteraction } from "discord.js"; +import { ChatInputCommandInteraction } from "discord.js"; // Modules import modules from "./modules"; @@ -15,7 +15,7 @@ export const builder = new SlashCommandBuilder() .setDescription("Manage reputation.") .addSubcommand(modules.give.builder); -export const execute = async (interaction: CommandInteraction) => { +export const execute = async (interaction: ChatInputCommandInteraction) => { if (interaction.options.getSubcommand() === "give") { await modules.give.execute(interaction); } diff --git a/src/plugins/commands/reputation/modules/give/components/noSelfReputation.ts b/src/plugins/commands/reputation/modules/give/components/noSelfReputation.ts index f6a6778..dc0be04 100644 --- a/src/plugins/commands/reputation/modules/give/components/noSelfReputation.ts +++ b/src/plugins/commands/reputation/modules/give/components/noSelfReputation.ts @@ -1,4 +1,5 @@ import { User } from "discord.js"; + export default async (to: User | null, from: User | null) => { if (from?.id === to?.id) { throw new Error("You cannot give reputation to yourself."); diff --git a/src/plugins/commands/reputation/modules/give/index.ts b/src/plugins/commands/reputation/modules/give/index.ts index 1eb8c0b..7faa784 100644 --- a/src/plugins/commands/reputation/modules/give/index.ts +++ b/src/plugins/commands/reputation/modules/give/index.ts @@ -1,9 +1,9 @@ -import { CommandInteraction } from "discord.js"; +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js"; +import * as cooldown from "../../../../../helpers/cooldown"; +import fetchUser from "../../../../../helpers/fetchUser"; import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; import logger from "../../../../../middlewares/logger"; -import fetchUser from "../../../../../helpers/fetchUser"; -import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import * as cooldown from "../../../../../helpers/cooldown"; import noSelfReputation from "./components/noSelfReputation"; export default { @@ -33,7 +33,7 @@ export default { ) ); }, - execute: async (interaction: CommandInteraction) => { + execute: async (interaction: ChatInputCommandInteraction) => { const { options, user, guild } = interaction; const { successColor, footerText, footerIcon } = await getEmbedConfig( @@ -68,19 +68,17 @@ export default { await userObj.save().then(async () => { logger.silly(`User reputation has been updated`); + const interactionEmbed = new EmbedBuilder() + .setTitle("[:loudspeaker:] Give") + .setDescription( + `You have given a ${optionType} repute to ${optionTarget}` + ) + .setTimestamp() + .setColor(successColor) + .setFooter({ text: footerText, iconURL: footerIcon }); + await interaction.editReply({ - embeds: [ - { - title: "[:loudspeaker:] Give", - description: `You have given a ${optionType} repute to ${optionTarget}`, - timestamp: new Date(), - color: successColor, - footer: { - iconURL: footerIcon, - text: footerText, - }, - }, - ], + embeds: [interactionEmbed], }); }); }, diff --git a/src/plugins/commands/shop/index.ts b/src/plugins/commands/shop/index.ts index 20fa7dd..5f6e0b6 100644 --- a/src/plugins/commands/shop/index.ts +++ b/src/plugins/commands/shop/index.ts @@ -1,6 +1,6 @@ // Dependencies import { SlashCommandBuilder } from "@discordjs/builders"; -import { CommandInteraction } from "discord.js"; +import { ChatInputCommandInteraction } from "discord.js"; // Modules import modules from "./modules"; @@ -17,7 +17,7 @@ export const builder = new SlashCommandBuilder() .addSubcommand(modules.cpgg.builder) .addSubcommandGroup(modules.roles.builder); -export const execute = async (interaction: CommandInteraction) => { +export const execute = async (interaction: ChatInputCommandInteraction) => { const { options } = interaction; if (options?.getSubcommand() === "cpgg") { diff --git a/src/plugins/commands/shop/modules/cpgg/index.ts b/src/plugins/commands/shop/modules/cpgg/index.ts index 5655d7a..c868e83 100644 --- a/src/plugins/commands/shop/modules/cpgg/index.ts +++ b/src/plugins/commands/shop/modules/cpgg/index.ts @@ -1,21 +1,22 @@ +import axios from "axios"; import { - CommandInteraction, ActionRowBuilder, ButtonBuilder, + ButtonStyle, + ChatInputCommandInteraction, + EmbedBuilder, + Message, } from "discord.js"; import { v4 as uuidv4 } from "uuid"; -import axios from "axios"; -import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; - -import logger from "../../../../../middlewares/logger"; import encryption from "../../../../../handlers/encryption"; +import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; +import logger from "../../../../../middlewares/logger"; -import pluralize from "../../../../../helpers/pluralize"; - -import apiSchema from "../../../../../models/api"; -import fetchUser from "../../../../../helpers/fetchUser"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import fetchUser from "../../../../../helpers/fetchUser"; +import pluralize from "../../../../../helpers/pluralize"; +import apiSchema from "../../../../../models/api"; export default { metadata: { guildOnly: true, ephemeral: true }, @@ -31,7 +32,7 @@ export default { .setRequired(true) ); }, - execute: async (interaction: CommandInteraction) => { + execute: async (interaction: ChatInputCommandInteraction) => { const { errorColor, successColor, footerText, footerIcon } = await getEmbedConfig(interaction.guild); const { options, guild, user, client } = interaction; @@ -41,19 +42,15 @@ export default { if (optionAmount === null) { logger?.silly(`Amount is null.`); + const interactionEmbed = new EmbedBuilder() + .setTitle("[:dollar:] Gift") + .setDescription("We could not read your requested amount.") + .setTimestamp() + .setColor(errorColor) + .setFooter({ text: footerText, iconURL: footerIcon }); + return interaction?.editReply({ - embeds: [ - { - title: ":dollar: Credits [Gift]", - description: "We could not read your requested amount.", - color: errorColor, - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }, - ], + embeds: [interactionEmbed], }); } @@ -72,76 +69,59 @@ export default { if ((optionAmount || userDB?.credits) < 100) { logger?.silly(`Amount or user credits is below 100.`); + const interactionEmbed = new EmbedBuilder() + .setTitle("[:shopping_cart:] CPGG") + .setDescription("You **can't** withdraw for __CPGG__ below **100**.") + .setTimestamp() + .addFields({ + name: "Your balance", + value: `${pluralize(userDB?.credits, "credit")}`, + }) + .setColor(errorColor) + .setFooter({ text: footerText, iconURL: footerIcon }); + return interaction?.editReply({ - embeds: [ - { - title: "[:shopping_cart:] CPGG", - description: `You **can't** withdraw for __CPGG__ below **100**.`, - color: errorColor, - fields: [ - { - name: "Your balance", - value: `${pluralize(userDB?.credits, "credit")}`, - }, - ], - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }, - ], + embeds: [interactionEmbed], }); } if ((optionAmount || userDB?.credits) > 1000000) { logger?.silly(`Amount or user credits is above 1.000.000.`); + const interactionEmbed = new EmbedBuilder() + .setTitle("[:shopping_cart:] CPGG") + .setDescription( + "You **can't** withdraw for __CPGG__ above **1.000.000**." + ) + .setTimestamp() + .addFields({ + name: "Your balance", + value: `${pluralize(userDB?.credits, "credit")}`, + }) + .setColor(errorColor) + .setFooter({ text: footerText, iconURL: footerIcon }); + return interaction?.editReply({ - embeds: [ - { - title: "[:shopping_cart:] CPGG", - description: - "You **can't** withdraw for __CPGG__ above **1.000.000**.", - color: errorColor, - fields: [ - { - name: "Your balance", - value: `${pluralize(userDB?.credits, "credit")}`, - }, - ], - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }, - ], + embeds: [interactionEmbed], }); } if (userDB?.credits < optionAmount) { logger?.silly(`User credits is below amount.`); + const interactionEmbed = new EmbedBuilder() + .setTitle("[:shopping_cart:] CPGG") + .setDescription("You have **insufficient** credits.") + .setTimestamp() + .addFields({ + name: "Your balance", + value: `${pluralize(userDB?.credits, "credit")}`, + }) + .setColor(errorColor) + .setFooter({ text: footerText, iconURL: footerIcon }); + return interaction?.editReply({ - embeds: [ - { - title: "[:shopping_cart:] CPGG", - description: `You have **insufficient** credits.`, - color: errorColor, - fields: [ - { - name: "Your balance", - value: `${pluralize(userDB?.credits, "credit")}`, - }, - ], - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }, - ], + embeds: [interactionEmbed], }); } @@ -163,10 +143,10 @@ export default { const shopUrl = `${url}/store`; - const buttons = new ActionRowBuilder().addComponents( + const buttons = new ActionRowBuilder().addComponents( new ButtonBuilder() .setLabel("Redeem it here") - .setStyle("LINK") + .setStyle(ButtonStyle.Link) .setEmoji("🏦") .setURL(`${shopUrl}?voucher=${code}`) ); @@ -193,43 +173,37 @@ export default { if (!interaction.guild) throw new Error("Guild is undefined"); + const dmEmbed = new EmbedBuilder() + .setTitle("[:shopping_cart:] CPGG") + .setDescription( + `This voucher comes from **${interaction.guild.name}**.` + ) + .setTimestamp() + .addFields({ + name: "💶 Credits", + value: `${optionAmount || userDB?.credits}`, + inline: true, + }) + .setColor(successColor) + .setFooter({ text: footerText, iconURL: footerIcon }); + await dmUser ?.send({ - embeds: [ - { - title: "[:shopping_cart:] CPGG", - description: `This voucher comes from **${interaction.guild.name}**.`, - fields: [ - { - name: "💶 Credits", - value: `${optionAmount || userDB?.credits}`, - inline: true, - }, - ], - color: successColor, - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }, - ], + embeds: [dmEmbed], components: [buttons], }) - .then(async (msg) => { + .then(async (msg: Message) => { + const interactionEmbed = new EmbedBuilder() + .setTitle("[:shopping_cart:] CPGG") + .setDescription( + `I have sent you the code in [DM](${msg.url})!` + ) + .setTimestamp() + .setColor(successColor) + .setFooter({ text: footerText, iconURL: footerIcon }); + return interaction?.editReply({ - embeds: [ - { - title: "[:shopping_cart:] CPGG", - description: `I have sent you the code in [DM](${msg.url})!`, - color: successColor, - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }, - ], + embeds: [interactionEmbed], }); }); }) @@ -237,19 +211,15 @@ export default { .catch(async (error) => { logger?.silly(`Error saving new credits. - ${error}`); + const interactionEmbed = new EmbedBuilder() + .setTitle("[:shopping_cart:] CPGG") + .setDescription(`Something went wrong.`) + .setTimestamp() + .setColor(errorColor) + .setFooter({ text: footerText, iconURL: footerIcon }); + return interaction?.editReply({ - embeds: [ - { - title: "[:shopping_cart:] CPGG", - description: "Something went wrong.", - color: errorColor, - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }, - ], + embeds: [interactionEmbed], }); }); }) @@ -257,19 +227,15 @@ export default { .catch(async (error) => { logger?.silly(`Error creating voucher. - ${error}`); + const interactionEmbed = new EmbedBuilder() + .setTitle("[:shopping_cart:] CPGG") + .setDescription(`Something went wrong.`) + .setTimestamp() + .setColor(errorColor) + .setFooter({ text: footerText, iconURL: footerIcon }); + return interaction?.editReply({ - embeds: [ - { - title: "[:shopping_cart:] CPGG", - description: "Something went wrong.", - color: errorColor, - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }, - ], + embeds: [interactionEmbed], }); }); }, diff --git a/src/plugins/commands/shop/modules/roles/index.ts b/src/plugins/commands/shop/modules/roles/index.ts index ed0c190..5f5d005 100644 --- a/src/plugins/commands/shop/modules/roles/index.ts +++ b/src/plugins/commands/shop/modules/roles/index.ts @@ -1,11 +1,8 @@ // Dependencies import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders"; -import { CommandInteraction } from "discord.js"; +import { ChatInputCommandInteraction } from "discord.js"; // Handlers -import logger from "../../../../../middlewares/logger"; - -import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; // Modules import modules from "./modules"; @@ -23,11 +20,8 @@ export const builder = (group: SlashCommandSubcommandGroupBuilder) => { .addSubcommand(modules.cancel.builder); }; -export const execute = async (interaction: CommandInteraction) => { +export const execute = async (interaction: ChatInputCommandInteraction) => { if (interaction.guild == null) return; - const { errorColor, footerText, footerIcon } = await getEmbedConfig( - interaction.guild - ); const { options, guild } = interaction; const guildDB = await guildSchema?.findOne({ @@ -36,24 +30,8 @@ export const execute = async (interaction: CommandInteraction) => { if (guildDB === null) return; - if (!guildDB.shop.roles.status) { - logger.silly(`Shop roles disabled.`); - - return interaction?.editReply({ - embeds: [ - { - title: ":dollar: Shop - Roles", - description: "This server has disabled shop roles.", - color: errorColor, - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }, - ], - }); - } + if (!guildDB.shop.roles.status) + throw new Error("This server has disabled shop roles."); if (options?.getSubcommand() === "buy") { await modules.buy.execute(interaction); diff --git a/src/plugins/commands/shop/modules/roles/modules/buy/index.ts b/src/plugins/commands/shop/modules/roles/modules/buy/index.ts index e9197f8..2ed7cdf 100644 --- a/src/plugins/commands/shop/modules/roles/modules/buy/index.ts +++ b/src/plugins/commands/shop/modules/roles/modules/buy/index.ts @@ -1,7 +1,8 @@ // Dependencies import { - CommandInteraction, + ChatInputCommandInteraction, ColorResolvable, + EmbedBuilder, GuildMemberRoleManager, } from "discord.js"; @@ -9,15 +10,15 @@ import { import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; // Models -import shopRolesSchema from "../../../../../../../models/shopRole"; import guildSchema from "../../../../../../../models/guild"; +import shopRolesSchema from "../../../../../../../models/shopRole"; import logger from "../../../../../../../middlewares/logger"; // Helpers -import pluralize from "../../../../../../../helpers/pluralize"; -import fetchUser from "../../../../../../../helpers/fetchUser"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import fetchUser from "../../../../../../../helpers/fetchUser"; +import pluralize from "../../../../../../../helpers/pluralize"; // Function export default { @@ -40,33 +41,18 @@ export default { .setRequired(true) ); }, - execute: async (interaction: CommandInteraction) => { - const { errorColor, successColor, footerText, footerIcon } = - await getEmbedConfig(interaction.guild); + execute: async (interaction: ChatInputCommandInteraction) => { + const { successColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); const { options, guild, user, member } = interaction; const optionName = options?.getString("name"); const optionColor = options?.getString("color"); // If amount is null - if (optionName === null) { - logger?.silly(`Name is null.`); - - return interaction?.editReply({ - embeds: [ - { - title: ":dollar: Shop - Roles [Buy]", - description: "We could not read your requested name.", - color: errorColor, - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }, - ], - }); - } + if (optionName === null) + throw new Error("We could not read your requested name"); await guild?.roles .create({ @@ -112,28 +98,20 @@ export default { logger?.silly(`Role ${role?.name} was bought by ${user?.tag}`); + const interactionEmbed = new EmbedBuilder() + .setTitle("[:shopping_cart:] Buy") + .setDescription( + `You bought **${optionName}** for **${pluralize( + pricePerHour, + "credit" + )}**.` + ) + .setTimestamp() + .setColor(successColor) + .setFooter({ text: footerText, iconURL: footerIcon }); + return interaction?.editReply({ - embeds: [ - { - title: ":shopping_cart: Shop - Roles [Buy]", - description: `You bought **${optionName}** for **${pluralize( - pricePerHour, - "credit" - )}**.`, - color: successColor, - fields: [ - { - name: "Your balance", - value: `${pluralize(userDB?.credits, "credit")}`, - }, - ], - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }, - ], + embeds: [interactionEmbed], }); }) .catch(async (error) => { diff --git a/src/plugins/commands/shop/modules/roles/modules/cancel/index.ts b/src/plugins/commands/shop/modules/roles/modules/cancel/index.ts index e983dd3..225b42a 100644 --- a/src/plugins/commands/shop/modules/roles/modules/cancel/index.ts +++ b/src/plugins/commands/shop/modules/roles/modules/cancel/index.ts @@ -1,5 +1,9 @@ // Dependencies -import { CommandInteraction, GuildMemberRoleManager } from "discord.js"; +import { + ChatInputCommandInteraction, + EmbedBuilder, + GuildMemberRoleManager, +} from "discord.js"; // Configurations import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; @@ -10,9 +14,9 @@ import shopRolesSchema from "../../../../../../../models/shopRole"; import logger from "../../../../../../../middlewares/logger"; // Helpers -import pluralize from "../../../../../../../helpers/pluralize"; -import fetchUser from "../../../../../../../helpers/fetchUser"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import fetchUser from "../../../../../../../helpers/fetchUser"; +import pluralize from "../../../../../../../helpers/pluralize"; // Function export default { @@ -29,31 +33,16 @@ export default { .setRequired(true) ); }, - execute: async (interaction: CommandInteraction) => { - const { errorColor, successColor, footerText, footerIcon } = - await getEmbedConfig(interaction.guild); + execute: async (interaction: ChatInputCommandInteraction) => { + const { successColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); const { options, guild, user, member } = interaction; const optionRole = options.getRole("role"); - if (optionRole === null) { - logger?.silly(`Role is null.`); - - return interaction?.editReply({ - embeds: [ - { - title: ":dollar: Shop - Roles [Cancel]", - description: "We could not read your requested role.", - color: errorColor, - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }, - ], - }); - } + if (optionRole === null) + throw new Error("We could not read your requested role."); const roleExist = await shopRolesSchema?.findOne({ guildId: guild?.id, @@ -80,28 +69,22 @@ export default { guildId: guild?.id, }); + const interactionEmbed = new EmbedBuilder() + .setTitle("[:shopping_cart:] Cancel") + .setDescription(`You have canceled ${optionRole.name}.`) + .setTimestamp() + .setColor(successColor) + .addFields({ + name: "Your balance", + value: `${pluralize(userDB?.credits, "credit")}`, + }) + .setFooter({ text: footerText, iconURL: footerIcon }); + return interaction?.editReply({ - embeds: [ - { - title: ":shopping_cart: Shop - Roles [Cancel]", - description: `You have canceled ${optionRole.name}.`, - color: successColor, - fields: [ - { - name: "Your balance", - value: `${pluralize(userDB?.credits, "credit")}`, - }, - ], - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }, - ], + embeds: [interactionEmbed], }); }) - .catch(async (error) => { + .catch(async (error: Error) => { return logger?.silly(`Role could not be deleted. ${error}`); }); }, diff --git a/src/plugins/commands/utility/index.ts b/src/plugins/commands/utility/index.ts index 43da584..a10fde2 100644 --- a/src/plugins/commands/utility/index.ts +++ b/src/plugins/commands/utility/index.ts @@ -1,5 +1,5 @@ import { SlashCommandBuilder } from "@discordjs/builders"; -import { CommandInteraction } from "discord.js"; +import { ChatInputCommandInteraction } from "discord.js"; import modules from "./modules"; export const moduleData = modules; @@ -13,7 +13,7 @@ export const builder = new SlashCommandBuilder() .addSubcommand(modules.avatar.builder) .addSubcommand(modules.ping.builder); -export const execute = async (interaction: CommandInteraction) => { +export const execute = async (interaction: ChatInputCommandInteraction) => { switch (interaction.options.getSubcommand()) { case "about": return modules.about.execute(interaction); diff --git a/src/plugins/commands/utility/modules/about/index.ts b/src/plugins/commands/utility/modules/about/index.ts index 3dc1deb..6fee2f3 100644 --- a/src/plugins/commands/utility/modules/about/index.ts +++ b/src/plugins/commands/utility/modules/about/index.ts @@ -1,9 +1,9 @@ // Dependencies import { - CommandInteraction, ActionRowBuilder, ButtonBuilder, ButtonStyle, + CommandInteraction, EmbedBuilder, } from "discord.js"; diff --git a/src/plugins/commands/utility/modules/avatar/index.ts b/src/plugins/commands/utility/modules/avatar/index.ts index 3d69414..20f8edd 100644 --- a/src/plugins/commands/utility/modules/avatar/index.ts +++ b/src/plugins/commands/utility/modules/avatar/index.ts @@ -1,7 +1,7 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; -import { CommandInteraction, EmbedBuilder } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import { CommandInteraction, EmbedBuilder } from "discord.js"; export default { metadata: { guildOnly: false, ephemeral: false }, diff --git a/src/plugins/commands/utility/modules/index.ts b/src/plugins/commands/utility/modules/index.ts index 33fa0f5..7383403 100644 --- a/src/plugins/commands/utility/modules/index.ts +++ b/src/plugins/commands/utility/modules/index.ts @@ -1,7 +1,7 @@ -import avatar from "./avatar"; import about from "./about"; -import stats from "./stats"; +import avatar from "./avatar"; import ping from "./ping"; +import stats from "./stats"; export default { avatar, diff --git a/src/plugins/commands/utility/modules/ping/index.ts b/src/plugins/commands/utility/modules/ping/index.ts index 420329e..96aee27 100644 --- a/src/plugins/commands/utility/modules/ping/index.ts +++ b/src/plugins/commands/utility/modules/ping/index.ts @@ -1,5 +1,5 @@ // Dependencies -import { CommandInteraction } from "discord.js"; +import { CommandInteraction, EmbedBuilder } from "discord.js"; // Configurations import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; @@ -18,9 +18,9 @@ export default { interaction.guild ); - const interactionEmbed = { - title: "[:tools:] Ping", - fields: [ + const interactionEmbed = new EmbedBuilder() + .setTitle("[:tools:] Ping") + .addFields( { name: "📦 Deliver Latency", value: `${Math.abs(Date.now() - interaction.createdTimestamp)} ms`, @@ -30,15 +30,12 @@ export default { name: "🤖 API Latency", value: `${Math.round(interaction.client.ws.ping)} ms`, inline: true, - }, - ], - color: successColor, - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }; + } + ) + .setTimestamp() + .setColor(successColor) + .setFooter({ text: footerText, iconURL: footerIcon }); + await interaction.editReply({ embeds: [interactionEmbed], }); diff --git a/src/types/common/environment.d.ts b/src/types/common/environment.d.ts index 4c1ee6c..bc18671 100644 --- a/src/types/common/environment.d.ts +++ b/src/types/common/environment.d.ts @@ -1,4 +1,4 @@ -import { Snowflake, ColorResolvable } from "discord.js"; +import { ColorResolvable, Snowflake } from "discord.js"; declare global { namespace NodeJS { From 96190607841f7f1899f61f142a08e9fe3de70855 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Thu, 25 Aug 2022 12:00:54 +0200 Subject: [PATCH 042/215] =?UTF-8?q?=F0=9F=91=BD=EF=B8=8F=20bit=20activity?= =?UTF-8?q?=20status=20working=20on=20v14?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/helpers/updatePresence/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/helpers/updatePresence/index.ts b/src/helpers/updatePresence/index.ts index 2b25c37..e3fbe34 100644 --- a/src/helpers/updatePresence/index.ts +++ b/src/helpers/updatePresence/index.ts @@ -1,5 +1,5 @@ // Dependencies -import { Client } from "discord.js"; +import { ActivityType, Client } from "discord.js"; import logger from "../../middlewares/logger"; // Function @@ -12,7 +12,7 @@ export default async (client: Client) => { const status = `${memberCount} users in ${guildCount} guilds.`; client.user.setPresence({ - activities: [{ type: "LISTENING", name: status }], + activities: [{ type: ActivityType.Watching, name: status }], status: "online", }); From 696ca8a7f6b2761201901091e9370421a198f968 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Thu, 25 Aug 2022 12:01:24 +0200 Subject: [PATCH 043/215] =?UTF-8?q?=F0=9F=9A=9A=20database=20logging=20use?= =?UTF-8?q?=20correct=20path=20to=20logger?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/managers/database/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/managers/database/index.ts b/src/managers/database/index.ts index 4b65e4f..44152a7 100644 --- a/src/managers/database/index.ts +++ b/src/managers/database/index.ts @@ -1,5 +1,5 @@ import mongoose from "mongoose"; -import logger from "../../logger"; +import logger from "../../middlewares/logger"; export const connect = async () => { await mongoose From 72456155a33287b615218d692ddae4a20719c076 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Thu, 25 Aug 2022 12:01:48 +0200 Subject: [PATCH 044/215] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=20changed=20some?= =?UTF-8?q?=20=20v13=20to=20v14=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/helpers/getCommandMetadata/index.ts | 4 ++-- src/helpers/getPluginStructure/index.ts | 9 ++++----- .../interactionCreate/handlers/command/index.ts | 6 +++--- .../events/interactionCreate/handlers/index.ts | 14 +++++++++----- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/helpers/getCommandMetadata/index.ts b/src/helpers/getCommandMetadata/index.ts index 647eb75..6a6a8b7 100644 --- a/src/helpers/getCommandMetadata/index.ts +++ b/src/helpers/getCommandMetadata/index.ts @@ -1,8 +1,8 @@ -import { CommandInteraction } from "discord.js"; +import { ChatInputCommandInteraction } from "discord.js"; import { ICommand } from "../../interfaces/Command"; export default async ( - interaction: CommandInteraction, + interaction: ChatInputCommandInteraction, currentCommand: ICommand ) => { const subcommand = interaction.options.getSubcommand(); diff --git a/src/helpers/getPluginStructure/index.ts b/src/helpers/getPluginStructure/index.ts index 0bba6f4..6642bb8 100644 --- a/src/helpers/getPluginStructure/index.ts +++ b/src/helpers/getPluginStructure/index.ts @@ -1,13 +1,12 @@ /* eslint-disable no-loops/no-loops */ -import path from "path"; -import listDir from "../listDir"; -import getPlugins from "../getPlugins"; +import { Client } from "discord.js"; +import logger from "../../middlewares/logger"; import getPluginCommands from "../getPluginCommands"; import getPluginMetadata from "../getPluginMetadata"; -import logger from "../../middlewares/logger"; +import getPlugins from "../getPlugins"; -export default async (client, dir: string) => { +export default async (client: Client, dir: string) => { const plugins = await getPlugins(dir); const pluginStructure = []; diff --git a/src/plugins/events/interactionCreate/handlers/command/index.ts b/src/plugins/events/interactionCreate/handlers/command/index.ts index 797b6bd..acc53b0 100644 --- a/src/plugins/events/interactionCreate/handlers/command/index.ts +++ b/src/plugins/events/interactionCreate/handlers/command/index.ts @@ -1,11 +1,11 @@ // Dependencies -import { BaseInteraction } from "discord.js"; +import { ChatInputCommandInteraction } from "discord.js"; +import * as cooldown from "../../../../../helpers/cooldown"; import deferReply from "../../../../../helpers/deferReply"; import getCommandMetadata from "../../../../../helpers/getCommandMetadata"; -import * as cooldown from "../../../../../helpers/cooldown"; -export default async (interaction: BaseInteraction) => { +export default async (interaction: ChatInputCommandInteraction) => { if (!interaction.isCommand()) return; const { client, commandName } = interaction; diff --git a/src/plugins/events/interactionCreate/handlers/index.ts b/src/plugins/events/interactionCreate/handlers/index.ts index 186b3d1..d6fad1b 100644 --- a/src/plugins/events/interactionCreate/handlers/index.ts +++ b/src/plugins/events/interactionCreate/handlers/index.ts @@ -1,14 +1,18 @@ -import { BaseInteraction, CommandInteraction, EmbedBuilder } from "discord.js"; -import getEmbedConfig from "../../../../helpers/getEmbedConfig"; +import { + BaseInteraction, + ChatInputCommandInteraction, + CommandInteraction, + EmbedBuilder, +} from "discord.js"; import capitalizeFirstLetter from "../../../../helpers/capitalizeFirstLetter"; -import logger from "../../../../middlewares/logger"; +import getEmbedConfig from "../../../../helpers/getEmbedConfig"; import button from "./button"; import command from "./command"; export const execute = async (interaction: BaseInteraction) => { await button(interaction); - await command(interaction); + await command(interaction); }; export const handleCommandInteraction = async ( @@ -18,7 +22,7 @@ export const handleCommandInteraction = async ( interaction.guild ); - await command(interaction).catch(async (err) => { + await command(interaction).catch(async (err) => { return interaction.editReply({ embeds: [ new EmbedBuilder() From 8d213f65a769d0cfa7b7bc6e498c9b5fdcf3b8f1 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Thu, 25 Aug 2022 12:04:07 +0200 Subject: [PATCH 045/215] =?UTF-8?q?=F0=9F=8E=A8organized=20imports=20on=20?= =?UTF-8?q?events?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/events/guildCreate/index.ts | 4 ++-- src/plugins/events/guildDelete/index.ts | 4 ++-- src/plugins/events/guildMemberAdd/audits.ts | 2 +- src/plugins/events/guildMemberAdd/index.ts | 4 ++-- src/plugins/events/guildMemberAdd/joinMessage.ts | 2 +- src/plugins/events/guildMemberRemove/audits.ts | 2 +- src/plugins/events/guildMemberRemove/index.ts | 8 ++++---- src/plugins/events/guildMemberRemove/leaveMessage.ts | 2 +- src/plugins/events/interactionCreate/audits.ts | 2 +- .../events/interactionCreate/handlers/button/index.ts | 2 +- src/plugins/events/interactionCreate/index.ts | 5 +---- src/plugins/events/messageCreate/modules/credits/index.ts | 4 ++-- src/plugins/events/messageCreate/modules/points/index.ts | 2 +- src/plugins/events/messageDelete/audits.ts | 2 +- src/plugins/events/messageDelete/index.ts | 2 +- src/plugins/events/messageDelete/modules/counter.ts | 2 +- src/plugins/events/messageUpdate/audits.ts | 2 +- src/plugins/events/messageUpdate/index.ts | 2 +- src/plugins/events/messageUpdate/modules/counter.ts | 2 +- src/plugins/events/ready/index.ts | 2 +- 20 files changed, 27 insertions(+), 30 deletions(-) diff --git a/src/plugins/events/guildCreate/index.ts b/src/plugins/events/guildCreate/index.ts index 918ac59..c661913 100644 --- a/src/plugins/events/guildCreate/index.ts +++ b/src/plugins/events/guildCreate/index.ts @@ -1,8 +1,8 @@ import { Guild } from "discord.js"; -import updatePresence from "../../../helpers/updatePresence"; import fetchGuild from "../../../helpers/fetchGuild"; -import logger from "../../../middlewares/logger"; +import updatePresence from "../../../helpers/updatePresence"; import { IEventOptions } from "../../../interfaces/EventOptions"; +import logger from "../../../middlewares/logger"; export const options: IEventOptions = { type: "on", diff --git a/src/plugins/events/guildDelete/index.ts b/src/plugins/events/guildDelete/index.ts index 7c15b30..5d7bde0 100644 --- a/src/plugins/events/guildDelete/index.ts +++ b/src/plugins/events/guildDelete/index.ts @@ -2,10 +2,10 @@ import { Guild } from "discord.js"; // Dependencies -import updatePresence from "../../../helpers/updatePresence"; import dropGuild from "../../../helpers/dropGuild"; -import logger from "../../../middlewares/logger"; +import updatePresence from "../../../helpers/updatePresence"; import { IEventOptions } from "../../../interfaces/EventOptions"; +import logger from "../../../middlewares/logger"; export const options: IEventOptions = { type: "on", diff --git a/src/plugins/events/guildMemberAdd/audits.ts b/src/plugins/events/guildMemberAdd/audits.ts index ab29c86..e5b1e67 100644 --- a/src/plugins/events/guildMemberAdd/audits.ts +++ b/src/plugins/events/guildMemberAdd/audits.ts @@ -1,5 +1,5 @@ +import { ChannelType, EmbedBuilder, GuildMember } from "discord.js"; import logger from "../../../middlewares/logger"; -import { GuildMember, EmbedBuilder, ChannelType } from "discord.js"; import guildSchema from "../../../models/guild"; diff --git a/src/plugins/events/guildMemberAdd/index.ts b/src/plugins/events/guildMemberAdd/index.ts index ec349c4..a5efdb9 100644 --- a/src/plugins/events/guildMemberAdd/index.ts +++ b/src/plugins/events/guildMemberAdd/index.ts @@ -2,12 +2,12 @@ import { GuildMember } from "discord.js"; // Dependencies -import updatePresence from "../../../helpers/updatePresence"; import fetchUser from "../../../helpers/fetchUser"; +import updatePresence from "../../../helpers/updatePresence"; import logger from "../../../middlewares/logger"; -import joinMessage from "./joinMessage"; import audits from "./audits"; +import joinMessage from "./joinMessage"; import { IEventOptions } from "../../../interfaces/EventOptions"; diff --git a/src/plugins/events/guildMemberAdd/joinMessage.ts b/src/plugins/events/guildMemberAdd/joinMessage.ts index c6abae8..7bf5889 100644 --- a/src/plugins/events/guildMemberAdd/joinMessage.ts +++ b/src/plugins/events/guildMemberAdd/joinMessage.ts @@ -1,4 +1,4 @@ -import { GuildMember, EmbedBuilder, TextChannel } from "discord.js"; +import { EmbedBuilder, GuildMember, TextChannel } from "discord.js"; import guildSchema from "../../../models/guild"; diff --git a/src/plugins/events/guildMemberRemove/audits.ts b/src/plugins/events/guildMemberRemove/audits.ts index 52affa3..522e132 100644 --- a/src/plugins/events/guildMemberRemove/audits.ts +++ b/src/plugins/events/guildMemberRemove/audits.ts @@ -1,5 +1,5 @@ +import { ChannelType, EmbedBuilder, GuildMember } from "discord.js"; import logger from "../../../middlewares/logger"; -import { GuildMember, EmbedBuilder, ChannelType } from "discord.js"; import guildSchema from "../../../models/guild"; diff --git a/src/plugins/events/guildMemberRemove/index.ts b/src/plugins/events/guildMemberRemove/index.ts index 3ac50e6..5ee1bec 100644 --- a/src/plugins/events/guildMemberRemove/index.ts +++ b/src/plugins/events/guildMemberRemove/index.ts @@ -2,12 +2,12 @@ import { GuildMember } from "discord.js"; // Dependencies -import updatePresence from "../../../helpers/updatePresence"; import dropUser from "../../../helpers/dropUser"; -import logger from "../../../middlewares/logger"; -import leaveMessage from "./leaveMessage"; -import audits from "./audits"; +import updatePresence from "../../../helpers/updatePresence"; import { IEventOptions } from "../../../interfaces/EventOptions"; +import logger from "../../../middlewares/logger"; +import audits from "./audits"; +import leaveMessage from "./leaveMessage"; export const options: IEventOptions = { type: "on", diff --git a/src/plugins/events/guildMemberRemove/leaveMessage.ts b/src/plugins/events/guildMemberRemove/leaveMessage.ts index 815e0f9..8792af5 100644 --- a/src/plugins/events/guildMemberRemove/leaveMessage.ts +++ b/src/plugins/events/guildMemberRemove/leaveMessage.ts @@ -1,4 +1,4 @@ -import { GuildMember, EmbedBuilder, TextChannel } from "discord.js"; +import { EmbedBuilder, GuildMember, TextChannel } from "discord.js"; import guildSchema from "../../../models/guild"; diff --git a/src/plugins/events/interactionCreate/audits.ts b/src/plugins/events/interactionCreate/audits.ts index a6ce76c..e8de61c 100644 --- a/src/plugins/events/interactionCreate/audits.ts +++ b/src/plugins/events/interactionCreate/audits.ts @@ -1,5 +1,5 @@ -import logger from "../../../middlewares/logger"; import { BaseInteraction, EmbedBuilder, TextChannel } from "discord.js"; +import logger from "../../../middlewares/logger"; import guildSchema from "../../../models/guild"; diff --git a/src/plugins/events/interactionCreate/handlers/button/index.ts b/src/plugins/events/interactionCreate/handlers/button/index.ts index 85ee639..04d524e 100644 --- a/src/plugins/events/interactionCreate/handlers/button/index.ts +++ b/src/plugins/events/interactionCreate/handlers/button/index.ts @@ -1,8 +1,8 @@ // Dependencies import { BaseInteraction } from "discord.js"; -import deferReply from "../../../../../helpers/deferReply"; import * as cooldown from "../../../../../helpers/cooldown"; +import deferReply from "../../../../../helpers/deferReply"; export default async (interaction: BaseInteraction) => { if (!interaction.isButton()) return; diff --git a/src/plugins/events/interactionCreate/index.ts b/src/plugins/events/interactionCreate/index.ts index 3d78060..49599e6 100644 --- a/src/plugins/events/interactionCreate/index.ts +++ b/src/plugins/events/interactionCreate/index.ts @@ -2,18 +2,15 @@ import { BaseInteraction, CommandInteraction, - EmbedBuilder, InteractionType, } from "discord.js"; // Dependencies import * as handlers from "./handlers"; +import { IEventOptions } from "../../../interfaces/EventOptions"; import logger from "../../../middlewares/logger"; import audits from "./audits"; -import { IEventOptions } from "../../../interfaces/EventOptions"; -import capitalizeFirstLetter from "../../../helpers/capitalizeFirstLetter"; -import getEmbedConfig from "../../../helpers/getEmbedConfig"; export const options: IEventOptions = { type: "on", diff --git a/src/plugins/events/messageCreate/modules/credits/index.ts b/src/plugins/events/messageCreate/modules/credits/index.ts index 0d1ddcf..3f282f7 100644 --- a/src/plugins/events/messageCreate/modules/credits/index.ts +++ b/src/plugins/events/messageCreate/modules/credits/index.ts @@ -1,8 +1,8 @@ -import logger from "../../../../../middlewares/logger"; import { ChannelType, Message } from "discord.js"; +import logger from "../../../../../middlewares/logger"; -import fetchUser from "../../../../../helpers/fetchUser"; import fetchGuild from "../../../../../helpers/fetchGuild"; +import fetchUser from "../../../../../helpers/fetchUser"; import * as cooldown from "../../../../../helpers/cooldown"; diff --git a/src/plugins/events/messageCreate/modules/points/index.ts b/src/plugins/events/messageCreate/modules/points/index.ts index 9750ddb..d2b2ab2 100644 --- a/src/plugins/events/messageCreate/modules/points/index.ts +++ b/src/plugins/events/messageCreate/modules/points/index.ts @@ -2,8 +2,8 @@ import logger from "../../../../../middlewares/logger"; import * as cooldown from "../../../../../helpers/cooldown"; -import fetchUser from "../../../../../helpers/fetchUser"; import fetchGuild from "../../../../../helpers/fetchGuild"; +import fetchUser from "../../../../../helpers/fetchUser"; import { ChannelType, Message } from "discord.js"; export default { diff --git a/src/plugins/events/messageDelete/audits.ts b/src/plugins/events/messageDelete/audits.ts index 3ce3a37..781897b 100644 --- a/src/plugins/events/messageDelete/audits.ts +++ b/src/plugins/events/messageDelete/audits.ts @@ -1,5 +1,5 @@ +import { EmbedBuilder, Message, TextChannel } from "discord.js"; import logger from "../../../middlewares/logger"; -import { Message, EmbedBuilder, TextChannel } from "discord.js"; import guildSchema from "../../../models/guild"; diff --git a/src/plugins/events/messageDelete/index.ts b/src/plugins/events/messageDelete/index.ts index 3cb7f6e..4b3db23 100644 --- a/src/plugins/events/messageDelete/index.ts +++ b/src/plugins/events/messageDelete/index.ts @@ -1,7 +1,7 @@ import { Message } from "discord.js"; +import { IEventOptions } from "../../../interfaces/EventOptions"; import audits from "../../events/messageDelete/audits"; import counter from "./modules/counter"; -import { IEventOptions } from "../../../interfaces/EventOptions"; export const options: IEventOptions = { type: "on", diff --git a/src/plugins/events/messageDelete/modules/counter.ts b/src/plugins/events/messageDelete/modules/counter.ts index e5533c3..65d8bc5 100644 --- a/src/plugins/events/messageDelete/modules/counter.ts +++ b/src/plugins/events/messageDelete/modules/counter.ts @@ -2,8 +2,8 @@ import { Message } from "discord.js"; // Models -import counterSchema from "../../../../models/counter"; import logger from "../../../../middlewares/logger"; +import counterSchema from "../../../../models/counter"; export default async (message: Message) => { const { guild, channel, author, content } = message; diff --git a/src/plugins/events/messageUpdate/audits.ts b/src/plugins/events/messageUpdate/audits.ts index b34a85f..4bd79a2 100644 --- a/src/plugins/events/messageUpdate/audits.ts +++ b/src/plugins/events/messageUpdate/audits.ts @@ -1,6 +1,6 @@ /* eslint-disable no-loops/no-loops */ +import { EmbedBuilder, Message, TextChannel } from "discord.js"; import logger from "../../../middlewares/logger"; -import { Message, EmbedBuilder, TextChannel } from "discord.js"; import guildSchema from "../../../models/guild"; diff --git a/src/plugins/events/messageUpdate/index.ts b/src/plugins/events/messageUpdate/index.ts index 273a2b4..812a0ba 100644 --- a/src/plugins/events/messageUpdate/index.ts +++ b/src/plugins/events/messageUpdate/index.ts @@ -5,8 +5,8 @@ import logger from "../../../middlewares/logger"; // Modules import counter from "./modules/counter"; -import audits from "./audits"; import { IEventOptions } from "../../../interfaces/EventOptions"; +import audits from "./audits"; export const options: IEventOptions = { type: "on", diff --git a/src/plugins/events/messageUpdate/modules/counter.ts b/src/plugins/events/messageUpdate/modules/counter.ts index 15d3dc1..b969358 100644 --- a/src/plugins/events/messageUpdate/modules/counter.ts +++ b/src/plugins/events/messageUpdate/modules/counter.ts @@ -2,8 +2,8 @@ import { Message } from "discord.js"; // Models -import counterSchema from "../../../../models/counter"; import logger from "../../../../middlewares/logger"; +import counterSchema from "../../../../models/counter"; export default async (message: Message) => { const { guild, channel, author, content } = message; diff --git a/src/plugins/events/ready/index.ts b/src/plugins/events/ready/index.ts index b7d5809..2831375 100644 --- a/src/plugins/events/ready/index.ts +++ b/src/plugins/events/ready/index.ts @@ -3,9 +3,9 @@ import { Client } from "discord.js"; import logger from "../../../middlewares/logger"; // Helpers -import updatePresence from "../../../helpers/updatePresence"; import deployCommands from "../../../handlers/deployCommands"; import devMode from "../../../handlers/devMode"; +import updatePresence from "../../../helpers/updatePresence"; import { IEventOptions } from "../../../interfaces/EventOptions"; export const options: IEventOptions = { From e0d53feecdc299deed68e25220b4398e7c6a252e Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Thu, 25 Aug 2022 12:05:23 +0200 Subject: [PATCH 046/215] =?UTF-8?q?=F0=9F=8E=A8=20organized=20imports=20on?= =?UTF-8?q?=20helpers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/helpers/cooldown/index.ts | 4 ++-- src/helpers/dropGuild/index.ts | 4 ++-- src/helpers/getDiscordCommandJSON/index.ts | 8 ++------ src/helpers/getPluginCommandBuilder/index.ts | 1 - src/helpers/getPluginCommandOptions/index.ts | 1 - src/helpers/getPluginCommands/index.ts | 6 +++--- src/helpers/registerDiscordCommands/index.ts | 4 ++-- 7 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/helpers/cooldown/index.ts b/src/helpers/cooldown/index.ts index b8f3a55..12246e5 100644 --- a/src/helpers/cooldown/index.ts +++ b/src/helpers/cooldown/index.ts @@ -1,10 +1,10 @@ // Dependencies -import { CommandInteraction, ButtonInteraction, Message } from "discord.js"; +import { ButtonInteraction, CommandInteraction, Message } from "discord.js"; import logger from "../../middlewares/logger"; -import timeoutSchema from "../../models/timeout"; import addSeconds from "../../helpers/addSeconds"; +import timeoutSchema from "../../models/timeout"; export const command = async (i: CommandInteraction, cooldown: number) => { const { guild, user, commandId } = i; diff --git a/src/helpers/dropGuild/index.ts b/src/helpers/dropGuild/index.ts index d07c62c..8d770b3 100644 --- a/src/helpers/dropGuild/index.ts +++ b/src/helpers/dropGuild/index.ts @@ -1,9 +1,9 @@ -import guildSchema from "../../models/guild"; -import userSchema from "../../models/user"; import apiSchema from "../../models/api"; import counterSchema from "../../models/counter"; +import guildSchema from "../../models/guild"; import shopRoleSchema from "../../models/shopRole"; import timeoutSchema from "../../models/timeout"; +import userSchema from "../../models/user"; import logger from "../../middlewares/logger"; diff --git a/src/helpers/getDiscordCommandJSON/index.ts b/src/helpers/getDiscordCommandJSON/index.ts index 2fcf06f..f69deab 100644 --- a/src/helpers/getDiscordCommandJSON/index.ts +++ b/src/helpers/getDiscordCommandJSON/index.ts @@ -1,13 +1,9 @@ /* eslint-disable no-loops/no-loops */ -import path from "path"; -import listDir from "../listDir"; -import getPlugins from "../getPlugins"; -import getPluginCommands from "../getPluginCommands"; -import getPluginMetadata from "../getPluginMetadata"; -import getPluginCommandBuilder from "../getPluginCommandBuilder"; import { SlashCommandBuilder } from "discord.js"; import logger from "../../middlewares/logger"; +import getPluginCommands from "../getPluginCommands"; +import getPlugins from "../getPlugins"; export default async () => { logger.debug("Processing complete builder for plugins"); diff --git a/src/helpers/getPluginCommandBuilder/index.ts b/src/helpers/getPluginCommandBuilder/index.ts index f474ac4..c7036a4 100644 --- a/src/helpers/getPluginCommandBuilder/index.ts +++ b/src/helpers/getPluginCommandBuilder/index.ts @@ -1,5 +1,4 @@ import logger from "../../middlewares/logger"; -import listDir from "../listDir"; export default async (plugin: string, command: string) => { logger.debug(`Processing builder for command: ${command}`); diff --git a/src/helpers/getPluginCommandOptions/index.ts b/src/helpers/getPluginCommandOptions/index.ts index ba41950..e9e6a1d 100644 --- a/src/helpers/getPluginCommandOptions/index.ts +++ b/src/helpers/getPluginCommandOptions/index.ts @@ -1,5 +1,4 @@ import logger from "../../middlewares/logger"; -import listDir from "../listDir"; export default async (plugin: string, command: string) => { logger.debug(`Processing options for command: ${command}`); diff --git a/src/helpers/getPluginCommands/index.ts b/src/helpers/getPluginCommands/index.ts index 93bae18..96e4d0b 100644 --- a/src/helpers/getPluginCommands/index.ts +++ b/src/helpers/getPluginCommands/index.ts @@ -1,8 +1,8 @@ /* eslint-disable no-loops/no-loops */ -import getPluginCommandBuilder from "../getPluginCommandBuilder"; -import listDir from "../listDir"; -import getPluginCommandOptions from "../getPluginCommandOptions"; import logger from "../../middlewares/logger"; +import getPluginCommandBuilder from "../getPluginCommandBuilder"; +import getPluginCommandOptions from "../getPluginCommandOptions"; +import listDir from "../listDir"; export default async (plugin: string) => { logger.debug(`Processing commands for plugin: ${plugin}`); diff --git a/src/helpers/registerDiscordCommands/index.ts b/src/helpers/registerDiscordCommands/index.ts index 4ef501b..d258687 100644 --- a/src/helpers/registerDiscordCommands/index.ts +++ b/src/helpers/registerDiscordCommands/index.ts @@ -1,8 +1,8 @@ -import { Routes } from "discord.js"; import { REST } from "@discordjs/rest"; +import { Routes, SlashCommandBuilder } from "discord.js"; import logger from "../../middlewares/logger"; -export default async (builder: any) => { +export default async (builder: SlashCommandBuilder) => { const rest = new REST({ version: "10" }).setToken(process.env.DISCORD_TOKEN); await rest.put( From fcf9a095e5b057c284440d668494cac8bcbefaf9 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Thu, 25 Aug 2022 12:06:56 +0200 Subject: [PATCH 047/215] =?UTF-8?q?=F0=9F=8E=A8=20organized=20imports=20on?= =?UTF-8?q?=20managers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/managers/command/index.ts | 2 +- src/managers/index.ts | 6 +++--- src/managers/schedule/index.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/managers/command/index.ts b/src/managers/command/index.ts index 71306a6..40ab1d9 100644 --- a/src/managers/command/index.ts +++ b/src/managers/command/index.ts @@ -1,4 +1,4 @@ -import { Collection, Client } from "discord.js"; +import { Client } from "discord.js"; import listDir from "../../helpers/listDir"; import logger from "../../middlewares/logger"; diff --git a/src/managers/index.ts b/src/managers/index.ts index a1f3dad..47d7eb7 100644 --- a/src/managers/index.ts +++ b/src/managers/index.ts @@ -1,9 +1,9 @@ import { Client } from "discord.js"; -import * as database from "./database"; -import * as schedule from "./schedule"; -import * as event from "./event"; import * as command from "./command"; +import * as database from "./database"; +import * as event from "./event"; +import * as schedule from "./schedule"; export const start = async (client: Client) => { await database.connect(); diff --git a/src/managers/schedule/index.ts b/src/managers/schedule/index.ts index 18bf6ee..7e4cfdc 100644 --- a/src/managers/schedule/index.ts +++ b/src/managers/schedule/index.ts @@ -1,5 +1,5 @@ -import logger from "../../middlewares/logger"; import { Client } from "discord.js"; +import logger from "../../middlewares/logger"; import { IJob } from "../../interfaces/Job"; From 6ed5bb3cf3f8c68a390eb0007bf9e4e61cbe1714 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Thu, 25 Aug 2022 12:08:17 +0200 Subject: [PATCH 048/215] =?UTF-8?q?=F0=9F=9A=A8=20Null=20comparisons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/commands/config/modules/credits/index.ts | 2 +- src/plugins/commands/moderation/modules/prune/index.ts | 2 +- src/plugins/commands/shop/modules/roles/index.ts | 2 +- src/plugins/events/messageCreate/modules/counters/index.ts | 2 +- src/plugins/events/messageCreate/modules/credits/index.ts | 2 +- src/plugins/events/messageCreate/modules/points/index.ts | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/plugins/commands/config/modules/credits/index.ts b/src/plugins/commands/config/modules/credits/index.ts index 4535d74..245cc6f 100644 --- a/src/plugins/commands/config/modules/credits/index.ts +++ b/src/plugins/commands/config/modules/credits/index.ts @@ -55,7 +55,7 @@ export default { ); const { guild, options } = interaction; - if (guild == null) return; + if (!guild) return; const status = options?.getBoolean("status"); const rate = options?.getNumber("rate"); diff --git a/src/plugins/commands/moderation/modules/prune/index.ts b/src/plugins/commands/moderation/modules/prune/index.ts index 8abc31b..e10cf48 100644 --- a/src/plugins/commands/moderation/modules/prune/index.ts +++ b/src/plugins/commands/moderation/modules/prune/index.ts @@ -39,7 +39,7 @@ export default { ); const count = interaction.options.getInteger("count"); - if (count == null) return; + if (count === null) return; const bots = interaction.options.getBoolean("bots"); if (count < 1 || count > 100) { diff --git a/src/plugins/commands/shop/modules/roles/index.ts b/src/plugins/commands/shop/modules/roles/index.ts index 5f5d005..fe78d0c 100644 --- a/src/plugins/commands/shop/modules/roles/index.ts +++ b/src/plugins/commands/shop/modules/roles/index.ts @@ -21,7 +21,7 @@ export const builder = (group: SlashCommandSubcommandGroupBuilder) => { }; export const execute = async (interaction: ChatInputCommandInteraction) => { - if (interaction.guild == null) return; + if (!interaction.guild) return; const { options, guild } = interaction; const guildDB = await guildSchema?.findOne({ diff --git a/src/plugins/events/messageCreate/modules/counters/index.ts b/src/plugins/events/messageCreate/modules/counters/index.ts index c99c030..b5d8d68 100644 --- a/src/plugins/events/messageCreate/modules/counters/index.ts +++ b/src/plugins/events/messageCreate/modules/counters/index.ts @@ -7,7 +7,7 @@ export default { execute: async (message: Message) => { const { guild, author, content, channel } = message; - if (guild == null) return; + if (!guild) return; if (author.bot) return; if (channel?.type !== ChannelType.GuildText) return; diff --git a/src/plugins/events/messageCreate/modules/credits/index.ts b/src/plugins/events/messageCreate/modules/credits/index.ts index 3f282f7..3e12e6c 100644 --- a/src/plugins/events/messageCreate/modules/credits/index.ts +++ b/src/plugins/events/messageCreate/modules/credits/index.ts @@ -10,7 +10,7 @@ export default { execute: async (message: Message) => { const { guild, author, content, channel } = message; - if (guild == null) return; + if (!guild) return; if (author.bot) return; if (channel.type !== ChannelType.GuildText) return; diff --git a/src/plugins/events/messageCreate/modules/points/index.ts b/src/plugins/events/messageCreate/modules/points/index.ts index d2b2ab2..0d4bf6b 100644 --- a/src/plugins/events/messageCreate/modules/points/index.ts +++ b/src/plugins/events/messageCreate/modules/points/index.ts @@ -10,7 +10,7 @@ export default { execute: async (message: Message) => { const { guild, author, content, channel } = message; - if (guild == null) return; + if (!guild) return; if (author.bot) return; if (channel.type !== ChannelType.GuildText) return; From 0273d94e209ce2f065d611df020f7d5ee8893072 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 26 Aug 2022 17:34:31 +0000 Subject: [PATCH 049/215] Update dependency jest to v29 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e3ecb34..4dc183c 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "eslint-plugin-no-loops": "0.3.0", "eslint-plugin-prettier": "4.2.1", "husky": "8.0.1", - "jest": "28.1.3", + "jest": "29.0.1", "lint-staged": "13.0.3", "nodemon": "2.0.19", "prettier": "2.7.1" From 2afab025636e90e36e412aa6e3ccc4f6686a5ed3 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 26 Aug 2022 23:41:03 +0000 Subject: [PATCH 050/215] Update dependency eslint to v8.23.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e3ecb34..6e35ffa 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@types/uuid": "8.3.4", "@typescript-eslint/eslint-plugin": "5.35.1", "@typescript-eslint/parser": "5.35.1", - "eslint": "8.22.0", + "eslint": "8.23.0", "eslint-config-airbnb-base": "15.0.0", "eslint-config-prettier": "8.5.0", "eslint-plugin-import": "2.26.0", From f58a9b53ec5984e8182c4fb2a0c6e865b69cb5b2 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sun, 28 Aug 2022 00:16:11 +0200 Subject: [PATCH 051/215] =?UTF-8?q?=F0=9F=8E=A8=20reuse=20discord=20client?= =?UTF-8?q?=20when=20deploy=20commands?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/handlers/deployCommands/index.ts | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/src/handlers/deployCommands/index.ts b/src/handlers/deployCommands/index.ts index e7662e3..c8d175e 100644 --- a/src/handlers/deployCommands/index.ts +++ b/src/handlers/deployCommands/index.ts @@ -1,9 +1,7 @@ -import logger from "../../middlewares/logger"; -import { Client } from "discord.js"; -import { REST } from "@discordjs/rest"; -import { Routes } from "discord-api-types/v9"; import { RESTPostAPIApplicationCommandsJSONBody } from "discord-api-types/v10"; +import { Client } from "discord.js"; import { ICommand } from "../../interfaces/Command"; +import logger from "../../middlewares/logger"; export default async (client: Client) => { const commandList: Array = []; @@ -28,12 +26,8 @@ export default async (client: Client) => { throw new Error(`Could not gather command list: ${error}`); }); - const rest = new REST({ version: "9" }).setToken(process.env.DISCORD_TOKEN); - - await rest - .put(Routes.applicationCommands(process.env.DISCORD_CLIENT_ID), { - body: commandList, - }) + await client.application?.commands + .set(commandList, process.env.DISCORD_GUILD_ID) .then(async () => { logger.info(`Finished updating command list.`); }) @@ -42,16 +36,8 @@ export default async (client: Client) => { }); if (process.env.NODE_ENV !== "production") { - await rest - .put( - Routes.applicationGuildCommands( - process.env.DISCORD_CLIENT_ID, - process.env.DISCORD_GUILD_ID - ), - { - body: commandList, - } - ) + await client.application?.commands + .set(commandList) .then(async () => logger.info(`Finished updating guild command list.`)) .catch(async (error) => { logger.error(`${error}`); From b6c9954069295c5a476ebe295224f4b0d4d7ccb6 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sun, 28 Aug 2022 00:16:40 +0200 Subject: [PATCH 052/215] =?UTF-8?q?=F0=9F=9A=B8better=20config=20command?= =?UTF-8?q?=20for=20audits?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commands/config/modules/audits/index.ts | 49 ++++++++++--------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/src/plugins/commands/config/modules/audits/index.ts b/src/plugins/commands/config/modules/audits/index.ts index b440562..5ef3fac 100644 --- a/src/plugins/commands/config/modules/audits/index.ts +++ b/src/plugins/commands/config/modules/audits/index.ts @@ -34,43 +34,44 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { - const { successColor, footerText, footerIcon } = await getEmbedConfig( - interaction.guild - ); - const { guild, options } = interaction; + const { successColor, footerText, footerIcon } = await getEmbedConfig( + guild + ); + const status = options.getBoolean("status"); + const channel = options.getChannel("channel"); - const status = options?.getBoolean("status"); - const channel = options?.getChannel("channel"); - - const guildDB = await guildSchema?.findOne({ - guildId: guild?.id, + if (!guild) throw new Error("Guild not found."); + const guildDB = await guildSchema.findOne({ + guildId: guild.id, }); + if (!guildDB) throw new Error("Guild configuration not found."); - if (guildDB === null) { - return logger?.silly(`Guild not found in database.`); - } + guildDB.audits.status = status !== null ? status : guildDB.audits.status; + guildDB.audits.channelId = channel ? channel.id : guildDB.audits.channelId; - guildDB.audits.status = status !== null ? status : guildDB?.audits?.status; - guildDB.audits.channelId = - channel !== null ? channel.id : guildDB?.audits?.channelId; + await guildDB.save().then(async () => { + logger.verbose( + `Guild ${guild.name} updated their configuration for audits.` + ); - await guildDB?.save()?.then(async () => { - logger?.silly(`Guild audits updated.`); - - const interactionEmbed = new EmbedBuilder() + const embedSuccess = new EmbedBuilder() .setTitle("[:hammer:] Audits") - .setDescription("Audit settings updated!") + .setDescription("Guild configuration updated successfully.") .setColor(successColor) .addFields( { name: "🤖 Status", - value: `${guildDB?.audits?.status}`, + value: `${ + guildDB.audits.status + ? ":white_check_mark: Enabled" + : ":x: Disabled" + }`, inline: true, }, { name: "🌊 Channel", - value: `${guildDB?.audits?.channelId}`, + value: `<#${guildDB.audits.channelId}>`, inline: true, } ) @@ -80,8 +81,8 @@ export default { text: footerText, }); - return interaction?.editReply({ - embeds: [interactionEmbed], + return interaction.editReply({ + embeds: [embedSuccess], }); }); }, From 012d2ce6bf56e98bf23d8bcdf52236c1ebee3b43 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sun, 28 Aug 2022 00:17:04 +0200 Subject: [PATCH 053/215] =?UTF-8?q?=E2=9A=B0=EF=B8=8F=20organized=20import?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jobs/shop/modules/roles/components/overDueForPayment.ts | 2 +- src/jobs/shop/modules/roles/index.ts | 2 +- src/models/counter.ts | 2 +- src/models/guild.ts | 2 +- src/models/shopRole.ts | 2 +- src/models/timeout.ts | 2 +- src/models/user.ts | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/jobs/shop/modules/roles/components/overDueForPayment.ts b/src/jobs/shop/modules/roles/components/overDueForPayment.ts index e33b810..49b9c85 100644 --- a/src/jobs/shop/modules/roles/components/overDueForPayment.ts +++ b/src/jobs/shop/modules/roles/components/overDueForPayment.ts @@ -3,8 +3,8 @@ import logger from "../../../../../middlewares/logger"; import { IShopRole } from "../../../../../interfaces/ShopRole"; import guildSchema from "../../../../../models/guild"; -import userSchema from "../../../../../models/user"; import shopRoleSchema from "../../../../../models/shopRole"; +import userSchema from "../../../../../models/user"; export const execute = async (client: Client, role: IShopRole) => { const { guildId, userId, roleId } = role; diff --git a/src/jobs/shop/modules/roles/index.ts b/src/jobs/shop/modules/roles/index.ts index c8e393a..d4e2c21 100644 --- a/src/jobs/shop/modules/roles/index.ts +++ b/src/jobs/shop/modules/roles/index.ts @@ -3,8 +3,8 @@ import { Client } from "discord.js"; import { IShopRole } from "../../../../interfaces/ShopRole"; import shopRoleSchema from "../../../../models/shopRole"; -import * as overDueForPayment from "./components/overDueForPayment"; import * as dueForPayment from "./components/dueForPayment"; +import * as overDueForPayment from "./components/overDueForPayment"; export const execute = async (client: Client) => { const roles = await shopRoleSchema.find(); diff --git a/src/models/counter.ts b/src/models/counter.ts index fd274eb..a9c463a 100644 --- a/src/models/counter.ts +++ b/src/models/counter.ts @@ -1,5 +1,5 @@ -import { Schema, model } from "mongoose"; import { Snowflake } from "discord.js"; +import { model, Schema } from "mongoose"; export interface ICounter { guildId: Snowflake; diff --git a/src/models/guild.ts b/src/models/guild.ts index 44b6958..140befa 100644 --- a/src/models/guild.ts +++ b/src/models/guild.ts @@ -1,5 +1,5 @@ import { ColorResolvable } from "discord.js"; -import { Schema, model } from "mongoose"; +import { model, Schema } from "mongoose"; interface IGuild { guildId: string; diff --git a/src/models/shopRole.ts b/src/models/shopRole.ts index 19692fa..8711760 100644 --- a/src/models/shopRole.ts +++ b/src/models/shopRole.ts @@ -1,5 +1,5 @@ import { Snowflake } from "discord.js"; -import { Schema, model } from "mongoose"; +import { model, Schema } from "mongoose"; export interface IShopRole { roleId: Snowflake; diff --git a/src/models/timeout.ts b/src/models/timeout.ts index 0e3554c..dc1ba97 100644 --- a/src/models/timeout.ts +++ b/src/models/timeout.ts @@ -1,5 +1,5 @@ import { Snowflake } from "discord.js"; -import { Schema, model } from "mongoose"; +import { model, Schema } from "mongoose"; export interface ITimeout { userId: Snowflake; diff --git a/src/models/user.ts b/src/models/user.ts index 387ac7f..8170ac6 100644 --- a/src/models/user.ts +++ b/src/models/user.ts @@ -1,5 +1,5 @@ import { Snowflake } from "discord.js"; -import { Schema, model } from "mongoose"; +import { model, Schema } from "mongoose"; export interface IUser { guildId: Snowflake; From 0391798562c8a97a86145321b9f46f1b80586773 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 3 Sep 2022 11:31:02 +0000 Subject: [PATCH 054/215] Update dependency jest to v29.0.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bf94c32..2b0e451 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "eslint-plugin-no-loops": "0.3.0", "eslint-plugin-prettier": "4.2.1", "husky": "8.0.1", - "jest": "29.0.1", + "jest": "29.0.2", "lint-staged": "13.0.3", "nodemon": "2.0.19", "prettier": "2.7.1" From 60ccf3d63a9722bdfdd3ba295df7729119571e48 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 5 Sep 2022 19:50:23 +0000 Subject: [PATCH 055/215] Update typescript-eslint monorepo to v5.36.2 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bf94c32..914575e 100644 --- a/package.json +++ b/package.json @@ -57,8 +57,8 @@ "@types/chance": "1.1.3", "@types/node-schedule": "2.1.0", "@types/uuid": "8.3.4", - "@typescript-eslint/eslint-plugin": "5.35.1", - "@typescript-eslint/parser": "5.35.1", + "@typescript-eslint/eslint-plugin": "5.36.2", + "@typescript-eslint/parser": "5.36.2", "eslint": "8.23.0", "eslint-config-airbnb-base": "15.0.0", "eslint-config-prettier": "8.5.0", From d745f2f0113f6d09bf870339463dd060ad4b1d3d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 5 Sep 2022 23:56:02 +0000 Subject: [PATCH 056/215] Update dependency uuid to v9 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bf94c32..51504de 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "ts-node": "^10.7.0", "tsconfig-paths": "^4.0.0", "typescript": "^4.6.3", - "uuid": "^8.3.2", + "uuid": "^9.0.0", "winston-daily-rotate-file": "^4.6.1" }, "devDependencies": { From 9d3bfd71e7065716849e5a134fa5ff316b45d304 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 9 Sep 2022 07:55:09 +0000 Subject: [PATCH 057/215] Restyled by whitespace --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ed75827..9dbdaef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,4 +16,4 @@ WORKDIR /app RUN cp -r /build/build/* . RUN cp -r /build/node_modules . -CMD [ "node", "." ] \ No newline at end of file +CMD [ "node", "." ] From 5ca3ea35e11b6846bb01246c5355936b658dd7e5 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 10 Sep 2022 15:15:40 +0000 Subject: [PATCH 058/215] Update dependency jest to v29.0.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b8bce6e..c6f7edb 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "eslint-plugin-no-loops": "0.3.0", "eslint-plugin-prettier": "4.2.1", "husky": "8.0.1", - "jest": "29.0.2", + "jest": "29.0.3", "lint-staged": "13.0.3", "nodemon": "2.0.19", "prettier": "2.7.1" From eca4b548646f7c1f14d3a744770418d025797707 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 12 Sep 2022 06:11:12 +0000 Subject: [PATCH 059/215] Update dependency eslint to v8.23.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b8bce6e..4ef91fd 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "@types/uuid": "8.3.4", "@typescript-eslint/eslint-plugin": "5.36.2", "@typescript-eslint/parser": "5.36.2", - "eslint": "8.23.0", + "eslint": "8.23.1", "eslint-config-airbnb-base": "15.0.0", "eslint-config-prettier": "8.5.0", "eslint-plugin-import": "2.26.0", From 3710097aaf0c4c5c115c82d752800171a3720377 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 16 Sep 2022 15:46:24 +0000 Subject: [PATCH 060/215] Update dependency nodemon to v2.0.20 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b8bce6e..7de87b5 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "husky": "8.0.1", "jest": "29.0.2", "lint-staged": "13.0.3", - "nodemon": "2.0.19", + "nodemon": "2.0.20", "prettier": "2.7.1" }, "lint-staged": { From 8a95c30557241a925eb4a9d0eb4fd9f8f1fe52e1 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 20 Sep 2022 08:36:32 +0000 Subject: [PATCH 061/215] Update typescript-eslint monorepo to v5.38.0 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 03e73bf..7213ea3 100644 --- a/package.json +++ b/package.json @@ -57,8 +57,8 @@ "@types/chance": "1.1.3", "@types/node-schedule": "2.1.0", "@types/uuid": "8.3.4", - "@typescript-eslint/eslint-plugin": "5.36.2", - "@typescript-eslint/parser": "5.36.2", + "@typescript-eslint/eslint-plugin": "5.38.0", + "@typescript-eslint/parser": "5.38.0", "eslint": "8.23.1", "eslint-config-airbnb-base": "15.0.0", "eslint-config-prettier": "8.5.0", From d9761f3ef13f3a5dd56f7d1b6116a96b99e933e3 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 24 Sep 2022 01:30:24 +0000 Subject: [PATCH 062/215] Update dependency eslint to v8.24.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7213ea3..641f35d 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "@types/uuid": "8.3.4", "@typescript-eslint/eslint-plugin": "5.38.0", "@typescript-eslint/parser": "5.38.0", - "eslint": "8.23.1", + "eslint": "8.24.0", "eslint-config-airbnb-base": "15.0.0", "eslint-config-prettier": "8.5.0", "eslint-plugin-import": "2.26.0", From e92be5f881dc84dbc30fdebba5306edfb236a1ab Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 30 Sep 2022 09:34:01 +0000 Subject: [PATCH 063/215] Update dependency jest to v29.1.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 641f35d..d6f8148 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "eslint-plugin-no-loops": "0.3.0", "eslint-plugin-prettier": "4.2.1", "husky": "8.0.1", - "jest": "29.0.3", + "jest": "29.1.2", "lint-staged": "13.0.3", "nodemon": "2.0.20", "prettier": "2.7.1" From eee4371048626e7864514d42e9aa22f72abb39d1 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 4 Oct 2022 20:23:42 +0000 Subject: [PATCH 064/215] Update dependency axios to v1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 641f35d..968afdc 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "dependencies": { "@discordjs/rest": "^1.0.0", "@types/i18next-fs-backend": "^1.1.2", - "axios": "^0.27.2", + "axios": "^1.0.0", "chance": "^1.1.8", "common": "^0.2.5", "crypto": "^1.0.1", From 85418ee17ceeecbc86f41e1292691395250c2f6f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 8 Oct 2022 01:02:49 +0000 Subject: [PATCH 065/215] Update dependency eslint to v8.25.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 641f35d..b7c8e1b 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "@types/uuid": "8.3.4", "@typescript-eslint/eslint-plugin": "5.38.0", "@typescript-eslint/parser": "5.38.0", - "eslint": "8.24.0", + "eslint": "8.25.0", "eslint-config-airbnb-base": "15.0.0", "eslint-config-prettier": "8.5.0", "eslint-plugin-import": "2.26.0", From b37e6786c9e497c5744741ee523c5bd4424918df Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 13 Oct 2022 07:26:23 +0000 Subject: [PATCH 066/215] Update typescript-eslint monorepo to v5.40.0 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b7c8e1b..fad37aa 100644 --- a/package.json +++ b/package.json @@ -57,8 +57,8 @@ "@types/chance": "1.1.3", "@types/node-schedule": "2.1.0", "@types/uuid": "8.3.4", - "@typescript-eslint/eslint-plugin": "5.38.0", - "@typescript-eslint/parser": "5.38.0", + "@typescript-eslint/eslint-plugin": "5.40.0", + "@typescript-eslint/parser": "5.40.0", "eslint": "8.25.0", "eslint-config-airbnb-base": "15.0.0", "eslint-config-prettier": "8.5.0", From 593ad9a33595a083612104de55c72a64771092fd Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 14 Oct 2022 11:12:28 +0200 Subject: [PATCH 067/215] =?UTF-8?q?=F0=9F=9A=9A=20move=20handlers=20to=20h?= =?UTF-8?q?elpers=20and=20rename=20helpers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{listDir => checkDirectory}/index.ts | 0 src/helpers/deferReply/index.ts | 2 +- .../{dropGuild => deleteGuildData}/index.ts | 0 .../{dropUser => deleteUserData}/index.ts | 0 .../deployCommands/index.ts | 0 src/{handlers => helpers}/devMode/index.ts | 0 src/{handlers => helpers}/encryption/index.ts | 0 .../{getEmbedConfig => getEmbedData}/index.ts | 0 src/helpers/getPluginCommands/index.ts | 2 +- src/helpers/getPlugins/index.ts | 2 +- .../{fetchGuild => guildData}/index.ts | 0 src/helpers/{fetchUser => userData}/index.ts | 0 src/managers/command/index.ts | 5 ++--- src/managers/event/index.ts | 2 +- src/managers/schedule/index.ts | 9 +++----- .../commands/config/modules/audits/index.ts | 9 +++----- .../commands/config/modules/cpgg/index.ts | 9 +++----- .../commands/config/modules/credits/index.ts | 7 ++----- .../embeds/components/getValues/index.ts | 2 +- .../commands/config/modules/points/index.ts | 7 ++----- .../commands/config/modules/shop/index.ts | 7 ++----- .../commands/config/modules/welcome/index.ts | 9 +++----- .../commands/counters/modules/view/index.ts | 4 +--- .../commands/credits/modules/balance/index.ts | 6 ++---- .../commands/credits/modules/gift/index.ts | 17 ++++++++------- .../commands/credits/modules/top/index.ts | 4 +--- .../commands/credits/modules/work/index.ts | 21 ++++++++++--------- .../commands/dns/modules/lookup/index.ts | 6 ++---- .../commands/fun/modules/meme/index.ts | 2 +- .../modules/counters/modules/add/index.ts | 5 +---- .../modules/counters/modules/remove/index.ts | 11 ++++------ .../modules/credits/modules/give/index.ts | 14 +++++-------- .../modules/credits/modules/giveaway/index.ts | 10 ++++----- .../modules/credits/modules/set/index.ts | 15 +++++++------ .../modules/credits/modules/take/index.ts | 16 ++++++-------- .../modules/credits/modules/transfer/index.ts | 14 +++++-------- .../moderation/modules/prune/index.ts | 6 ++---- .../commands/profile/modules/view/index.ts | 13 +++++------- .../commands/reputation/modules/give/index.ts | 4 ++-- .../commands/shop/modules/cpgg/index.ts | 12 +++++------ .../shop/modules/roles/modules/buy/index.ts | 16 ++++++-------- .../modules/roles/modules/cancel/index.ts | 16 ++++++-------- .../commands/utility/modules/about/index.ts | 6 ++---- .../commands/utility/modules/avatar/index.ts | 3 +-- .../commands/utility/modules/ping/index.ts | 8 +++---- .../commands/utility/modules/stats/index.ts | 4 ++-- src/plugins/events/guildDelete/index.ts | 3 +-- src/plugins/events/guildMemberAdd/audits.ts | 4 +--- src/plugins/events/guildMemberAdd/index.ts | 9 +++----- .../events/guildMemberAdd/joinMessage.ts | 4 +--- .../events/guildMemberRemove/audits.ts | 4 +--- src/plugins/events/guildMemberRemove/index.ts | 3 +-- .../events/guildMemberRemove/leaveMessage.ts | 4 +--- .../events/interactionCreate/audits.ts | 4 +--- .../interactionCreate/handlers/index.ts | 3 +-- .../messageCreate/modules/credits/index.ts | 8 +++---- .../messageCreate/modules/points/index.ts | 10 ++++----- src/plugins/events/messageDelete/audits.ts | 4 +--- src/plugins/events/messageUpdate/audits.ts | 4 +--- src/plugins/events/ready/index.ts | 7 +++---- 60 files changed, 141 insertions(+), 235 deletions(-) rename src/helpers/{listDir => checkDirectory}/index.ts (100%) rename src/helpers/{dropGuild => deleteGuildData}/index.ts (100%) rename src/helpers/{dropUser => deleteUserData}/index.ts (100%) rename src/{handlers => helpers}/deployCommands/index.ts (100%) rename src/{handlers => helpers}/devMode/index.ts (100%) rename src/{handlers => helpers}/encryption/index.ts (100%) rename src/helpers/{getEmbedConfig => getEmbedData}/index.ts (100%) rename src/helpers/{fetchGuild => guildData}/index.ts (100%) rename src/helpers/{fetchUser => userData}/index.ts (100%) diff --git a/src/helpers/listDir/index.ts b/src/helpers/checkDirectory/index.ts similarity index 100% rename from src/helpers/listDir/index.ts rename to src/helpers/checkDirectory/index.ts diff --git a/src/helpers/deferReply/index.ts b/src/helpers/deferReply/index.ts index 790df34..ae9e16b 100644 --- a/src/helpers/deferReply/index.ts +++ b/src/helpers/deferReply/index.ts @@ -1,5 +1,5 @@ import { BaseInteraction, EmbedBuilder } from "discord.js"; -import getEmbedConfig from "../../helpers/getEmbedConfig"; +import getEmbedConfig from "../getEmbedData"; export default async (interaction: BaseInteraction, ephemeral: boolean) => { if (!interaction.isRepliable()) diff --git a/src/helpers/dropGuild/index.ts b/src/helpers/deleteGuildData/index.ts similarity index 100% rename from src/helpers/dropGuild/index.ts rename to src/helpers/deleteGuildData/index.ts diff --git a/src/helpers/dropUser/index.ts b/src/helpers/deleteUserData/index.ts similarity index 100% rename from src/helpers/dropUser/index.ts rename to src/helpers/deleteUserData/index.ts diff --git a/src/handlers/deployCommands/index.ts b/src/helpers/deployCommands/index.ts similarity index 100% rename from src/handlers/deployCommands/index.ts rename to src/helpers/deployCommands/index.ts diff --git a/src/handlers/devMode/index.ts b/src/helpers/devMode/index.ts similarity index 100% rename from src/handlers/devMode/index.ts rename to src/helpers/devMode/index.ts diff --git a/src/handlers/encryption/index.ts b/src/helpers/encryption/index.ts similarity index 100% rename from src/handlers/encryption/index.ts rename to src/helpers/encryption/index.ts diff --git a/src/helpers/getEmbedConfig/index.ts b/src/helpers/getEmbedData/index.ts similarity index 100% rename from src/helpers/getEmbedConfig/index.ts rename to src/helpers/getEmbedData/index.ts diff --git a/src/helpers/getPluginCommands/index.ts b/src/helpers/getPluginCommands/index.ts index 96e4d0b..33547c0 100644 --- a/src/helpers/getPluginCommands/index.ts +++ b/src/helpers/getPluginCommands/index.ts @@ -1,8 +1,8 @@ /* eslint-disable no-loops/no-loops */ import logger from "../../middlewares/logger"; +import listDir from "../checkDirectory"; import getPluginCommandBuilder from "../getPluginCommandBuilder"; import getPluginCommandOptions from "../getPluginCommandOptions"; -import listDir from "../listDir"; export default async (plugin: string) => { logger.debug(`Processing commands for plugin: ${plugin}`); diff --git a/src/helpers/getPlugins/index.ts b/src/helpers/getPlugins/index.ts index fbf9daa..4146a4f 100644 --- a/src/helpers/getPlugins/index.ts +++ b/src/helpers/getPlugins/index.ts @@ -1,5 +1,5 @@ import logger from "../../middlewares/logger"; -import listDir from "../listDir"; +import listDir from "../checkDirectory"; export default async (dir: string) => { logger.debug("Processing list of plugins..."); diff --git a/src/helpers/fetchGuild/index.ts b/src/helpers/guildData/index.ts similarity index 100% rename from src/helpers/fetchGuild/index.ts rename to src/helpers/guildData/index.ts diff --git a/src/helpers/fetchUser/index.ts b/src/helpers/userData/index.ts similarity index 100% rename from src/helpers/fetchUser/index.ts rename to src/helpers/userData/index.ts diff --git a/src/managers/command/index.ts b/src/managers/command/index.ts index 40ab1d9..5f43be4 100644 --- a/src/managers/command/index.ts +++ b/src/managers/command/index.ts @@ -1,8 +1,7 @@ import { Client } from "discord.js"; -import listDir from "../../helpers/listDir"; -import logger from "../../middlewares/logger"; - +import listDir from "../../helpers/checkDirectory"; import { ICommand } from "../../interfaces/Command"; +import logger from "../../middlewares/logger"; export const register = async (client: Client) => { // Get name of directories containing commands diff --git a/src/managers/event/index.ts b/src/managers/event/index.ts index 9a58e18..c0734ba 100644 --- a/src/managers/event/index.ts +++ b/src/managers/event/index.ts @@ -1,6 +1,6 @@ /* eslint-disable no-loops/no-loops */ import { Client } from "discord.js"; -import listDir from "../../helpers/listDir"; +import listDir from "../../helpers/checkDirectory"; import { IEvent } from "../../interfaces/Event"; import logger from "../../middlewares/logger"; diff --git a/src/managers/schedule/index.ts b/src/managers/schedule/index.ts index 7e4cfdc..ab8e51f 100644 --- a/src/managers/schedule/index.ts +++ b/src/managers/schedule/index.ts @@ -1,11 +1,8 @@ import { Client } from "discord.js"; -import logger from "../../middlewares/logger"; - -import { IJob } from "../../interfaces/Job"; - -import listDir from "../../helpers/listDir"; - import schedule from "node-schedule"; +import listDir from "../../helpers/checkDirectory"; +import { IJob } from "../../interfaces/Job"; +import logger from "../../middlewares/logger"; export const start = async (client: Client) => { logger.info("⏰ Started job management"); diff --git a/src/plugins/commands/config/modules/audits/index.ts b/src/plugins/commands/config/modules/audits/index.ts index 5ef3fac..c8de0ad 100644 --- a/src/plugins/commands/config/modules/audits/index.ts +++ b/src/plugins/commands/config/modules/audits/index.ts @@ -1,15 +1,12 @@ +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import { ChannelType } from "discord-api-types/v10"; import { ChatInputCommandInteraction, EmbedBuilder, PermissionsBitField, } from "discord.js"; - -import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; - +import getEmbedConfig from "../../../../../helpers/getEmbedData"; import logger from "../../../../../middlewares/logger"; - -import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import { ChannelType } from "discord-api-types/v10"; import guildSchema from "../../../../../models/guild"; export default { diff --git a/src/plugins/commands/config/modules/cpgg/index.ts b/src/plugins/commands/config/modules/cpgg/index.ts index 80caa14..a4297ad 100644 --- a/src/plugins/commands/config/modules/cpgg/index.ts +++ b/src/plugins/commands/config/modules/cpgg/index.ts @@ -1,15 +1,12 @@ +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction, EmbedBuilder, PermissionsBitField, } from "discord.js"; - -import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; - +import encryption from "../../../../../helpers/encryption"; +import getEmbedConfig from "../../../../../helpers/getEmbedData"; import logger from "../../../../../middlewares/logger"; - -import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import encryption from "../../../../../handlers/encryption"; import apiSchema from "../../../../../models/api"; export default { diff --git a/src/plugins/commands/config/modules/credits/index.ts b/src/plugins/commands/config/modules/credits/index.ts index 245cc6f..436d26f 100644 --- a/src/plugins/commands/config/modules/credits/index.ts +++ b/src/plugins/commands/config/modules/credits/index.ts @@ -1,14 +1,11 @@ +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction, EmbedBuilder, PermissionsBitField, } from "discord.js"; - -import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; - +import getEmbedConfig from "../../../../../helpers/getEmbedData"; import logger from "../../../../../middlewares/logger"; - -import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import guildSchema from "../../../../../models/guild"; export default { diff --git a/src/plugins/commands/config/modules/embeds/components/getValues/index.ts b/src/plugins/commands/config/modules/embeds/components/getValues/index.ts index bc49e1f..068b82c 100644 --- a/src/plugins/commands/config/modules/embeds/components/getValues/index.ts +++ b/src/plugins/commands/config/modules/embeds/components/getValues/index.ts @@ -1,5 +1,5 @@ import { ChatInputCommandInteraction, ColorResolvable } from "discord.js"; -import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; +import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; import guildSchema from "../../../../../../../models/guild"; export default async (interaction: ChatInputCommandInteraction) => { diff --git a/src/plugins/commands/config/modules/points/index.ts b/src/plugins/commands/config/modules/points/index.ts index 9b73eb1..7e1c6dc 100644 --- a/src/plugins/commands/config/modules/points/index.ts +++ b/src/plugins/commands/config/modules/points/index.ts @@ -1,14 +1,11 @@ +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction, EmbedBuilder, PermissionsBitField, } from "discord.js"; - -import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; - +import getEmbedConfig from "../../../../../helpers/getEmbedData"; import logger from "../../../../../middlewares/logger"; - -import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import guildSchema from "../../../../../models/guild"; export default { diff --git a/src/plugins/commands/config/modules/shop/index.ts b/src/plugins/commands/config/modules/shop/index.ts index 0e10d9f..8a6ceb7 100644 --- a/src/plugins/commands/config/modules/shop/index.ts +++ b/src/plugins/commands/config/modules/shop/index.ts @@ -1,14 +1,11 @@ +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction, EmbedBuilder, PermissionsBitField, } from "discord.js"; - -import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; - +import getEmbedConfig from "../../../../../helpers/getEmbedData"; import logger from "../../../../../middlewares/logger"; - -import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import guildSchema from "../../../../../models/guild"; export default { diff --git a/src/plugins/commands/config/modules/welcome/index.ts b/src/plugins/commands/config/modules/welcome/index.ts index 919711e..61a9436 100644 --- a/src/plugins/commands/config/modules/welcome/index.ts +++ b/src/plugins/commands/config/modules/welcome/index.ts @@ -1,15 +1,12 @@ +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import { ChannelType } from "discord-api-types/v10"; import { ChatInputCommandInteraction, EmbedBuilder, PermissionsBitField, } from "discord.js"; - -import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; - +import getEmbedConfig from "../../../../../helpers/getEmbedData"; import logger from "../../../../../middlewares/logger"; - -import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import { ChannelType } from "discord-api-types/v10"; import guildSchema from "../../../../../models/guild"; export default { diff --git a/src/plugins/commands/counters/modules/view/index.ts b/src/plugins/commands/counters/modules/view/index.ts index 81e1147..679b68e 100644 --- a/src/plugins/commands/counters/modules/view/index.ts +++ b/src/plugins/commands/counters/modules/view/index.ts @@ -1,9 +1,7 @@ -import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; - import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChannelType } from "discord-api-types/v10"; import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js"; - +import getEmbedConfig from "../../../../../helpers/getEmbedData"; import counterSchema from "../../../../../models/counter"; export default { diff --git a/src/plugins/commands/credits/modules/balance/index.ts b/src/plugins/commands/credits/modules/balance/index.ts index 57afd75..3cddb4b 100644 --- a/src/plugins/commands/credits/modules/balance/index.ts +++ b/src/plugins/commands/credits/modules/balance/index.ts @@ -1,11 +1,9 @@ -import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; - import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { CommandInteraction, EmbedBuilder } from "discord.js"; +import getEmbedConfig from "../../../../../helpers/getEmbedData"; +import fetchUser from "../../../../../helpers/userData"; import logger from "../../../../../middlewares/logger"; -import fetchUser from "../../../../../helpers/fetchUser"; - export default { metadata: { guildOnly: true, ephemeral: true }, builder: (command: SlashCommandSubcommandBuilder) => { diff --git a/src/plugins/commands/credits/modules/gift/index.ts b/src/plugins/commands/credits/modules/gift/index.ts index fba20f1..b2dfabe 100644 --- a/src/plugins/commands/credits/modules/gift/index.ts +++ b/src/plugins/commands/credits/modules/gift/index.ts @@ -1,17 +1,18 @@ // Dependencies import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js"; - +import mongoose from "mongoose"; // Configurations -import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; - +import getEmbedConfig from "../../../../../helpers/getEmbedData"; +import fetchUser from "../../../../../helpers/userData"; // Handlers import logger from "../../../../../middlewares/logger"; - -import mongoose from "mongoose"; - // Models -import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import fetchUser from "../../../../../helpers/fetchUser"; +import { SlashCommandSu } from /../../../../ helpers / userDatajs / builders; + + + + +"; // Function export default { diff --git a/src/plugins/commands/credits/modules/top/index.ts b/src/plugins/commands/credits/modules/top/index.ts index 6c3bec7..0ad0bb1 100644 --- a/src/plugins/commands/credits/modules/top/index.ts +++ b/src/plugins/commands/credits/modules/top/index.ts @@ -1,9 +1,7 @@ -import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; - import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { CommandInteraction, EmbedBuilder } from "discord.js"; +import getEmbedConfig from "../../../../../helpers/getEmbedData"; import logger from "../../../../../middlewares/logger"; - import userSchema, { IUser } from "../../../../../models/user"; export default { diff --git a/src/plugins/commands/credits/modules/work/index.ts b/src/plugins/commands/credits/modules/work/index.ts index 5354752..9291d45 100644 --- a/src/plugins/commands/credits/modules/work/index.ts +++ b/src/plugins/commands/credits/modules/work/index.ts @@ -2,19 +2,20 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import Chance from "chance"; import { CommandInteraction, EmbedBuilder } from "discord.js"; - -// Configurations -import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; - -// Handlers -import logger from "../../../../../middlewares/logger"; - // Models import * as cooldown from "../../../../../helpers/cooldown"; - +// Configurations +import getEmbedConfig from "../../../../../helpers/getEmbedData"; +import fetchUser from "../../../../../helpers/userData"; +// Handlers +import logger from "../../../../../middlewares/logger"; // Helpers -import fetchGuild from "../../../../../helpers/fetchGuild"; -import fetchUser from "../../../../../helpers/fetchUser"; +import fetchGuild from../../../../../ helpers / userDatald; + + + + +"; export default { metadata: { guildOnly: true, ephemeral: true }, diff --git a/src/plugins/commands/dns/modules/lookup/index.ts b/src/plugins/commands/dns/modules/lookup/index.ts index 54635e1..47f0785 100644 --- a/src/plugins/commands/dns/modules/lookup/index.ts +++ b/src/plugins/commands/dns/modules/lookup/index.ts @@ -1,9 +1,7 @@ +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import axios from "axios"; import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js"; - -import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; - -import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import getEmbedConfig from "../../../../../helpers/getEmbedData"; export default { metadata: { guildOnly: false, ephemeral: false }, diff --git a/src/plugins/commands/fun/modules/meme/index.ts b/src/plugins/commands/fun/modules/meme/index.ts index 9ad5a48..9709014 100644 --- a/src/plugins/commands/fun/modules/meme/index.ts +++ b/src/plugins/commands/fun/modules/meme/index.ts @@ -1,7 +1,7 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import axios from "axios"; import { CommandInteraction, EmbedBuilder } from "discord.js"; -import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; +import getEmbedConfig from "../../../../../helpers/getEmbedData"; export default { metadata: { guildOnly: false, ephemeral: false, cooldown: 15 }, diff --git a/src/plugins/commands/manage/modules/counters/modules/add/index.ts b/src/plugins/commands/manage/modules/counters/modules/add/index.ts index 2b95f9a..f73d6e5 100644 --- a/src/plugins/commands/manage/modules/counters/modules/add/index.ts +++ b/src/plugins/commands/manage/modules/counters/modules/add/index.ts @@ -6,12 +6,9 @@ import { EmbedBuilder, PermissionsBitField, } from "discord.js"; - // Configurations -import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; - +import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; import logger from "../../../../../../../middlewares/logger"; - // Models import counterSchema from "../../../../../../../models/counter"; diff --git a/src/plugins/commands/manage/modules/counters/modules/remove/index.ts b/src/plugins/commands/manage/modules/counters/modules/remove/index.ts index 096fda7..8b21059 100644 --- a/src/plugins/commands/manage/modules/counters/modules/remove/index.ts +++ b/src/plugins/commands/manage/modules/counters/modules/remove/index.ts @@ -1,19 +1,16 @@ // Dependencies +// Models +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import { ChannelType } from "discord-api-types/v10"; import { ChatInputCommandInteraction, EmbedBuilder, PermissionsBitField, } from "discord.js"; - // Configurations -import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; - +import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; // Handlers import logger from "../../../../../../../middlewares/logger"; - -// Models -import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import { ChannelType } from "discord-api-types/v10"; import counterSchema from "../../../../../../../models/counter"; // Function diff --git a/src/plugins/commands/manage/modules/credits/modules/give/index.ts b/src/plugins/commands/manage/modules/credits/modules/give/index.ts index e797afd..c59bb5a 100644 --- a/src/plugins/commands/manage/modules/credits/modules/give/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/give/index.ts @@ -5,19 +5,15 @@ import { EmbedBuilder, PermissionsBitField, } from "discord.js"; - // Configurations -import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; - +import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; +// Helpers../../../../../../../helpers/userData +import pluralize from "../../../../../../../helpers/pluralize"; +// Models +import fetchUser from "../../../../../../../helpers/userData"; // Handlers import logger from "../../../../../../../middlewares/logger"; -// Helpers -import pluralize from "../../../../../../../helpers/pluralize"; - -// Models -import fetchUser from "../../../../../../../helpers/fetchUser"; - // Function export default { metadata: { diff --git a/src/plugins/commands/manage/modules/credits/modules/giveaway/index.ts b/src/plugins/commands/manage/modules/credits/modules/giveaway/index.ts index 246b00a..93ac561 100644 --- a/src/plugins/commands/manage/modules/credits/modules/giveaway/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/giveaway/index.ts @@ -1,6 +1,7 @@ // Dependencies import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import axios from "axios"; +import { ButtonStyle, ChannelType } from "discord-api-types/v10"; import { ActionRowBuilder, ButtonBuilder, @@ -9,13 +10,10 @@ import { PermissionsBitField, } from "discord.js"; import { v4 as uuidv4 } from "uuid"; -import encryption from "../../../../../../../handlers/encryption"; -import apiSchema from "../../../../../../../models/api"; - +import encryption from "../../../../../../../helpers/encryption"; // Configurations -import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; - -import { ButtonStyle, ChannelType } from "discord-api-types/v10"; +import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; +import apiSchema from "../../../../../../../models/api"; // Function export default { diff --git a/src/plugins/commands/manage/modules/credits/modules/set/index.ts b/src/plugins/commands/manage/modules/credits/modules/set/index.ts index 9e2a63c..294f30a 100644 --- a/src/plugins/commands/manage/modules/credits/modules/set/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/set/index.ts @@ -1,21 +1,20 @@ // Dependencies +// Helpers +// Models +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction, EmbedBuilder, - PermissionsBitField, + PermissionsBitField } from "discord.js"; - // Configurations -import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; - +import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; +import fetchUser from "../../../../../../../helpers/userData"; // Handlers import logger from "../../../../../../../middlewares/logger"; -// Helpers -// Models -import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import fetchUser from "../../../../../../../helpers/fetchUser"; +../../../../../../../helpers/userData // Function export default { diff --git a/src/plugins/commands/manage/modules/credits/modules/take/index.ts b/src/plugins/commands/manage/modules/credits/modules/take/index.ts index 707a149..20b5445 100644 --- a/src/plugins/commands/manage/modules/credits/modules/take/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/take/index.ts @@ -1,23 +1,19 @@ // Dependencies +// Models +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction, EmbedBuilder, PermissionsBitField, } from "discord.js"; - // Configurations -import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; - +import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; +// Helpers../../../../../../../helpers/userData +import pluralize from "../../../../../../../helpers/pluralize"; +import fetchUser from "../../../../../../../helpers/userData"; // Handlers import logger from "../../../../../../../middlewares/logger"; -// Helpers -import pluralize from "../../../../../../../helpers/pluralize"; - -// Models -import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import fetchUser from "../../../../../../../helpers/fetchUser"; - // Function export default { metadata: { diff --git a/src/plugins/commands/manage/modules/credits/modules/transfer/index.ts b/src/plugins/commands/manage/modules/credits/modules/transfer/index.ts index e8a1c00..2d790b8 100644 --- a/src/plugins/commands/manage/modules/credits/modules/transfer/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/transfer/index.ts @@ -1,22 +1,18 @@ // Dependencies +// Models +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction, EmbedBuilder, PermissionsBitField, } from "discord.js"; - import mongoose from "mongoose"; - // Configurations -import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; - -// Handlers +import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; +import fetchUser from "../../../../../../../helpers/userData"; +// Handlers../../../../../../../helpers/userData import logger from "../../../../../../../middlewares/logger"; -// Models -import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import fetchUser from "../../../../../../../helpers/fetchUser"; - // Function export default { metadata: { diff --git a/src/plugins/commands/moderation/modules/prune/index.ts b/src/plugins/commands/moderation/modules/prune/index.ts index e10cf48..b5e909e 100644 --- a/src/plugins/commands/moderation/modules/prune/index.ts +++ b/src/plugins/commands/moderation/modules/prune/index.ts @@ -1,15 +1,13 @@ // Dependencies +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChannelType, ChatInputCommandInteraction, EmbedBuilder, PermissionsBitField, } from "discord.js"; - // Configurations -import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; - -import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import getEmbedConfig from "../../../../../helpers/getEmbedData"; // Function export default { diff --git a/src/plugins/commands/profile/modules/view/index.ts b/src/plugins/commands/profile/modules/view/index.ts index fe4474b..a17ac18 100644 --- a/src/plugins/commands/profile/modules/view/index.ts +++ b/src/plugins/commands/profile/modules/view/index.ts @@ -1,13 +1,10 @@ // Dependencies -import { CommandInteraction, EmbedBuilder } from "discord.js"; - -// Configurations -import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; - -// Models -import fetchUser from "../../../../../helpers/fetchUser"; - import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import { CommandInteraction, EmbedBuilder } from "discord.js"; +// Configurations +import getEmbedConfig from "../../../../../helpers/getEmbedData"; +// Models +import fetchUser from "../../../../../helpers/userData"; import logger from "../../../../../middlewares/logger"; // Function diff --git a/src/plugins/commands/reputation/modules/give/index.ts b/src/plugins/commands/reputation/modules/give/index.ts index 7faa784..44f0155 100644 --- a/src/plugins/commands/reputation/modules/give/index.ts +++ b/src/plugins/commands/reputation/modules/give/index.ts @@ -1,8 +1,8 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js"; import * as cooldown from "../../../../../helpers/cooldown"; -import fetchUser from "../../../../../helpers/fetchUser"; -import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; +import getEmbedConfig from "../../../../../helpers/getEmbedData"; +import fetchUser from "../../../../../helpers/userData"; import logger from "../../../../../middlewares/logger"; import noSelfReputation from "./components/noSelfReputation"; diff --git a/src/plugins/commands/shop/modules/cpgg/index.ts b/src/plugins/commands/shop/modules/cpgg/index.ts index c868e83..124d12b 100644 --- a/src/plugins/commands/shop/modules/cpgg/index.ts +++ b/src/plugins/commands/shop/modules/cpgg/index.ts @@ -1,3 +1,4 @@ +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import axios from "axios"; import { ActionRowBuilder, @@ -8,14 +9,11 @@ import { Message, } from "discord.js"; import { v4 as uuidv4 } from "uuid"; - -import encryption from "../../../../../handlers/encryption"; -import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; -import logger from "../../../../../middlewares/logger"; - -import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import fetchUser from "../../../../../helpers/fetchUser"; +import encryption from "../../../../../helpers/encryption"; +import getEmbedConfig from "../../../../../helpers/getEmbedData"; import pluralize from "../../../../../helpers/pluralize"; +import fetchUser from "../../../../../helpers/userData"; +import logger from "../../../../../middlewares/logger"; import apiSchema from "../../../../../models/api"; export default { diff --git a/src/plugins/commands/shop/modules/roles/modules/buy/index.ts b/src/plugins/commands/shop/modules/roles/modules/buy/index.ts index 2ed7cdf..194ccb7 100644 --- a/src/plugins/commands/shop/modules/roles/modules/buy/index.ts +++ b/src/plugins/commands/shop/modules/roles/modules/buy/index.ts @@ -1,25 +1,21 @@ // Dependencies +// Helpers +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction, ColorResolvable, EmbedBuilder, GuildMemberRoleManager, } from "discord.js"; - // Configurations -import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; - +import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; +import pluralize from "../../../../../../../helpers/pluralize"; +import fetchUser from "../../../../../../../helpers/userData"; +import logger from "../../../../../../../middlewares/logger"; // Models import guildSchema from "../../../../../../../models/guild"; import shopRolesSchema from "../../../../../../../models/shopRole"; -import logger from "../../../../../../../middlewares/logger"; - -// Helpers -import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import fetchUser from "../../../../../../../helpers/fetchUser"; -import pluralize from "../../../../../../../helpers/pluralize"; - // Function export default { metadata: { guildOnly: true, ephemeral: true }, diff --git a/src/plugins/commands/shop/modules/roles/modules/cancel/index.ts b/src/plugins/commands/shop/modules/roles/modules/cancel/index.ts index 225b42a..a2d92d2 100644 --- a/src/plugins/commands/shop/modules/roles/modules/cancel/index.ts +++ b/src/plugins/commands/shop/modules/roles/modules/cancel/index.ts @@ -1,23 +1,19 @@ // Dependencies +// Helpers +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction, EmbedBuilder, GuildMemberRoleManager, } from "discord.js"; - // Configurations -import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; - +import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; +import pluralize from "../../../../../../../helpers/pluralize"; +import fetchUser from "../../../../../../../helpers/userData"; +import logger from "../../../../../../../middlewares/logger"; // Models import shopRolesSchema from "../../../../../../../models/shopRole"; -import logger from "../../../../../../../middlewares/logger"; - -// Helpers -import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import fetchUser from "../../../../../../../helpers/fetchUser"; -import pluralize from "../../../../../../../helpers/pluralize"; - // Function export default { metadata: { guildOnly: true, ephemeral: true }, diff --git a/src/plugins/commands/utility/modules/about/index.ts b/src/plugins/commands/utility/modules/about/index.ts index 6fee2f3..5dfc051 100644 --- a/src/plugins/commands/utility/modules/about/index.ts +++ b/src/plugins/commands/utility/modules/about/index.ts @@ -1,4 +1,5 @@ // Dependencies +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ActionRowBuilder, ButtonBuilder, @@ -6,11 +7,8 @@ import { CommandInteraction, EmbedBuilder, } from "discord.js"; - // Configurations -import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; - -import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import getEmbedConfig from "../../../../../helpers/getEmbedData"; // Function export default { diff --git a/src/plugins/commands/utility/modules/avatar/index.ts b/src/plugins/commands/utility/modules/avatar/index.ts index 20f8edd..5a935a0 100644 --- a/src/plugins/commands/utility/modules/avatar/index.ts +++ b/src/plugins/commands/utility/modules/avatar/index.ts @@ -1,7 +1,6 @@ -import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; - import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { CommandInteraction, EmbedBuilder } from "discord.js"; +import getEmbedConfig from "../../../../../helpers/getEmbedData"; export default { metadata: { guildOnly: false, ephemeral: false }, diff --git a/src/plugins/commands/utility/modules/ping/index.ts b/src/plugins/commands/utility/modules/ping/index.ts index 96aee27..60b5d3f 100644 --- a/src/plugins/commands/utility/modules/ping/index.ts +++ b/src/plugins/commands/utility/modules/ping/index.ts @@ -1,10 +1,8 @@ // Dependencies -import { CommandInteraction, EmbedBuilder } from "discord.js"; - -// Configurations -import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; - import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import { CommandInteraction, EmbedBuilder } from "discord.js"; +// Configurations +import getEmbedConfig from "../../../../../helpers/getEmbedData"; // Function export default { diff --git a/src/plugins/commands/utility/modules/stats/index.ts b/src/plugins/commands/utility/modules/stats/index.ts index a90c289..d552c86 100644 --- a/src/plugins/commands/utility/modules/stats/index.ts +++ b/src/plugins/commands/utility/modules/stats/index.ts @@ -1,7 +1,7 @@ -import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; - import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { CommandInteraction, EmbedBuilder } from "discord.js"; +import getEmbedConfig from "../../../../../helpers/getEmbedData"; + export default { metadata: { guildOnly: false, ephemeral: false }, diff --git a/src/plugins/events/guildDelete/index.ts b/src/plugins/events/guildDelete/index.ts index 5d7bde0..c3355d5 100644 --- a/src/plugins/events/guildDelete/index.ts +++ b/src/plugins/events/guildDelete/index.ts @@ -1,8 +1,7 @@ // 3rd party dependencies import { Guild } from "discord.js"; - // Dependencies -import dropGuild from "../../../helpers/dropGuild"; +import dropGuild from "../../../helpers/deleteGuildData"; import updatePresence from "../../../helpers/updatePresence"; import { IEventOptions } from "../../../interfaces/EventOptions"; import logger from "../../../middlewares/logger"; diff --git a/src/plugins/events/guildMemberAdd/audits.ts b/src/plugins/events/guildMemberAdd/audits.ts index e5b1e67..7710fac 100644 --- a/src/plugins/events/guildMemberAdd/audits.ts +++ b/src/plugins/events/guildMemberAdd/audits.ts @@ -1,10 +1,8 @@ import { ChannelType, EmbedBuilder, GuildMember } from "discord.js"; +import getEmbedConfig from "../../../helpers/getEmbedData"; import logger from "../../../middlewares/logger"; - import guildSchema from "../../../models/guild"; -import getEmbedConfig from "../../../helpers/getEmbedConfig"; - export default { execute: async (member: GuildMember) => { const { client, guild } = member; diff --git a/src/plugins/events/guildMemberAdd/index.ts b/src/plugins/events/guildMemberAdd/index.ts index a5efdb9..d65f42a 100644 --- a/src/plugins/events/guildMemberAdd/index.ts +++ b/src/plugins/events/guildMemberAdd/index.ts @@ -1,16 +1,13 @@ // 3rd party dependencies import { GuildMember } from "discord.js"; - -// Dependencies -import fetchUser from "../../../helpers/fetchUser"; import updatePresence from "../../../helpers/updatePresence"; +// Dependencies +import fetchUser from "../../../helpers/userData"; +import { IEventOptions } from "../../../interfaces/EventOptions"; import logger from "../../../middlewares/logger"; - import audits from "./audits"; import joinMessage from "./joinMessage"; -import { IEventOptions } from "../../../interfaces/EventOptions"; - export const options: IEventOptions = { type: "on", }; diff --git a/src/plugins/events/guildMemberAdd/joinMessage.ts b/src/plugins/events/guildMemberAdd/joinMessage.ts index 7bf5889..a50dca6 100644 --- a/src/plugins/events/guildMemberAdd/joinMessage.ts +++ b/src/plugins/events/guildMemberAdd/joinMessage.ts @@ -1,9 +1,7 @@ import { EmbedBuilder, GuildMember, TextChannel } from "discord.js"; - +import getEmbedConfig from "../../../helpers/getEmbedData"; import guildSchema from "../../../models/guild"; -import getEmbedConfig from "../../../helpers/getEmbedConfig"; - export default { execute: async (member: GuildMember) => { const { footerText, footerIcon, successColor } = await getEmbedConfig( diff --git a/src/plugins/events/guildMemberRemove/audits.ts b/src/plugins/events/guildMemberRemove/audits.ts index 522e132..72391fa 100644 --- a/src/plugins/events/guildMemberRemove/audits.ts +++ b/src/plugins/events/guildMemberRemove/audits.ts @@ -1,10 +1,8 @@ import { ChannelType, EmbedBuilder, GuildMember } from "discord.js"; +import getEmbedConfig from "../../../helpers/getEmbedData"; import logger from "../../../middlewares/logger"; - import guildSchema from "../../../models/guild"; -import getEmbedConfig from "../../../helpers/getEmbedConfig"; - export default { execute: async (member: GuildMember) => { const { client, guild } = member; diff --git a/src/plugins/events/guildMemberRemove/index.ts b/src/plugins/events/guildMemberRemove/index.ts index 5ee1bec..9c1bcbf 100644 --- a/src/plugins/events/guildMemberRemove/index.ts +++ b/src/plugins/events/guildMemberRemove/index.ts @@ -1,8 +1,7 @@ // 3rd party dependencies import { GuildMember } from "discord.js"; - // Dependencies -import dropUser from "../../../helpers/dropUser"; +import dropUser from "../../../helpers/deleteUserData"; import updatePresence from "../../../helpers/updatePresence"; import { IEventOptions } from "../../../interfaces/EventOptions"; import logger from "../../../middlewares/logger"; diff --git a/src/plugins/events/guildMemberRemove/leaveMessage.ts b/src/plugins/events/guildMemberRemove/leaveMessage.ts index 8792af5..7e0cc09 100644 --- a/src/plugins/events/guildMemberRemove/leaveMessage.ts +++ b/src/plugins/events/guildMemberRemove/leaveMessage.ts @@ -1,9 +1,7 @@ import { EmbedBuilder, GuildMember, TextChannel } from "discord.js"; - +import getEmbedConfig from "../../../helpers/getEmbedData"; import guildSchema from "../../../models/guild"; -import getEmbedConfig from "../../../helpers/getEmbedConfig"; - export default { execute: async (member: GuildMember) => { const { footerText, footerIcon, errorColor } = await getEmbedConfig( diff --git a/src/plugins/events/interactionCreate/audits.ts b/src/plugins/events/interactionCreate/audits.ts index e8de61c..e4ebd19 100644 --- a/src/plugins/events/interactionCreate/audits.ts +++ b/src/plugins/events/interactionCreate/audits.ts @@ -1,10 +1,8 @@ import { BaseInteraction, EmbedBuilder, TextChannel } from "discord.js"; +import getEmbedConfig from "../../../helpers/getEmbedData"; import logger from "../../../middlewares/logger"; - import guildSchema from "../../../models/guild"; -import getEmbedConfig from "../../../helpers/getEmbedConfig"; - export default { execute: async (interaction: BaseInteraction) => { if (interaction === null) return; diff --git a/src/plugins/events/interactionCreate/handlers/index.ts b/src/plugins/events/interactionCreate/handlers/index.ts index d6fad1b..d596913 100644 --- a/src/plugins/events/interactionCreate/handlers/index.ts +++ b/src/plugins/events/interactionCreate/handlers/index.ts @@ -5,8 +5,7 @@ import { EmbedBuilder, } from "discord.js"; import capitalizeFirstLetter from "../../../../helpers/capitalizeFirstLetter"; -import getEmbedConfig from "../../../../helpers/getEmbedConfig"; - +import getEmbedConfig from "../../../../helpers/getEmbedData"; import button from "./button"; import command from "./command"; diff --git a/src/plugins/events/messageCreate/modules/credits/index.ts b/src/plugins/events/messageCreate/modules/credits/index.ts index 3e12e6c..439c605 100644 --- a/src/plugins/events/messageCreate/modules/credits/index.ts +++ b/src/plugins/events/messageCreate/modules/credits/index.ts @@ -1,10 +1,8 @@ import { ChannelType, Message } from "discord.js"; -import logger from "../../../../../middlewares/logger"; - -import fetchGuild from "../../../../../helpers/fetchGuild"; -import fetchUser from "../../../../../helpers/fetchUser"; - import * as cooldown from "../../../../../helpers/cooldown"; +import fetchGuild from "../../../../../helpers/fetchGuild"; +import fetchUser from "../../../../../helpers/userData"; +import logger from "../../../../../middlewares/logger"; export default { execute: async (message: Message) => { diff --git a/src/plugins/events/messageCreate/modules/points/index.ts b/src/plugins/events/messageCreate/modules/points/index.ts index 0d4bf6b..5224a7a 100644 --- a/src/plugins/events/messageCreate/modules/points/index.ts +++ b/src/plugins/events/messageCreate/modules/points/index.ts @@ -1,11 +1,9 @@ +import { ChannelType, Message } from "discord.js"; +import * as cooldown from "../../../../../helpers/cooldown"; +import fetchGuild from "../../../../../helpers/fetchGuild"; +import fetchUser from "../../../../../helpers/userData"; import logger from "../../../../../middlewares/logger"; -import * as cooldown from "../../../../../helpers/cooldown"; - -import fetchGuild from "../../../../../helpers/fetchGuild"; -import fetchUser from "../../../../../helpers/fetchUser"; - -import { ChannelType, Message } from "discord.js"; export default { execute: async (message: Message) => { const { guild, author, content, channel } = message; diff --git a/src/plugins/events/messageDelete/audits.ts b/src/plugins/events/messageDelete/audits.ts index 781897b..8c9fba8 100644 --- a/src/plugins/events/messageDelete/audits.ts +++ b/src/plugins/events/messageDelete/audits.ts @@ -1,10 +1,8 @@ import { EmbedBuilder, Message, TextChannel } from "discord.js"; +import getEmbedConfig from "../../../helpers/getEmbedData"; import logger from "../../../middlewares/logger"; - import guildSchema from "../../../models/guild"; -import getEmbedConfig from "../../../helpers/getEmbedConfig"; - export default { execute: async (message: Message) => { if (message === null) return; diff --git a/src/plugins/events/messageUpdate/audits.ts b/src/plugins/events/messageUpdate/audits.ts index 4bd79a2..81ab688 100644 --- a/src/plugins/events/messageUpdate/audits.ts +++ b/src/plugins/events/messageUpdate/audits.ts @@ -1,11 +1,9 @@ /* eslint-disable no-loops/no-loops */ import { EmbedBuilder, Message, TextChannel } from "discord.js"; +import getEmbedConfig from "../../../helpers/getEmbedData"; import logger from "../../../middlewares/logger"; - import guildSchema from "../../../models/guild"; -import getEmbedConfig from "../../../helpers/getEmbedConfig"; - export default { execute: async (oldMessage: Message, newMessage: Message) => { if (oldMessage === null) return; diff --git a/src/plugins/events/ready/index.ts b/src/plugins/events/ready/index.ts index 2831375..e45fd39 100644 --- a/src/plugins/events/ready/index.ts +++ b/src/plugins/events/ready/index.ts @@ -1,12 +1,11 @@ // Dependencies import { Client } from "discord.js"; -import logger from "../../../middlewares/logger"; - // Helpers -import deployCommands from "../../../handlers/deployCommands"; -import devMode from "../../../handlers/devMode"; +import deployCommands from "../../../helpers/deployCommands"; +import devMode from "../../../helpers/devMode"; import updatePresence from "../../../helpers/updatePresence"; import { IEventOptions } from "../../../interfaces/EventOptions"; +import logger from "../../../middlewares/logger"; export const options: IEventOptions = { type: "once", From 764c3cff559d983231d06bbab1ff934fb507e190 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 14 Oct 2022 11:12:46 +0200 Subject: [PATCH 068/215] =?UTF-8?q?=E2=9E=96=20get=20rid=20of=20husky?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .husky/.gitignore | 1 - .husky/pre-commit | 4 ---- 2 files changed, 5 deletions(-) delete mode 100644 .husky/.gitignore delete mode 100644 .husky/pre-commit diff --git a/.husky/.gitignore b/.husky/.gitignore deleted file mode 100644 index 31354ec..0000000 --- a/.husky/.gitignore +++ /dev/null @@ -1 +0,0 @@ -_ diff --git a/.husky/pre-commit b/.husky/pre-commit deleted file mode 100644 index c37466e..0000000 --- a/.husky/pre-commit +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" - -npx lint-staged \ No newline at end of file From 5b33733d14fd86443c0474a87bb7166b8f3fd27c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 14 Oct 2022 09:20:55 +0000 Subject: [PATCH 069/215] Update dependency jest to v29.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 117b798..76f3672 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "eslint-plugin-no-loops": "0.3.0", "eslint-plugin-prettier": "4.2.1", "husky": "8.0.1", - "jest": "29.1.2", + "jest": "29.2.0", "lint-staged": "13.0.3", "nodemon": "2.0.20", "prettier": "2.7.1" From ab42b4f91bbe69906005bf8220fae0878ea02f93 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 14 Oct 2022 11:39:46 +0200 Subject: [PATCH 070/215] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Fix?= =?UTF-8?q?ed=20some=20code=20smells?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/managers/command/index.ts | 4 ---- src/managers/event/index.ts | 2 ++ .../commands/counters/modules/view/index.ts | 7 ------- .../modules/credits/modules/transfer/index.ts | 19 ++++--------------- .../modules/roles/modules/cancel/index.ts | 3 --- 5 files changed, 6 insertions(+), 29 deletions(-) diff --git a/src/managers/command/index.ts b/src/managers/command/index.ts index 5f43be4..10e6184 100644 --- a/src/managers/command/index.ts +++ b/src/managers/command/index.ts @@ -23,10 +23,6 @@ export const register = async (client: Client) => { throw new Error( `📦 No command builder found while importing "${commandName}"` ); - if (!command.execute) - throw new Error( - `📦 No command execute found while importing "${commandName}"` - ); if (!command.moduleData) throw new Error( `📦 No command moduleData found while importing "${commandName}"` diff --git a/src/managers/event/index.ts b/src/managers/event/index.ts index c0734ba..778066d 100644 --- a/src/managers/event/index.ts +++ b/src/managers/event/index.ts @@ -44,6 +44,8 @@ export const register = async (client: Client) => { case "on": client.on(eventName, eventExecutor); break; + default: + logger.error(`${eventName} does not have a valid type`); } importedEventAmount += 1; }; diff --git a/src/plugins/commands/counters/modules/view/index.ts b/src/plugins/commands/counters/modules/view/index.ts index 679b68e..321206c 100644 --- a/src/plugins/commands/counters/modules/view/index.ts +++ b/src/plugins/commands/counters/modules/view/index.ts @@ -46,13 +46,6 @@ export default { channelId: discordChannel.id, }); - const counters = await counterSchema.find(); - - console.log(counters, { - guildId: guild.id, - channelId: discordChannel.id, - }); - if (!counter) throw new Error("No counter found for channel"); return interaction.editReply({ diff --git a/src/plugins/commands/manage/modules/credits/modules/transfer/index.ts b/src/plugins/commands/manage/modules/credits/modules/transfer/index.ts index 2d790b8..62a9425 100644 --- a/src/plugins/commands/manage/modules/credits/modules/transfer/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/transfer/index.ts @@ -207,24 +207,13 @@ export default { await toUser.save(); await session.commitTransaction(); - } catch (error) { + } catch (error: unknown) { await session.abortTransaction(); session.endSession(); - logger.error(`${error}`); - return interaction.editReply({ - embeds: [ - new EmbedBuilder() - .setTitle("[:toolbox:] Manage - Credits (Transfer)") - .setDescription( - "An error occurred while trying to gift credits. Please try again." - ) - .setColor(errorColor) - .setTimestamp(new Date()) - .setColor(successColor) - .setFooter({ text: footerText, iconURL: footerIcon }), - ], - }); + throw new Error( + "An error occurred while trying to gift credits. Please try again later." + ); } finally { // ending the session session.endSession(); diff --git a/src/plugins/commands/shop/modules/roles/modules/cancel/index.ts b/src/plugins/commands/shop/modules/roles/modules/cancel/index.ts index a2d92d2..f3064cd 100644 --- a/src/plugins/commands/shop/modules/roles/modules/cancel/index.ts +++ b/src/plugins/commands/shop/modules/roles/modules/cancel/index.ts @@ -79,9 +79,6 @@ export default { return interaction?.editReply({ embeds: [interactionEmbed], }); - }) - .catch(async (error: Error) => { - return logger?.silly(`Role could not be deleted. ${error}`); }); }, }; From 38d192207d771d8c31caa0ee7b623e7e67b558f7 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 14 Oct 2022 11:41:53 +0200 Subject: [PATCH 071/215] =?UTF-8?q?=F0=9F=92=A1=20event.register=20comment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/managers/event/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/managers/event/index.ts b/src/managers/event/index.ts index 778066d..3834687 100644 --- a/src/managers/event/index.ts +++ b/src/managers/event/index.ts @@ -4,6 +4,7 @@ import listDir from "../../helpers/checkDirectory"; import { IEvent } from "../../interfaces/Event"; import logger from "../../middlewares/logger"; +// Registers all available events export const register = async (client: Client) => { const eventNames = await listDir("plugins/events"); if (!eventNames) throw new Error("📦 No events available"); From dd7d31c571ce9d6444638c66d3712c1ab6961039 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 14 Oct 2022 11:43:43 +0200 Subject: [PATCH 072/215] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Fix?= =?UTF-8?q?ed=20some=20more=20code=20smells?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/managers/command/index.ts | 12 ++++-------- src/managers/event/index.ts | 6 +++--- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/managers/command/index.ts b/src/managers/command/index.ts index 10e6184..1816c8f 100644 --- a/src/managers/command/index.ts +++ b/src/managers/command/index.ts @@ -34,7 +34,7 @@ export const register = async (client: Client) => { }; // Send log message when it's done loading commands - const doneImporting = async () => { + const doneImporting = () => { if (importedCommandAmount !== amountOfCommands) { return logger.warn( `📦 Failed importing ${ @@ -48,13 +48,9 @@ export const register = async (client: Client) => { // Start importing commands commandNames.forEach(async (commandName: string, index: number) => { - await importCommand(commandName) - .then(async () => { - logger.debug(`📦 Imported the "${commandName}" command`); - }) - .catch(async (err) => { - logger.error(err); - }); + await importCommand(commandName).then(() => { + logger.debug(`📦 Imported the "${commandName}" command`); + }); // If done importing if (index + 1 === amountOfCommands) { diff --git a/src/managers/event/index.ts b/src/managers/event/index.ts index 3834687..cf44860 100644 --- a/src/managers/event/index.ts +++ b/src/managers/event/index.ts @@ -29,7 +29,7 @@ export const register = async (client: Client) => { // Register event const eventExecutor = async (...args: Promise[]) => { - await event.execute(...args).catch(async (err) => { + await event.execute(...args).catch((err) => { logger.error(`${err}`); }); }; @@ -52,7 +52,7 @@ export const register = async (client: Client) => { }; // Send log message when it's done loading events - const doneImporting = async () => { + const doneImporting = () => { if (importedEventAmount !== amountOfEvents) { return logger.warn( `📦 Failed importing ${ @@ -65,7 +65,7 @@ export const register = async (client: Client) => { }; eventNames.forEach(async (eventName: string, index: number) => { - await importEvent(eventName).then(async () => { + await importEvent(eventName).then(() => { logger.debug(`📦 Imported the "${eventName}" event`); }); From 74b5ab121c6a0837959da09a8cfa26dfdf13b85f Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 14 Oct 2022 11:48:37 +0200 Subject: [PATCH 073/215] =?UTF-8?q?=F0=9F=9A=91=20Fixed=20some=20syntax=20?= =?UTF-8?q?error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/commands/credits/modules/gift/index.ts | 14 ++++++-------- src/plugins/commands/credits/modules/work/index.ts | 9 ++------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/plugins/commands/credits/modules/gift/index.ts b/src/plugins/commands/credits/modules/gift/index.ts index b2dfabe..9161cad 100644 --- a/src/plugins/commands/credits/modules/gift/index.ts +++ b/src/plugins/commands/credits/modules/gift/index.ts @@ -1,18 +1,16 @@ // Dependencies -import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js"; +// Models +import { + ChatInputCommandInteraction, + EmbedBuilder, + SlashCommandSubcommandBuilder, +} from "discord.js"; import mongoose from "mongoose"; // Configurations import getEmbedConfig from "../../../../../helpers/getEmbedData"; import fetchUser from "../../../../../helpers/userData"; // Handlers import logger from "../../../../../middlewares/logger"; -// Models -import { SlashCommandSu } from /../../../../ helpers / userDatajs / builders; - - - - -"; // Function export default { diff --git a/src/plugins/commands/credits/modules/work/index.ts b/src/plugins/commands/credits/modules/work/index.ts index 9291d45..e1fcbc3 100644 --- a/src/plugins/commands/credits/modules/work/index.ts +++ b/src/plugins/commands/credits/modules/work/index.ts @@ -6,16 +6,11 @@ import { CommandInteraction, EmbedBuilder } from "discord.js"; import * as cooldown from "../../../../../helpers/cooldown"; // Configurations import getEmbedConfig from "../../../../../helpers/getEmbedData"; +// Helpers +import fetchGuild from "../../../../../helpers/guildData"; import fetchUser from "../../../../../helpers/userData"; // Handlers import logger from "../../../../../middlewares/logger"; -// Helpers -import fetchGuild from../../../../../ helpers / userDatald; - - - - -"; export default { metadata: { guildOnly: true, ephemeral: true }, From 1d04890c9246f06c9f44b5960e1054f15f663354 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 14 Oct 2022 11:51:15 +0200 Subject: [PATCH 074/215] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Fix?= =?UTF-8?q?ed=20some=20code=20smelling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/commands/credits/modules/gift/index.ts | 13 ++----------- src/plugins/commands/credits/modules/work/index.ts | 2 +- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/plugins/commands/credits/modules/gift/index.ts b/src/plugins/commands/credits/modules/gift/index.ts index 9161cad..0f36ee9 100644 --- a/src/plugins/commands/credits/modules/gift/index.ts +++ b/src/plugins/commands/credits/modules/gift/index.ts @@ -3,7 +3,7 @@ import { ChatInputCommandInteraction, EmbedBuilder, - SlashCommandSubcommandBuilder, + SlashCommandSubcommandBuilder } from "discord.js"; import mongoose from "mongoose"; // Configurations @@ -200,17 +200,8 @@ export default { } catch (error) { await session.abortTransaction(); session.endSession(); - logger.error(`${error}`); - return interaction.editReply({ - embeds: [ - embed - .setDescription( - "An error occurred while trying to gift credits. Please try again." - ) - .setColor(errorColor), - ], - }); + thorw new Error("An error occurred while trying to gift credits. Please try again later.") } finally { // ending the session session.endSession(); diff --git a/src/plugins/commands/credits/modules/work/index.ts b/src/plugins/commands/credits/modules/work/index.ts index e1fcbc3..d9be719 100644 --- a/src/plugins/commands/credits/modules/work/index.ts +++ b/src/plugins/commands/credits/modules/work/index.ts @@ -56,7 +56,7 @@ export default { userDB.credits += creditsEarned; - await userDB?.save()?.then(async () => { + await userDB?.save()?.then(() => { logger?.silly( `User ${userDB?.userId} worked and earned ${creditsEarned} credits` ); From 038b8070f9165e2a2ff15e90c3719b3259b3d5c3 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 14 Oct 2022 12:50:16 +0200 Subject: [PATCH 075/215] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Fix?= =?UTF-8?q?ed=20some=20code=20smells?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commands/manage/modules/credits/index.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/plugins/commands/manage/modules/credits/index.ts b/src/plugins/commands/manage/modules/credits/index.ts index 0ed9837..bf6f578 100644 --- a/src/plugins/commands/manage/modules/credits/index.ts +++ b/src/plugins/commands/manage/modules/credits/index.ts @@ -1,6 +1,5 @@ import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction } from "discord.js"; - import modules from "./modules"; export const moduleData = modules; @@ -19,14 +18,21 @@ export const builder = (group: SlashCommandSubcommandGroupBuilder) => { export const execute = async (interaction: ChatInputCommandInteraction) => { switch (interaction.options.getSubcommand()) { case "give": - return modules.give.execute(interaction); + await modules.give.execute(interaction); + break; case "set": - return modules.set.execute(interaction); + await modules.set.execute(interaction); + break; case "take": - return modules.take.execute(interaction); + await modules.take.execute(interaction); + break; case "transfer": - return modules.transfer.execute(interaction); + await modules.transfer.execute(interaction); + break; case "giveaway": - return modules.giveaway.execute(interaction); + await modules.giveaway.execute(interaction); + break; + default: + throw new Error("No module found for that specific command"); } }; From a5a4aa93b8b2c31551c5e53c2ece7ad7ab4f6f76 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 14 Oct 2022 12:52:17 +0200 Subject: [PATCH 076/215] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Fix?= =?UTF-8?q?=20more=20code=20smells?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/commands/config/index.ts | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/plugins/commands/config/index.ts b/src/plugins/commands/config/index.ts index 5d9fd42..783219b 100644 --- a/src/plugins/commands/config/index.ts +++ b/src/plugins/commands/config/index.ts @@ -1,6 +1,5 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction } from "discord.js"; - import modules from "./modules"; export const builder = new SlashCommandBuilder() @@ -20,18 +19,27 @@ export const moduleData = modules; export const execute = async (interaction: ChatInputCommandInteraction) => { switch (interaction.options?.getSubcommand()) { case "cpgg": - return modules.cpgg.execute(interaction); + await modules.cpgg.execute(interaction); + break; case "credits": - return modules.credits.execute(interaction); + await modules.credits.execute(interaction); + break; case "points": - return modules.points.execute(interaction); + await modules.points.execute(interaction); + break; case "welcome": - return modules.welcome.execute(interaction); + await modules.welcome.execute(interaction); + break; case "audits": - return modules.audits.execute(interaction); + await modules.audits.execute(interaction); + break; case "shop": - return modules.shop.execute(interaction); + await modules.shop.execute(interaction); + break; case "embeds": - return modules.embeds.execute(interaction); + await modules.embeds.execute(interaction); + break; + default: + throw new Error("No module found for that specific command."); } }; From 9baa207df9ccccdbe94f002158912dd8e32ea65c Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 14 Oct 2022 12:53:00 +0200 Subject: [PATCH 077/215] =?UTF-8?q?=F0=9F=9A=91=20spelled=20throw=20wrong?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/commands/credits/modules/gift/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/commands/credits/modules/gift/index.ts b/src/plugins/commands/credits/modules/gift/index.ts index 0f36ee9..ca2f554 100644 --- a/src/plugins/commands/credits/modules/gift/index.ts +++ b/src/plugins/commands/credits/modules/gift/index.ts @@ -3,7 +3,7 @@ import { ChatInputCommandInteraction, EmbedBuilder, - SlashCommandSubcommandBuilder + SlashCommandSubcommandBuilder, } from "discord.js"; import mongoose from "mongoose"; // Configurations @@ -201,7 +201,9 @@ export default { await session.abortTransaction(); session.endSession(); - thorw new Error("An error occurred while trying to gift credits. Please try again later.") + throw new Error( + "An error occurred while trying to gift credits. Please try again later." + ); } finally { // ending the session session.endSession(); From c7c3aae86781ffe5dd1812b8dabb48bf1f7cd58a Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 14 Oct 2022 12:59:34 +0200 Subject: [PATCH 078/215] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Fix?= =?UTF-8?q?ed=20some=20more=20code=20smells=20again?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/events/messageUpdate/audits.ts | 13 +++++++------ src/plugins/events/messageUpdate/modules/counter.ts | 9 ++++----- src/plugins/events/rateLimit/index.ts | 5 ++--- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/plugins/events/messageUpdate/audits.ts b/src/plugins/events/messageUpdate/audits.ts index 81ab688..263bf5e 100644 --- a/src/plugins/events/messageUpdate/audits.ts +++ b/src/plugins/events/messageUpdate/audits.ts @@ -1,5 +1,5 @@ /* eslint-disable no-loops/no-loops */ -import { EmbedBuilder, Message, TextChannel } from "discord.js"; +import { ChannelType, EmbedBuilder, Message } from "discord.js"; import getEmbedConfig from "../../../helpers/getEmbedData"; import logger from "../../../middlewares/logger"; import guildSchema from "../../../models/guild"; @@ -29,9 +29,10 @@ export default { const channel = client.channels.cache.get(`${guildData.audits.channelId}`); - if (channel === null) return; + if (!channel) return; + if (channel.type !== ChannelType.GuildText) return; - (channel as TextChannel) + channel .send({ embeds: [ new EmbedBuilder() @@ -52,13 +53,13 @@ export default { }), ], }) - .then(async () => { + .then(() => { logger.info( `Audit log sent for event messageUpdate in guild ${newMessage?.guild?.name} (${newMessage?.guild?.id})` ); }) - .catch(async () => { - logger.error( + .catch(() => { + throw new Error( `Audit log failed to send for event messageUpdate in guild ${newMessage?.guild?.name} (${newMessage?.guild?.id})` ); }); diff --git a/src/plugins/events/messageUpdate/modules/counter.ts b/src/plugins/events/messageUpdate/modules/counter.ts index b969358..f0ed934 100644 --- a/src/plugins/events/messageUpdate/modules/counter.ts +++ b/src/plugins/events/messageUpdate/modules/counter.ts @@ -1,6 +1,5 @@ // Dependencies import { Message } from "discord.js"; - // Models import logger from "../../../../middlewares/logger"; import counterSchema from "../../../../models/counter"; @@ -24,12 +23,12 @@ export default async (message: Message) => { ); await message - ?.delete() - ?.then(async () => { + .delete() + .then(async () => { await channel?.send(`${author} said **${word}**.`); logger?.silly(`${author} said ${word} in ${channel}`); }) - ?.catch(async (error) => { - logger?.error(error); + .catch((error) => { + logger.error(error); }); }; diff --git a/src/plugins/events/rateLimit/index.ts b/src/plugins/events/rateLimit/index.ts index a96b144..36ade47 100644 --- a/src/plugins/events/rateLimit/index.ts +++ b/src/plugins/events/rateLimit/index.ts @@ -1,14 +1,13 @@ // Dependencies import { Client } from "discord.js"; -import logger from "../../../middlewares/logger"; - // Helpers import { IEventOptions } from "../../../interfaces/EventOptions"; +import logger from "../../../middlewares/logger"; export const options: IEventOptions = { type: "on", }; -export const execute = async (client: Client) => { +export const execute = (client: Client) => { logger.warn(`Discord's API client (${client?.user?.tag}) is rate-limited!`); }; From 6d44db1c2c328632ef86cc28435f9b1807b7b0de Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 14 Oct 2022 13:02:16 +0200 Subject: [PATCH 079/215] =?UTF-8?q?=F0=9F=92=A1=20event.execute=20comment?= =?UTF-8?q?=20for=20rateLimit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/events/rateLimit/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/events/rateLimit/index.ts b/src/plugins/events/rateLimit/index.ts index 36ade47..d645ab2 100644 --- a/src/plugins/events/rateLimit/index.ts +++ b/src/plugins/events/rateLimit/index.ts @@ -8,6 +8,7 @@ export const options: IEventOptions = { type: "on", }; +// Function to execute the event export const execute = (client: Client) => { logger.warn(`Discord's API client (${client?.user?.tag}) is rate-limited!`); }; From 8b5dc9d51b171708ee2058383e195b3bce5bb945 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 14 Oct 2022 13:14:25 +0200 Subject: [PATCH 080/215] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Fix?= =?UTF-8?q?ed=20more=20code=20smells?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../events/messageCreate/modules/credits/index.ts | 8 +++----- .../events/messageCreate/modules/points/index.ts | 9 +++------ src/plugins/events/messageDelete/audits.ts | 13 +++++++------ 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/plugins/events/messageCreate/modules/credits/index.ts b/src/plugins/events/messageCreate/modules/credits/index.ts index 439c605..b3023d2 100644 --- a/src/plugins/events/messageCreate/modules/credits/index.ts +++ b/src/plugins/events/messageCreate/modules/credits/index.ts @@ -31,15 +31,13 @@ export default { await userData .save() - .then(async () => { + .then(() => { logger.silly( `User ${userId} in guild ${guildId} has ${userData.credits} credits` ); }) - .catch(async (err) => { - logger.error( - `Error saving credits for user ${userId} in guild ${guildId} - ${err}` - ); + .catch(() => { + throw new Error(`Error saving credits to database.`); }); }, }; diff --git a/src/plugins/events/messageCreate/modules/points/index.ts b/src/plugins/events/messageCreate/modules/points/index.ts index 5224a7a..3be492d 100644 --- a/src/plugins/events/messageCreate/modules/points/index.ts +++ b/src/plugins/events/messageCreate/modules/points/index.ts @@ -28,16 +28,13 @@ export default { await userData .save() - .then(async () => { + .then(() => { logger.silly( `Successfully saved user ${author.tag} (${author.id}) in guild: ${guild?.name} (${guild?.id})` ); }) - .catch(async (err) => { - logger.error( - `Error saving points for user ${author.tag} (${author.id}) in guild: ${guild?.name} (${guild?.id})`, - err - ); + .catch(() => { + throw new Error("Error saving points to database."); }); logger.silly( diff --git a/src/plugins/events/messageDelete/audits.ts b/src/plugins/events/messageDelete/audits.ts index 8c9fba8..dd4bedc 100644 --- a/src/plugins/events/messageDelete/audits.ts +++ b/src/plugins/events/messageDelete/audits.ts @@ -1,4 +1,4 @@ -import { EmbedBuilder, Message, TextChannel } from "discord.js"; +import { ChannelType, EmbedBuilder, Message } from "discord.js"; import getEmbedConfig from "../../../helpers/getEmbedData"; import logger from "../../../middlewares/logger"; import guildSchema from "../../../models/guild"; @@ -26,9 +26,10 @@ export default { const channel = client.channels.cache.get(`${guildData.audits.channelId}`); - if (channel === null) return; + if (!channel) return; + if (channel.type !== ChannelType.GuildText) return; - (channel as TextChannel) + channel .send({ embeds: [ new EmbedBuilder() @@ -50,13 +51,13 @@ export default { }), ], }) - .then(async () => { + .then(() => { logger.info( `Audit log sent for event messageDelete in guild ${message?.guild?.name} (${message?.guild?.id})` ); }) - .catch(async () => { - logger.error( + .catch(() => { + throw new Error( `Audit log failed to send for event messageDelete in guild ${message?.guild?.name} (${message?.guild?.id})` ); }); From 0a3be3c5f02636f30904065576f209c6ce6e5be8 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 14 Oct 2022 13:30:59 +0200 Subject: [PATCH 081/215] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Fix?= =?UTF-8?q?ed=20some=20code=20smells?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/events/messageCreate/modules/credits/index.ts | 2 +- src/plugins/events/messageCreate/modules/points/index.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/events/messageCreate/modules/credits/index.ts b/src/plugins/events/messageCreate/modules/credits/index.ts index b3023d2..0b66a0f 100644 --- a/src/plugins/events/messageCreate/modules/credits/index.ts +++ b/src/plugins/events/messageCreate/modules/credits/index.ts @@ -1,6 +1,6 @@ import { ChannelType, Message } from "discord.js"; import * as cooldown from "../../../../../helpers/cooldown"; -import fetchGuild from "../../../../../helpers/fetchGuild"; +import fetchGuild from "../../../../../helpers/guildData"; import fetchUser from "../../../../../helpers/userData"; import logger from "../../../../../middlewares/logger"; diff --git a/src/plugins/events/messageCreate/modules/points/index.ts b/src/plugins/events/messageCreate/modules/points/index.ts index 3be492d..57f321e 100644 --- a/src/plugins/events/messageCreate/modules/points/index.ts +++ b/src/plugins/events/messageCreate/modules/points/index.ts @@ -1,6 +1,6 @@ import { ChannelType, Message } from "discord.js"; -import * as cooldown from "../../../../../helpers/cooldown"; -import fetchGuild from "../../../../../helpers/fetchGuild"; +import { message as CooldownMessage } from "../../../../../helpers/cooldown"; +import fetchGuild from "../../../../../helpers/guildData"; import fetchUser from "../../../../../helpers/userData"; import logger from "../../../../../middlewares/logger"; @@ -17,7 +17,7 @@ export default { if (content.length < guildData.credits.minimumLength) return; - const isOnCooldown = await cooldown.message( + const isOnCooldown = await CooldownMessage( message, guildData.credits.timeout, "messageCreate-points" From 9b14123a54ea8afb97bec68ab9e5b5abd44ff774 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 14 Oct 2022 13:33:45 +0200 Subject: [PATCH 082/215] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Fix?= =?UTF-8?q?ed=20a=20code=20smell?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/events/messageCreate/modules/credits/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/events/messageCreate/modules/credits/index.ts b/src/plugins/events/messageCreate/modules/credits/index.ts index 0b66a0f..4b954f5 100644 --- a/src/plugins/events/messageCreate/modules/credits/index.ts +++ b/src/plugins/events/messageCreate/modules/credits/index.ts @@ -1,5 +1,5 @@ import { ChannelType, Message } from "discord.js"; -import * as cooldown from "../../../../../helpers/cooldown"; +import { message as CooldownMessage } from "../../../../../helpers/cooldown"; import fetchGuild from "../../../../../helpers/guildData"; import fetchUser from "../../../../../helpers/userData"; import logger from "../../../../../middlewares/logger"; @@ -20,7 +20,7 @@ export default { if (content.length < guildData.credits.minimumLength) return; - const isOnCooldown = await cooldown.message( + const isOnCooldown = await CooldownMessage( message, guildData.credits.timeout, "messageCreate-credits" From e5d932453339eab1f41fbad2dcfc3c6b8a5e93d1 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 14 Oct 2022 13:46:47 +0200 Subject: [PATCH 083/215] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Fix?= =?UTF-8?q?ed=20some=20more=20code=20smells?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../events/interactionCreate/handlers/button/index.ts | 5 ++--- .../events/interactionCreate/handlers/command/index.ts | 5 ++--- src/plugins/events/interactionCreate/index.ts | 8 +++----- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/plugins/events/interactionCreate/handlers/button/index.ts b/src/plugins/events/interactionCreate/handlers/button/index.ts index 04d524e..8fac9dd 100644 --- a/src/plugins/events/interactionCreate/handlers/button/index.ts +++ b/src/plugins/events/interactionCreate/handlers/button/index.ts @@ -1,7 +1,6 @@ // Dependencies import { BaseInteraction } from "discord.js"; - -import * as cooldown from "../../../../../helpers/cooldown"; +import { button as CooldownButton } from "../../../../../helpers/cooldown"; import deferReply from "../../../../../helpers/deferReply"; export default async (interaction: BaseInteraction) => { @@ -30,7 +29,7 @@ export default async (interaction: BaseInteraction) => { if (metadata.dmOnly && guild) throw new Error("This command is only available in DM"); - if (metadata.cooldown) await cooldown.button(interaction, metadata.cooldown); + if (metadata.cooldown) await CooldownButton(interaction, metadata.cooldown); await currentButton.execute(interaction); }; diff --git a/src/plugins/events/interactionCreate/handlers/command/index.ts b/src/plugins/events/interactionCreate/handlers/command/index.ts index acc53b0..4e9cc59 100644 --- a/src/plugins/events/interactionCreate/handlers/command/index.ts +++ b/src/plugins/events/interactionCreate/handlers/command/index.ts @@ -1,7 +1,6 @@ // Dependencies import { ChatInputCommandInteraction } from "discord.js"; - -import * as cooldown from "../../../../../helpers/cooldown"; +import { command as CooldownCommand } from "../../../../../helpers/cooldown"; import deferReply from "../../../../../helpers/deferReply"; import getCommandMetadata from "../../../../../helpers/getCommandMetadata"; @@ -29,7 +28,7 @@ export default async (interaction: ChatInputCommandInteraction) => { throw new Error("This command is only available in DM"); if (metadata.cooldown) { - await cooldown.command(interaction, metadata.cooldown); + await CooldownCommand(interaction, metadata.cooldown); } await currentCommand.execute(interaction); }; diff --git a/src/plugins/events/interactionCreate/index.ts b/src/plugins/events/interactionCreate/index.ts index 49599e6..11a715c 100644 --- a/src/plugins/events/interactionCreate/index.ts +++ b/src/plugins/events/interactionCreate/index.ts @@ -4,13 +4,11 @@ import { CommandInteraction, InteractionType, } from "discord.js"; - -// Dependencies -import * as handlers from "./handlers"; - import { IEventOptions } from "../../../interfaces/EventOptions"; import logger from "../../../middlewares/logger"; import audits from "./audits"; +// Dependencies +import { handleCommandInteraction as HandlersHandleCommandInteraction } from "./handlers"; export const options: IEventOptions = { type: "on", @@ -27,7 +25,7 @@ export const execute = async (interaction: BaseInteraction) => { switch (interaction.type) { case InteractionType.ApplicationCommand: - await handlers.handleCommandInteraction(interaction); + await HandlersHandleCommandInteraction(interaction); break; default: From d8acc4ed7b313524afc6cfd9a0f3fef708a5251b Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 14 Oct 2022 13:50:34 +0200 Subject: [PATCH 084/215] =?UTF-8?q?=F0=9F=92=A1=20Add=20event.execute=20co?= =?UTF-8?q?mment=20for=20interactionCreate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/events/interactionCreate/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/events/interactionCreate/index.ts b/src/plugins/events/interactionCreate/index.ts index 11a715c..a1d1692 100644 --- a/src/plugins/events/interactionCreate/index.ts +++ b/src/plugins/events/interactionCreate/index.ts @@ -14,6 +14,7 @@ export const options: IEventOptions = { type: "on", }; +// Execute the event export const execute = async (interaction: BaseInteraction) => { const { guild, id } = interaction; From 229ee5c97b1d6ac0736cdc4d924c0cd5d6de9320 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 14 Oct 2022 13:54:14 +0200 Subject: [PATCH 085/215] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Fix?= =?UTF-8?q?ed=20some=20code=20smells?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../events/messageCreate/modules/counters/index.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/plugins/events/messageCreate/modules/counters/index.ts b/src/plugins/events/messageCreate/modules/counters/index.ts index b5d8d68..35695c0 100644 --- a/src/plugins/events/messageCreate/modules/counters/index.ts +++ b/src/plugins/events/messageCreate/modules/counters/index.ts @@ -1,7 +1,7 @@ import { ChannelType, Message } from "discord.js"; - import logger from "../../../../../middlewares/logger"; import counterSchema from "../../../../../models/counter"; +import logger from "../../../../../middlewares/logger"; export default { execute: async (message: Message) => { @@ -52,16 +52,13 @@ export default { counter.counter += 1; await counter .save() - .then(async () => { + .then(() => { logger.silly( `Counter for guild ${guildId} and channel ${channelId} is now ${counter.counter}` ); }) - .catch(async (err) => { - logger.error( - `Error saving counter for guild ${guildId} and channel ${channelId}`, - err - ); + .catch((err) => { + throw new Error(`Error saving counter to database.`); }); logger.silly( From 3333063a4752e1c16fee73d86a0ead5d8cd5cc2f Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 14 Oct 2022 13:55:43 +0200 Subject: [PATCH 086/215] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Fix?= =?UTF-8?q?ed=20some=20code=20smells?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/events/interactionCreate/handlers/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/events/interactionCreate/handlers/index.ts b/src/plugins/events/interactionCreate/handlers/index.ts index d596913..3e99cb0 100644 --- a/src/plugins/events/interactionCreate/handlers/index.ts +++ b/src/plugins/events/interactionCreate/handlers/index.ts @@ -1,5 +1,6 @@ import { BaseInteraction, + ButtonInteraction, ChatInputCommandInteraction, CommandInteraction, EmbedBuilder, @@ -10,7 +11,7 @@ import button from "./button"; import command from "./command"; export const execute = async (interaction: BaseInteraction) => { - await button(interaction); + await button(interaction); await command(interaction); }; @@ -21,7 +22,7 @@ export const handleCommandInteraction = async ( interaction.guild ); - await command(interaction).catch(async (err) => { + await command(interaction).catch((err) => { return interaction.editReply({ embeds: [ new EmbedBuilder() From 6a5d4804385897233c65daa57b54ea06f09db000 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sun, 16 Oct 2022 14:50:59 +0200 Subject: [PATCH 087/215] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Fix?= =?UTF-8?q?ed=20some=20more=20code=20smells?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/commands/manage/index.ts | 18 +++++++---- .../commands/shop/modules/cpgg/index.ts | 32 +++---------------- .../shop/modules/roles/modules/buy/index.ts | 6 ++-- .../messageCreate/modules/counters/index.ts | 8 ++--- 4 files changed, 22 insertions(+), 42 deletions(-) diff --git a/src/plugins/commands/manage/index.ts b/src/plugins/commands/manage/index.ts index 01b6508..9de5997 100644 --- a/src/plugins/commands/manage/index.ts +++ b/src/plugins/commands/manage/index.ts @@ -18,11 +18,17 @@ export const execute = async (interaction: ChatInputCommandInteraction) => { // Destructure const { options } = interaction; - if (options?.getSubcommandGroup() === "credits") { - return modules.credits.execute(interaction); - } - - if (options?.getSubcommandGroup() === "counters") { - return modules.counters.execute(interaction); + switch (options.getSubcommandGroup()) { + case "credits": { + await modules.credits.execute(interaction); + break; + } + case "counters": { + await modules.counters.execute(interaction); + break; + } + default: { + throw new Error("Could not find an module for the command."); + } } }; diff --git a/src/plugins/commands/shop/modules/cpgg/index.ts b/src/plugins/commands/shop/modules/cpgg/index.ts index 124d12b..da45af1 100644 --- a/src/plugins/commands/shop/modules/cpgg/index.ts +++ b/src/plugins/commands/shop/modules/cpgg/index.ts @@ -6,7 +6,7 @@ import { ButtonStyle, ChatInputCommandInteraction, EmbedBuilder, - Message, + Message } from "discord.js"; import { v4 as uuidv4 } from "uuid"; import encryption from "../../../../../helpers/encryption"; @@ -206,35 +206,13 @@ export default { }); }) - .catch(async (error) => { - logger?.silly(`Error saving new credits. - ${error}`); - - const interactionEmbed = new EmbedBuilder() - .setTitle("[:shopping_cart:] CPGG") - .setDescription(`Something went wrong.`) - .setTimestamp() - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }); - - return interaction?.editReply({ - embeds: [interactionEmbed], - }); + .catch(() => { + throw new Error("Failed to update credits for user.") }); }) - .catch(async (error) => { - logger?.silly(`Error creating voucher. - ${error}`); - - const interactionEmbed = new EmbedBuilder() - .setTitle("[:shopping_cart:] CPGG") - .setDescription(`Something went wrong.`) - .setTimestamp() - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }); - - return interaction?.editReply({ - embeds: [interactionEmbed], - }); + .catch(() => { + throw new Error("Failed generating an voucher.") }); }, }; diff --git a/src/plugins/commands/shop/modules/roles/modules/buy/index.ts b/src/plugins/commands/shop/modules/roles/modules/buy/index.ts index 194ccb7..22ac40f 100644 --- a/src/plugins/commands/shop/modules/roles/modules/buy/index.ts +++ b/src/plugins/commands/shop/modules/roles/modules/buy/index.ts @@ -5,7 +5,7 @@ import { ChatInputCommandInteraction, ColorResolvable, EmbedBuilder, - GuildMemberRoleManager, + GuildMemberRoleManager } from "discord.js"; // Configurations import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; @@ -110,8 +110,8 @@ export default { embeds: [interactionEmbed], }); }) - .catch(async (error) => { - return logger?.silly(`Role could not be created. ${error}`); + .catch(() => { + throw new Error("Failed creating role.") }); }, }; diff --git a/src/plugins/events/messageCreate/modules/counters/index.ts b/src/plugins/events/messageCreate/modules/counters/index.ts index 35695c0..341d0c0 100644 --- a/src/plugins/events/messageCreate/modules/counters/index.ts +++ b/src/plugins/events/messageCreate/modules/counters/index.ts @@ -1,7 +1,6 @@ import { ChannelType, Message } from "discord.js"; import logger from "../../../../../middlewares/logger"; import counterSchema from "../../../../../models/counter"; -import logger from "../../../../../middlewares/logger"; export default { execute: async (message: Message) => { @@ -23,10 +22,7 @@ export default { }); if (counter === null) { - logger.silly( - `No counter found for guild ${guildId} and channel ${channelId}` - ); - return; + throw new Error("No counter found in database."); } if ( @@ -57,7 +53,7 @@ export default { `Counter for guild ${guildId} and channel ${channelId} is now ${counter.counter}` ); }) - .catch((err) => { + .catch(() => { throw new Error(`Error saving counter to database.`); }); From 3f6e926789fea44e27dbba44dcd56a25008b2726 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sun, 16 Oct 2022 14:53:32 +0200 Subject: [PATCH 088/215] =?UTF-8?q?=F0=9F=92=A1=20Added=20comments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/events/interactionCreate/handlers/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/events/interactionCreate/handlers/index.ts b/src/plugins/events/interactionCreate/handlers/index.ts index 3e99cb0..75e3189 100644 --- a/src/plugins/events/interactionCreate/handlers/index.ts +++ b/src/plugins/events/interactionCreate/handlers/index.ts @@ -10,11 +10,13 @@ import getEmbedConfig from "../../../../helpers/getEmbedData"; import button from "./button"; import command from "./command"; +// Send interactions to all available handlers export const execute = async (interaction: BaseInteraction) => { await button(interaction); await command(interaction); }; +// Handle interactions from commands export const handleCommandInteraction = async ( interaction: CommandInteraction ) => { From b3aa7faa23898061778681ee0d87067d55afbc46 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sun, 16 Oct 2022 14:53:41 +0200 Subject: [PATCH 089/215] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Fix?= =?UTF-8?q?ed=20some=20more=20code=20smells?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/commands/shop/modules/cpgg/index.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/plugins/commands/shop/modules/cpgg/index.ts b/src/plugins/commands/shop/modules/cpgg/index.ts index da45af1..abe6467 100644 --- a/src/plugins/commands/shop/modules/cpgg/index.ts +++ b/src/plugins/commands/shop/modules/cpgg/index.ts @@ -6,7 +6,7 @@ import { ButtonStyle, ChatInputCommandInteraction, EmbedBuilder, - Message + Message, } from "discord.js"; import { v4 as uuidv4 } from "uuid"; import encryption from "../../../../../helpers/encryption"; @@ -200,19 +200,20 @@ export default { .setColor(successColor) .setFooter({ text: footerText, iconURL: footerIcon }); - return interaction?.editReply({ + await interaction?.editReply({ embeds: [interactionEmbed], }); + return; }); }) .catch(() => { - throw new Error("Failed to update credits for user.") + throw new Error("Failed to update credits for user."); }); }) .catch(() => { - throw new Error("Failed generating an voucher.") + throw new Error("Failed generating an voucher."); }); }, }; From 49091cb2504996744fe646e024baabaf40d0dd71 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sun, 16 Oct 2022 14:57:55 +0200 Subject: [PATCH 090/215] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Fix?= =?UTF-8?q?ed=20more=20code=20smells?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/events/interactionCreate/audits.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/plugins/events/interactionCreate/audits.ts b/src/plugins/events/interactionCreate/audits.ts index e4ebd19..62ca398 100644 --- a/src/plugins/events/interactionCreate/audits.ts +++ b/src/plugins/events/interactionCreate/audits.ts @@ -1,4 +1,4 @@ -import { BaseInteraction, EmbedBuilder, TextChannel } from "discord.js"; +import { BaseInteraction, ChannelType, EmbedBuilder } from "discord.js"; import getEmbedConfig from "../../../helpers/getEmbedData"; import logger from "../../../middlewares/logger"; import guildSchema from "../../../models/guild"; @@ -26,9 +26,10 @@ export default { const channel = client.channels.cache.get(`${guildData.audits.channelId}`); - if (channel === null) return; + if (!channel) return; + if (channel.type !== ChannelType.GuildText) return; - (channel as TextChannel) + channel .send({ embeds: [ new EmbedBuilder() @@ -49,15 +50,13 @@ export default { }), ], }) - .then(async () => { + .then(() => { logger.debug( `Audit log sent for event interactionCreate in guild ${interaction?.guild?.name} (${interaction?.guild?.id})` ); }) - .catch(async () => { - logger.error( - `Audit log failed to send for event interactionCreate in guild ${interaction?.guild?.name} (${interaction?.guild?.id})` - ); + .catch(() => { + logger.silly("Failed to send audit log for event interactionCreate"); }); }, }; From 05030fd1b898aa82ddd054fae8cbb92e0b477ef2 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sun, 16 Oct 2022 14:59:38 +0200 Subject: [PATCH 091/215] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Fix?= =?UTF-8?q?ed=20more=20code=20smells?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/managers/database/index.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/managers/database/index.ts b/src/managers/database/index.ts index 44152a7..7ddf0bf 100644 --- a/src/managers/database/index.ts +++ b/src/managers/database/index.ts @@ -4,18 +4,18 @@ import logger from "../../middlewares/logger"; export const connect = async () => { await mongoose .connect(process.env.MONGO_URL) - .then(async (connection) => { + .then((connection) => { logger.info(`💾 Connected to database: ${connection.connection.name}`); }) - .catch(async (e) => { - logger.error("💾 Could not connect to database", e); + .catch(() => { + throw new Error("Error connecting to database."); }); - mongoose.connection.on("error", async (error) => { - logger.error(`💾 ${error}`); + mongoose.connection.on("error", () => { + throw new Error("Failed to connect to database."); }); - mongoose.connection.on("warn", async (warning) => { + mongoose.connection.on("warn", (warning) => { logger.warn(`💾 ${warning}`); }); }; From 993508b0dedd73a46962139096dd4936efc64995 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sun, 16 Oct 2022 15:00:57 +0200 Subject: [PATCH 092/215] =?UTF-8?q?=F0=9F=92=A1=20Added=20comment=20for=20?= =?UTF-8?q?database.connect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/managers/database/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/managers/database/index.ts b/src/managers/database/index.ts index 7ddf0bf..930f449 100644 --- a/src/managers/database/index.ts +++ b/src/managers/database/index.ts @@ -1,6 +1,7 @@ import mongoose from "mongoose"; import logger from "../../middlewares/logger"; +// Function to connect to MongoDB server export const connect = async () => { await mongoose .connect(process.env.MONGO_URL) From 537e5223a0fbc77fd69d435d0359ba17049c5fdf Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sun, 16 Oct 2022 15:07:31 +0200 Subject: [PATCH 093/215] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Fix?= =?UTF-8?q?ed=20some=20more=20code=20smells?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/credits/modules/take/index.ts | 5 ++-- src/plugins/commands/moderation/index.ts | 9 ++++--- src/plugins/commands/profile/index.ts | 15 ++++++----- .../give/components/noSelfReputation.ts | 2 +- src/plugins/commands/shop/index.ts | 27 +++++++++++-------- src/plugins/commands/utility/index.ts | 12 ++++++--- src/plugins/events/guildMemberAdd/audits.ts | 8 +++--- .../events/guildMemberRemove/audits.ts | 8 +++--- 8 files changed, 47 insertions(+), 39 deletions(-) diff --git a/src/plugins/commands/manage/modules/credits/modules/take/index.ts b/src/plugins/commands/manage/modules/credits/modules/take/index.ts index 20b5445..5b920ba 100644 --- a/src/plugins/commands/manage/modules/credits/modules/take/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/take/index.ts @@ -151,9 +151,7 @@ export default { // Save toUser await toUser?.save()?.then(async () => { - logger?.silly(`Saved toUser`); - - return interaction?.editReply({ + await interaction?.editReply({ embeds: [ new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Take)") @@ -165,6 +163,7 @@ export default { .setFooter({ text: footerText, iconURL: footerIcon }), ], }); + return; }); }, }; diff --git a/src/plugins/commands/moderation/index.ts b/src/plugins/commands/moderation/index.ts index c9a2bec..f98040f 100644 --- a/src/plugins/commands/moderation/index.ts +++ b/src/plugins/commands/moderation/index.ts @@ -12,11 +12,14 @@ export const builder = new SlashCommandBuilder() export const execute = async (interaction: ChatInputCommandInteraction) => { switch (interaction.options.getSubcommand()) { - case "prune": - return modules.prune.execute(interaction); - default: + case "prune": { + await modules.prune.execute(interaction); + break; + } + default: { throw new Error( `Unknown subcommand: ${interaction.options.getSubcommand()}` ); + } } }; diff --git a/src/plugins/commands/profile/index.ts b/src/plugins/commands/profile/index.ts index 3a9305e..9ded381 100644 --- a/src/plugins/commands/profile/index.ts +++ b/src/plugins/commands/profile/index.ts @@ -6,7 +6,6 @@ import { ChatInputCommandInteraction } from "discord.js"; import modules from "../../commands/profile/modules"; // Handlers -import logger from "../../../middlewares/logger"; export const moduleData = modules; @@ -19,11 +18,13 @@ export const builder = new SlashCommandBuilder() export const execute = async (interaction: ChatInputCommandInteraction) => { const { options } = interaction; - if (options?.getSubcommand() === "view") { - logger?.silly(`Executing view subcommand`); - - return modules.view.execute(interaction); + switch (options.getSubcommand()) { + case "view": { + await modules.view.execute(interaction); + break; + } + default: { + throw new Error("Could not find module for that command"); + } } - - logger?.silly(`No subcommand found`); }; diff --git a/src/plugins/commands/reputation/modules/give/components/noSelfReputation.ts b/src/plugins/commands/reputation/modules/give/components/noSelfReputation.ts index dc0be04..8e3b913 100644 --- a/src/plugins/commands/reputation/modules/give/components/noSelfReputation.ts +++ b/src/plugins/commands/reputation/modules/give/components/noSelfReputation.ts @@ -1,6 +1,6 @@ import { User } from "discord.js"; -export default async (to: User | null, from: User | null) => { +export default (to: User | null, from: User | null) => { if (from?.id === to?.id) { throw new Error("You cannot give reputation to yourself."); } diff --git a/src/plugins/commands/shop/index.ts b/src/plugins/commands/shop/index.ts index 5f6e0b6..2db7112 100644 --- a/src/plugins/commands/shop/index.ts +++ b/src/plugins/commands/shop/index.ts @@ -6,7 +6,6 @@ import { ChatInputCommandInteraction } from "discord.js"; import modules from "./modules"; // Handlers -import logger from "../../../middlewares/logger"; export const moduleData = modules; @@ -20,17 +19,23 @@ export const builder = new SlashCommandBuilder() export const execute = async (interaction: ChatInputCommandInteraction) => { const { options } = interaction; - if (options?.getSubcommand() === "cpgg") { - logger.silly(`Executing cpgg subcommand`); - - return modules.cpgg.execute(interaction); + switch (options.getSubcommand()) { + case "cpgg": { + await modules.cpgg.execute(interaction); + break; + } + default: { + throw new Error("Could not find module for that command."); + } } - if (options?.getSubcommandGroup() === "roles") { - logger?.silly(`Subcommand group is roles`); - - return modules.roles.execute(interaction); + switch (options.getSubcommandGroup()) { + case "roles": { + await modules.roles.execute(interaction); + break; + } + default: { + throw new Error("Could not find module for that command."); + } } - - logger?.silly(`No subcommand found.`); }; diff --git a/src/plugins/commands/utility/index.ts b/src/plugins/commands/utility/index.ts index a10fde2..6ccdc81 100644 --- a/src/plugins/commands/utility/index.ts +++ b/src/plugins/commands/utility/index.ts @@ -16,13 +16,17 @@ export const builder = new SlashCommandBuilder() export const execute = async (interaction: ChatInputCommandInteraction) => { switch (interaction.options.getSubcommand()) { case "about": - return modules.about.execute(interaction); + await modules.about.execute(interaction); + break; case "stats": - return modules.stats.execute(interaction); + await modules.stats.execute(interaction); + break; case "avatar": - return modules.avatar.execute(interaction); + await modules.avatar.execute(interaction); + break; case "ping": - return modules.ping.execute(interaction); + await modules.ping.execute(interaction); + break; default: throw new Error( `Unknown subcommand: ${interaction.options.getSubcommand()}` diff --git a/src/plugins/events/guildMemberAdd/audits.ts b/src/plugins/events/guildMemberAdd/audits.ts index 7710fac..af6290a 100644 --- a/src/plugins/events/guildMemberAdd/audits.ts +++ b/src/plugins/events/guildMemberAdd/audits.ts @@ -48,12 +48,10 @@ export default { ]), ], }) - .then(async () => { - logger.debug( - `Audit log sent for event guildMemberAdd in guild ${member.guild.name} (${member.guild.id})` - ); + .then(() => { + logger.debug(`Audit log sent for event guildMemberAdd`); }) - .catch(async () => { + .catch(() => { throw new Error("Audit log failed to send"); }); }, diff --git a/src/plugins/events/guildMemberRemove/audits.ts b/src/plugins/events/guildMemberRemove/audits.ts index 72391fa..9f8b3e9 100644 --- a/src/plugins/events/guildMemberRemove/audits.ts +++ b/src/plugins/events/guildMemberRemove/audits.ts @@ -48,12 +48,10 @@ export default { ]), ], }) - .then(async () => { - logger.debug( - `Audit log sent for event guildMemberRemove in guild ${member.guild.name} (${member.guild.id})` - ); + .then(() => { + logger.debug(`Audit log sent for event guildMemberRemove.`); }) - .catch(async () => { + .catch(() => { throw new Error("Audit log failed to send"); }); }, From 30e992b5b9f165dfc472b77aa02d65a6c176b989 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sun, 16 Oct 2022 15:09:14 +0200 Subject: [PATCH 094/215] =?UTF-8?q?=F0=9F=92=A1=20Added=20comments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/commands/moderation/index.ts | 1 + src/plugins/commands/profile/index.ts | 1 + src/plugins/commands/shop/index.ts | 1 + src/plugins/commands/utility/index.ts | 1 + 4 files changed, 4 insertions(+) diff --git a/src/plugins/commands/moderation/index.ts b/src/plugins/commands/moderation/index.ts index f98040f..e74193e 100644 --- a/src/plugins/commands/moderation/index.ts +++ b/src/plugins/commands/moderation/index.ts @@ -10,6 +10,7 @@ export const builder = new SlashCommandBuilder() .addSubcommand(modules.prune.builder); +// Execute the command export const execute = async (interaction: ChatInputCommandInteraction) => { switch (interaction.options.getSubcommand()) { case "prune": { diff --git a/src/plugins/commands/profile/index.ts b/src/plugins/commands/profile/index.ts index 9ded381..fb3f287 100644 --- a/src/plugins/commands/profile/index.ts +++ b/src/plugins/commands/profile/index.ts @@ -15,6 +15,7 @@ export const builder = new SlashCommandBuilder() .setDescription("Check a profile.") .addSubcommand(modules.view.builder); +// Execute the command export const execute = async (interaction: ChatInputCommandInteraction) => { const { options } = interaction; diff --git a/src/plugins/commands/shop/index.ts b/src/plugins/commands/shop/index.ts index 2db7112..1da2442 100644 --- a/src/plugins/commands/shop/index.ts +++ b/src/plugins/commands/shop/index.ts @@ -16,6 +16,7 @@ export const builder = new SlashCommandBuilder() .addSubcommand(modules.cpgg.builder) .addSubcommandGroup(modules.roles.builder); +// Execute the command export const execute = async (interaction: ChatInputCommandInteraction) => { const { options } = interaction; diff --git a/src/plugins/commands/utility/index.ts b/src/plugins/commands/utility/index.ts index 6ccdc81..fb87528 100644 --- a/src/plugins/commands/utility/index.ts +++ b/src/plugins/commands/utility/index.ts @@ -13,6 +13,7 @@ export const builder = new SlashCommandBuilder() .addSubcommand(modules.avatar.builder) .addSubcommand(modules.ping.builder); +// Execute the command export const execute = async (interaction: ChatInputCommandInteraction) => { switch (interaction.options.getSubcommand()) { case "about": From 8e260391f669ea72ed5c3bacac1778c9aaaab079 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sun, 16 Oct 2022 15:17:13 +0200 Subject: [PATCH 095/215] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Fix?= =?UTF-8?q?ed=20some=20more=20code=20smells?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/commands/dns/index.ts | 3 +- .../commands/fun/modules/meme/index.ts | 3 +- .../commands/manage/modules/counters/index.ts | 26 +++--- .../modules/counters/modules/add/index.ts | 6 +- .../modules/counters/modules/remove/index.ts | 26 +++--- .../modules/credits/modules/give/index.ts | 87 +++---------------- 6 files changed, 39 insertions(+), 112 deletions(-) diff --git a/src/plugins/commands/dns/index.ts b/src/plugins/commands/dns/index.ts index abfb718..6b88d04 100644 --- a/src/plugins/commands/dns/index.ts +++ b/src/plugins/commands/dns/index.ts @@ -13,7 +13,8 @@ export const builder = new SlashCommandBuilder() export const execute = async (interaction: ChatInputCommandInteraction) => { switch (interaction.options.getSubcommand()) { case "lookup": - return modules.lookup.execute(interaction); + await modules.lookup.execute(interaction); + break; default: throw new Error( `Unknown subcommand: ${interaction.options.getSubcommand()}` diff --git a/src/plugins/commands/fun/modules/meme/index.ts b/src/plugins/commands/fun/modules/meme/index.ts index 9709014..452f900 100644 --- a/src/plugins/commands/fun/modules/meme/index.ts +++ b/src/plugins/commands/fun/modules/meme/index.ts @@ -49,7 +49,8 @@ export default { }) .setColor(embedConfig.successColor); - return interaction.editReply({ embeds: [embed] }); + await interaction.editReply({ embeds: [embed] }); + return; }) .catch((error) => { throw new Error(error.message); diff --git a/src/plugins/commands/manage/modules/counters/index.ts b/src/plugins/commands/manage/modules/counters/index.ts index 04580e5..2c19d7d 100644 --- a/src/plugins/commands/manage/modules/counters/index.ts +++ b/src/plugins/commands/manage/modules/counters/index.ts @@ -2,8 +2,6 @@ import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction } from "discord.js"; -import logger from "../../../../../middlewares/logger"; - // Modules import modules from "./modules"; @@ -21,17 +19,17 @@ export const builder = (group: SlashCommandSubcommandGroupBuilder) => { export const execute = async (interaction: ChatInputCommandInteraction) => { const { options } = interaction; - if (options?.getSubcommand() === "add") { - logger?.silly(`Executing create subcommand`); - - return modules.add.execute(interaction); + switch (options.getSubcommand()) { + case "add": { + await modules.add.execute(interaction); + break; + } + case "remove": { + await modules.remove.execute(interaction); + break; + } + default: { + throw new Error("Could not found a module for that command."); + } } - - if (options?.getSubcommand() === "remove") { - logger?.silly(`Executing delete subcommand`); - - return modules.remove.execute(interaction); - } - - logger?.silly(`Unknown subcommand ${options?.getSubcommand()}`); }; diff --git a/src/plugins/commands/manage/modules/counters/modules/add/index.ts b/src/plugins/commands/manage/modules/counters/modules/add/index.ts index f73d6e5..0be235c 100644 --- a/src/plugins/commands/manage/modules/counters/modules/add/index.ts +++ b/src/plugins/commands/manage/modules/counters/modules/add/index.ts @@ -8,7 +8,6 @@ import { } from "discord.js"; // Configurations import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; -import logger from "../../../../../../../middlewares/logger"; // Models import counterSchema from "../../../../../../../models/counter"; @@ -80,9 +79,7 @@ export default { counter: startValue || 0, }) .then(async () => { - logger?.silly(`Created counter`); - - return interaction?.editReply({ + await interaction?.editReply({ embeds: [ embed .setDescription( @@ -91,6 +88,7 @@ export default { .setColor(successColor), ], }); + return; }); }, }; diff --git a/src/plugins/commands/manage/modules/counters/modules/remove/index.ts b/src/plugins/commands/manage/modules/counters/modules/remove/index.ts index 8b21059..4a14d34 100644 --- a/src/plugins/commands/manage/modules/counters/modules/remove/index.ts +++ b/src/plugins/commands/manage/modules/counters/modules/remove/index.ts @@ -34,8 +34,9 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { - const { errorColor, successColor, footerText, footerIcon } = - await getEmbedConfig(interaction.guild); + const { successColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); const { options, guild } = interaction; const discordChannel = options?.getChannel("channel"); @@ -51,17 +52,9 @@ export default { }); if (counter === null) { - logger?.silly(`Counter is null`); - - return interaction?.editReply({ - embeds: [ - embed - .setDescription( - ":x: There is no counter in this channel. Please add a counter first." - ) - .setColor(errorColor), - ], - }); + throw new Error( + "There is no counters in this channel, please add one first." + ); } await counterSchema @@ -72,7 +65,7 @@ export default { ?.then(async () => { logger?.silly(`Counter deleted`); - return interaction?.editReply({ + await interaction?.editReply({ embeds: [ embed .setDescription( @@ -81,9 +74,10 @@ export default { .setColor(successColor), ], }); + return; }) - .catch(async (error) => { - logger?.error(`Error deleting counter: ${error}`); + .catch(() => { + throw new Error("Failed deleting counter from database."); }); }, }; diff --git a/src/plugins/commands/manage/modules/credits/modules/give/index.ts b/src/plugins/commands/manage/modules/credits/modules/give/index.ts index c59bb5a..cab7050 100644 --- a/src/plugins/commands/manage/modules/credits/modules/give/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/give/index.ts @@ -12,7 +12,6 @@ import pluralize from "../../../../../../../helpers/pluralize"; // Models import fetchUser from "../../../../../../../helpers/userData"; // Handlers -import logger from "../../../../../../../middlewares/logger"; // Function export default { @@ -40,8 +39,9 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { - const { errorColor, successColor, footerText, footerIcon } = - await getEmbedConfig(interaction.guild); // Destructure + const { successColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); // Destructure const { guild, options } = interaction; const discordReceiver = options?.getUser("user"); @@ -49,93 +49,29 @@ export default { // If amount option is null if (creditAmount === null) { - logger?.silly(`Amount is null`); - - return interaction?.editReply({ - embeds: [ - new EmbedBuilder() - .setTitle("[:toolbox:] Manage - Credits (Give)") - .setDescription(`You must provide an amount.`) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }), - ], - }); + throw new Error("You need to provide a credit amount."); } // If amount is zero or below if (creditAmount <= 0) { - logger?.silly(`Amount is zero or below`); - - return interaction?.editReply({ - embeds: [ - new EmbedBuilder() - .setTitle("[:toolbox:] Manage - Credits (Give)") - .setDescription(`You must provide an amount greater than zero.`) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }), - ], - }); + throw new Error("You must provide a credit amount greater than zero"); } if (discordReceiver === null) { - logger?.silly(`Discord receiver is null`); - - return interaction?.editReply({ - embeds: [ - new EmbedBuilder() - .setTitle("[:toolbox:] Manage - Credits (Give)") - .setDescription(`You must provide a user.`) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }), - ], - }); + throw new Error("We could not get the receiving user from Discord"); } if (guild === null) { - logger?.silly(`Guild is null`); - - return interaction?.editReply({ - embeds: [ - new EmbedBuilder() - .setTitle("[:toolbox:] Manage - Credits (Give)") - .setDescription(`You must be in a guild.`) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }), - ], - }); + throw new Error("We could not get the current guild from discord."); } const toUser = await fetchUser(discordReceiver, guild); if (toUser === null) { - logger?.silly(`To user is null`); - - return interaction?.editReply({ - embeds: [ - new EmbedBuilder() - .setTitle("[:toolbox:] Manage - Credits (Give)") - .setDescription(`The user you provided could not be found.`) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }), - ], - }); + throw new Error("The receiving user is not found."); } if (toUser?.credits === null) { - return interaction?.editReply({ - embeds: [ - new EmbedBuilder() - .setTitle("[:toolbox:] Manage - Credits (Give)") - .setDescription(`The user you provided does not have any credits.`) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }), - ], - }); + throw new Error("The receiving user's credits value could not found."); } // Deposit amount to toUser @@ -143,9 +79,7 @@ export default { // Save toUser await toUser?.save()?.then(async () => { - logger?.silly(`Saved toUser`); - - return interaction?.editReply({ + await interaction?.editReply({ embeds: [ new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Give)") @@ -157,6 +91,7 @@ export default { .setFooter({ text: footerText, iconURL: footerIcon }), ], }); + return; }); }, }; From 586caab1079594ca801c5d2eff153e465173ed47 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sun, 16 Oct 2022 15:19:39 +0200 Subject: [PATCH 096/215] =?UTF-8?q?=F0=9F=92=A1=20Added=20comments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/commands/dns/index.ts | 1 + src/plugins/commands/manage/modules/counters/index.ts | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/plugins/commands/dns/index.ts b/src/plugins/commands/dns/index.ts index 6b88d04..551814b 100644 --- a/src/plugins/commands/dns/index.ts +++ b/src/plugins/commands/dns/index.ts @@ -10,6 +10,7 @@ export const builder = new SlashCommandBuilder() .addSubcommand(modules.lookup.builder); +// Execute the command export const execute = async (interaction: ChatInputCommandInteraction) => { switch (interaction.options.getSubcommand()) { case "lookup": diff --git a/src/plugins/commands/manage/modules/counters/index.ts b/src/plugins/commands/manage/modules/counters/index.ts index 2c19d7d..941d672 100644 --- a/src/plugins/commands/manage/modules/counters/index.ts +++ b/src/plugins/commands/manage/modules/counters/index.ts @@ -8,6 +8,7 @@ import modules from "./modules"; // Function export const moduleData = modules; +// Create a discord builder export const builder = (group: SlashCommandSubcommandGroupBuilder) => { return group .setName("counters") @@ -16,6 +17,7 @@ export const builder = (group: SlashCommandSubcommandGroupBuilder) => { .addSubcommand(modules.remove.builder); }; +// Execute the command export const execute = async (interaction: ChatInputCommandInteraction) => { const { options } = interaction; From 4c348a6e7378f4547e6df99fd0d84fcd0d1e62d1 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sun, 16 Oct 2022 15:25:05 +0200 Subject: [PATCH 097/215] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Fix?= =?UTF-8?q?ed=20some=20more=20code=20smells?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../roles/components/overDueForPayment.ts | 17 +++++++---------- src/jobs/timeouts/index.ts | 2 +- .../commands/config/modules/audits/index.ts | 3 ++- .../commands/config/modules/cpgg/index.ts | 3 ++- .../commands/config/modules/credits/index.ts | 3 ++- .../commands/config/modules/embeds/index.ts | 3 ++- .../commands/config/modules/points/index.ts | 3 ++- .../commands/config/modules/shop/index.ts | 3 ++- .../commands/config/modules/welcome/index.ts | 3 ++- .../commands/reputation/modules/give/index.ts | 2 +- 10 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/jobs/shop/modules/roles/components/overDueForPayment.ts b/src/jobs/shop/modules/roles/components/overDueForPayment.ts index 49b9c85..3a834d8 100644 --- a/src/jobs/shop/modules/roles/components/overDueForPayment.ts +++ b/src/jobs/shop/modules/roles/components/overDueForPayment.ts @@ -51,11 +51,8 @@ export const execute = async (client: Client, role: IShopRole) => { ); }); }) - .catch(async (err) => { - throw new Error( - `Error removing role ${roleId} from user ${userId}.`, - err - ); + .catch(() => { + throw new Error(`Failed removing role from user.`); }); throw new Error("User does not have enough credits."); @@ -70,16 +67,16 @@ export const execute = async (client: Client, role: IShopRole) => { role.lastPayed = new Date(); await role .save() - .then(async () => { + .then(() => { logger.silly(`Shop role ${roleId} has been updated.`); }) - .catch(async (err) => { - throw new Error(`Error updating shop role ${roleId}.`, err); + .catch(() => { + throw new Error("Failed updating shop role."); }); logger.debug(`Shop role ${roleId} has been paid.`); }) - .catch(async (err) => { - throw new Error(`Error updating user ${userId}.`, err); + .catch(() => { + throw new Error("Failed updating user."); }); }; diff --git a/src/jobs/timeouts/index.ts b/src/jobs/timeouts/index.ts index 9684a7c..d0de4a1 100644 --- a/src/jobs/timeouts/index.ts +++ b/src/jobs/timeouts/index.ts @@ -24,7 +24,7 @@ export const execute = async () => { timeoutId, cooldown, }) - .then(async () => { + .then(() => { logger.debug( `Timeout document ${timeoutId} has been deleted from user ${userId}.` ); diff --git a/src/plugins/commands/config/modules/audits/index.ts b/src/plugins/commands/config/modules/audits/index.ts index c8de0ad..1605ed9 100644 --- a/src/plugins/commands/config/modules/audits/index.ts +++ b/src/plugins/commands/config/modules/audits/index.ts @@ -78,9 +78,10 @@ export default { text: footerText, }); - return interaction.editReply({ + await interaction.editReply({ embeds: [embedSuccess], }); + return; }); }, }; diff --git a/src/plugins/commands/config/modules/cpgg/index.ts b/src/plugins/commands/config/modules/cpgg/index.ts index a4297ad..1f640ab 100644 --- a/src/plugins/commands/config/modules/cpgg/index.ts +++ b/src/plugins/commands/config/modules/cpgg/index.ts @@ -80,9 +80,10 @@ export default { text: footerText, }); - return interaction?.editReply({ + await interaction?.editReply({ embeds: [interactionEmbed], }); + return; }); }, }; diff --git a/src/plugins/commands/config/modules/credits/index.ts b/src/plugins/commands/config/modules/credits/index.ts index 436d26f..1f65b88 100644 --- a/src/plugins/commands/config/modules/credits/index.ts +++ b/src/plugins/commands/config/modules/credits/index.ts @@ -126,9 +126,10 @@ export default { text: footerText, }); - return interaction?.editReply({ + await interaction?.editReply({ embeds: [interactionEmbed], }); + return; }); }, }; diff --git a/src/plugins/commands/config/modules/embeds/index.ts b/src/plugins/commands/config/modules/embeds/index.ts index 3e667c6..6835f0a 100644 --- a/src/plugins/commands/config/modules/embeds/index.ts +++ b/src/plugins/commands/config/modules/embeds/index.ts @@ -86,9 +86,10 @@ export default { }, ]); - return interaction.editReply({ + await interaction.editReply({ embeds: [embed], }); + return; }); }, }; diff --git a/src/plugins/commands/config/modules/points/index.ts b/src/plugins/commands/config/modules/points/index.ts index 7e1c6dc..03f30ec 100644 --- a/src/plugins/commands/config/modules/points/index.ts +++ b/src/plugins/commands/config/modules/points/index.ts @@ -98,9 +98,10 @@ export default { text: footerText, }); - return interaction?.editReply({ + await interaction?.editReply({ embeds: [interactionEmbed], }); + return; }); }, }; diff --git a/src/plugins/commands/config/modules/shop/index.ts b/src/plugins/commands/config/modules/shop/index.ts index 8a6ceb7..0b0b9e7 100644 --- a/src/plugins/commands/config/modules/shop/index.ts +++ b/src/plugins/commands/config/modules/shop/index.ts @@ -79,9 +79,10 @@ export default { text: footerText, }); - return interaction?.editReply({ + await interaction?.editReply({ embeds: [interactionEmbed], }); + return; }); }, }; diff --git a/src/plugins/commands/config/modules/welcome/index.ts b/src/plugins/commands/config/modules/welcome/index.ts index 61a9436..585c861 100644 --- a/src/plugins/commands/config/modules/welcome/index.ts +++ b/src/plugins/commands/config/modules/welcome/index.ts @@ -171,9 +171,10 @@ export default { text: footerText, }); - return interaction?.editReply({ + await interaction?.editReply({ embeds: [interactionEmbed], }); + return; }); }, }; diff --git a/src/plugins/commands/reputation/modules/give/index.ts b/src/plugins/commands/reputation/modules/give/index.ts index 44f0155..41b8c34 100644 --- a/src/plugins/commands/reputation/modules/give/index.ts +++ b/src/plugins/commands/reputation/modules/give/index.ts @@ -49,7 +49,7 @@ export default { if (!userObj) throw new Error("User is undefined"); // Pre-checks - await noSelfReputation(optionTarget, user); + noSelfReputation(optionTarget, user); // Check if user is on cooldown otherwise create one await cooldown.command(interaction, process.env.REPUTATION_TIMEOUT); From 26f9420f67ab65781a1ec7b0e94ae9d101cd9288 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sun, 16 Oct 2022 15:26:58 +0200 Subject: [PATCH 098/215] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Fix?= =?UTF-8?q?ed=20some=20more=20code=20smells?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shop/modules/roles/components/overDueForPayment.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/jobs/shop/modules/roles/components/overDueForPayment.ts b/src/jobs/shop/modules/roles/components/overDueForPayment.ts index 3a834d8..c3cdfd3 100644 --- a/src/jobs/shop/modules/roles/components/overDueForPayment.ts +++ b/src/jobs/shop/modules/roles/components/overDueForPayment.ts @@ -39,16 +39,13 @@ export const execute = async (client: Client, role: IShopRole) => { roleId, guildId, }) - .then(async () => { + .then(() => { logger.silly( `Shop role document ${roleId} has been deleted from user ${userId}.` ); }) - .catch(async (err) => { - throw new Error( - `Error deleting shop role document ${roleId} from user ${userId}.`, - err - ); + .catch(() => { + throw new Error("Failed deleting shop role from user."); }); }) .catch(() => { From b795d00d177b953a598e16dc6f6ce4e02007593a Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sun, 16 Oct 2022 15:28:08 +0200 Subject: [PATCH 099/215] =?UTF-8?q?=F0=9F=92=A1=20Added=20comments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jobs/shop/modules/roles/components/overDueForPayment.ts | 1 + src/jobs/timeouts/index.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/jobs/shop/modules/roles/components/overDueForPayment.ts b/src/jobs/shop/modules/roles/components/overDueForPayment.ts index c3cdfd3..cbc5568 100644 --- a/src/jobs/shop/modules/roles/components/overDueForPayment.ts +++ b/src/jobs/shop/modules/roles/components/overDueForPayment.ts @@ -6,6 +6,7 @@ import guildSchema from "../../../../../models/guild"; import shopRoleSchema from "../../../../../models/shopRole"; import userSchema from "../../../../../models/user"; +// Execute the component export const execute = async (client: Client, role: IShopRole) => { const { guildId, userId, roleId } = role; if (!userId) throw new Error("User ID not found for shop role."); diff --git a/src/jobs/timeouts/index.ts b/src/jobs/timeouts/index.ts index d0de4a1..bcdddd1 100644 --- a/src/jobs/timeouts/index.ts +++ b/src/jobs/timeouts/index.ts @@ -8,6 +8,7 @@ export const options = { schedule: "*/30 * * * *", // https://crontab.guru/ }; +// Execute the job export const execute = async () => { const timeouts = await timeoutSchema.find(); await Promise.all( From 118a67bb43cd46e25203dbaa4e5cf303a1577494 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sun, 16 Oct 2022 15:28:58 +0200 Subject: [PATCH 100/215] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Fix?= =?UTF-8?q?ed=20some=20more=20code=20smells?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/commands/reputation/modules/give/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/commands/reputation/modules/give/index.ts b/src/plugins/commands/reputation/modules/give/index.ts index 41b8c34..147be04 100644 --- a/src/plugins/commands/reputation/modules/give/index.ts +++ b/src/plugins/commands/reputation/modules/give/index.ts @@ -1,6 +1,6 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js"; -import * as cooldown from "../../../../../helpers/cooldown"; +import { command as CooldownCommand } from "../../../../../helpers/cooldown"; import getEmbedConfig from "../../../../../helpers/getEmbedData"; import fetchUser from "../../../../../helpers/userData"; import logger from "../../../../../middlewares/logger"; @@ -52,7 +52,7 @@ export default { noSelfReputation(optionTarget, user); // Check if user is on cooldown otherwise create one - await cooldown.command(interaction, process.env.REPUTATION_TIMEOUT); + await CooldownCommand(interaction, process.env.REPUTATION_TIMEOUT); switch (optionType) { case "positive": From e9c7d919d331c86d0948e3c378000b6a8f72ebec Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sun, 16 Oct 2022 15:35:34 +0200 Subject: [PATCH 101/215] =?UTF-8?q?=F0=9F=94=A5=20Removed=20privacy=20file?= =?UTF-8?q?=20since=20it's=20outdated?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PRIVACY.md | 57 ------------------------------------------------------ 1 file changed, 57 deletions(-) delete mode 100644 PRIVACY.md diff --git a/PRIVACY.md b/PRIVACY.md deleted file mode 100644 index 4bffac4..0000000 --- a/PRIVACY.md +++ /dev/null @@ -1,57 +0,0 @@ -> Please note that this is our first privacy policy, so some stuff may be off or not in it! -> We are trying our best to follow the privacy policy law. - -# Privacy Policy - -This document entails the privacy policy and agreement that you accept when adding Xyter bot to a server, or as a member of such a server. This document does not supersede the [Developer Terms of Service](https://discordapp.com/developers/docs/legal). - -This privacy policy applies to **Xyter**#7721 (949998000401436673) - -### Terminology - -- **Server Manager** - Anyone who has the ability to add a bot to a server or configure the bot for the server. This is usually an administrator or moderator -- **Server Member** - Anyone who is a member of server to which one of the bots has been added -- **Service User** - Anyone who authorizes an application (logs in) for a scope that provides additional information - -### Data Collected By Command - -The following items may be collected and stored when intentionally provided by a user (usually by means of a command). This data will not be collected automatically. When providing data in this way, you forego any rights to the content of the data provided. - -- Server configurations (/settings guild) -- Data and content for automated tasks (/shop roles) -- Locale (/settings user language) -- Reputation (/reputation give) - -### Data Collected When Enabled - -These items will be automatically collected if a bot is configured to perform certain actions by a server manager. These features are always opt-in, and thus this data will not be collected unless the corresponding feature is enabled. - -- API Token & URL (/settings guild pterodactyl) -- Counters (/admin counter) - -### Data Collected Automatically - -This data may be collected automatically. This data is used to provide statistics or history data. For any bots that collect this data, it is necessary for features of said bot. - -- Username ID (Unique identifier) -- Guild ID (Unique identifier) -- Any data needed for standard operation of Discord bots, such as server permissions -- Credits (/profile view) -- Points (/profile view) -- Levels (/profile view) -- Timestamps (Audit logs and all your data that we store) - -### Data Storage - -All stored data is kept on protected servers. While storage methods vary, most data is kept within password-protected databases such as [MongoDB Atlas](https://atlas.mongodb.com/). Please keep in mind that even with these protections, no data can ever be 100% secure. All efforts are taken to keep your data secure and private, but its absolute security cannot be guaranteed. - -### Feedback - -Feedback on Xyter bot and service is appreciated. When you submit comments, suggestions, bug reports, and any other forms of feedback, you forego any rights to the content, title, or intent of the provided feedback. Additionally, the feedback may be utilized in any way. - -### Agreement - -By adding Xyter bot to your server or using this bot or service in any way, you are consenting to the policies outlined in this document. In addition, you (the server manager) are agreeing to inform your members of the [Developer Terms of Service](https://discordapp.com/developers/docs/legal) and the contents of this document. If you, the server manager, do not agree to this document, you may remove the bot(s) from the server. If you, the server member, do not agree to this document, you may leave the server that contains the bot(s). If you, the service user, do not agree to this document, you may revoke authorization of the application(s) in your 'Authorized Apps' menu. - -Changes to This Privacy Policy -We may update our Privacy Policy from time to time. Thus, we advise you to review this page periodically for any changes. We will notify you of any changes by posting the new Privacy Policy on this page. These changes are effective immediately, after they are posted on this page. From 3fba9f90e4867fec1fa1e1a6645d388ea2954b04 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sun, 16 Oct 2022 15:36:06 +0200 Subject: [PATCH 102/215] =?UTF-8?q?=F0=9F=9A=B8=20compose=20file=20for=20d?= =?UTF-8?q?evelopment=20and=20production?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.dev.yml | 37 ------------------------------------- docker-compose.yml | 14 ++++++++------ 2 files changed, 8 insertions(+), 43 deletions(-) delete mode 100644 docker-compose.dev.yml diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml deleted file mode 100644 index ba7a2ba..0000000 --- a/docker-compose.dev.yml +++ /dev/null @@ -1,37 +0,0 @@ -version: "3" - -services: - app: - depends_on: - - mongodb - build: . - restart: unless-stopped - environment: - - DISCORD_TOKEN=DISCORD_TOKEN - - DISCORD_CLIENT_ID=DISCORD_CLIENT_ID - - DISCORD_GUILD_ID=DISCORD_GUILD_ID - - MONGO_URL=mongodb://MONGO_USER:MONGO_PASS@mongodb:27017/admin?retryWrites=true&w=majority - - ENCRYPTION_ALGORITHM=ENCRYPTION_ALGORITHM - - ENCRYPTION_SECRET=ENCRYPTION_SECRET - - EMEBD_COLOR_SUCCESS=EMEBD_COLOR_SUCCESS - - EMBED_COLOR_WAIT=EMBED_COLOR_WAIT - - EMBED_COLOR_ERROR=EMBED_COLOR_ERROR - - EMBED_FOOTER_TEXT=EMBED_FOOTER_TEXT - - EMBED_FOOTER_ICON=EMBED_FOOTER_ICON - - LOG_LEVEL=LOG_LEVEL - - REPUTATION_TIMEOUT=REPUTATION_TIMEOUT - - BOT_HOSTER_NAME=BOT_HOSTER_NAME - - BOT_HOSTER_URL=BOT_HOSTER_URL - - NODE_ENV=development - stdin_open: true - tty: true - volumes: - - ./logs:/app/logs - mongodb: - image: mongo:latest - restart: unless-stopped - environment: - MONGO_INITDB_ROOT_USERNAME: MONGO_USER - MONGO_INITDB_ROOT_PASSWORD: MONGO_PASS - volumes: - - ./database:/data/db diff --git a/docker-compose.yml b/docker-compose.yml index 2d67fb5..3309d8f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,10 +2,13 @@ version: "3" services: app: - depends_on: - - mongodb image: zyner/xyter:latest restart: unless-stopped + # build: . + stdin_open: true + tty: true + volumes: + - ./logs:/app/logs environment: - DISCORD_TOKEN=DISCORD_TOKEN - DISCORD_CLIENT_ID=DISCORD_CLIENT_ID @@ -23,10 +26,9 @@ services: - BOT_HOSTER_NAME=BOT_HOSTER_NAME - BOT_HOSTER_URL=BOT_HOSTER_URL - NODE_ENV=production - stdin_open: true - tty: true - volumes: - - ./logs:/app/logs + depends_on: + - mongodb + mongodb: image: mongo:latest restart: unless-stopped From 90a8414c14e394ed043c7c1911b5cd84ae45883a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 17 Oct 2022 18:32:07 +0000 Subject: [PATCH 103/215] Update typescript-eslint monorepo to v5.40.1 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 76f3672..ba04132 100644 --- a/package.json +++ b/package.json @@ -57,8 +57,8 @@ "@types/chance": "1.1.3", "@types/node-schedule": "2.1.0", "@types/uuid": "8.3.4", - "@typescript-eslint/eslint-plugin": "5.40.0", - "@typescript-eslint/parser": "5.40.0", + "@typescript-eslint/eslint-plugin": "5.40.1", + "@typescript-eslint/parser": "5.40.1", "eslint": "8.25.0", "eslint-config-airbnb-base": "15.0.0", "eslint-config-prettier": "8.5.0", From 09b9d72ae614e786a3d3a2e01d328096a192f6af Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 18 Oct 2022 18:49:49 +0000 Subject: [PATCH 104/215] Update dependency jest to v29.2.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 76f3672..2e4c2d0 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "eslint-plugin-no-loops": "0.3.0", "eslint-plugin-prettier": "4.2.1", "husky": "8.0.1", - "jest": "29.2.0", + "jest": "29.2.1", "lint-staged": "13.0.3", "nodemon": "2.0.20", "prettier": "2.7.1" From dceeed52e655525fcbfcbac7b9bac38cf58bee35 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 19 Oct 2022 00:24:45 +0000 Subject: [PATCH 105/215] Update Node.js to v19 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9dbdaef..172cf74 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:18 +FROM node:19 LABEL maintainer="xyter@zyner.org" From 1f4c24dc01b209f92d9154981b28e01a58f5c1ef Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 09:04:21 +0200 Subject: [PATCH 106/215] =?UTF-8?q?=E2=9E=95=20prisma/client?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 76f3672..c7f28ba 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ }, "dependencies": { "@discordjs/rest": "^1.0.0", + "@prisma/client": "^4.5.0", "@types/i18next-fs-backend": "^1.1.2", "axios": "^1.0.0", "chance": "^1.1.8", @@ -49,7 +50,7 @@ "node-schedule": "^2.1.0", "ts-node": "^10.7.0", "tsconfig-paths": "^4.0.0", - "typescript": "^4.6.3", + "typescript": "^4.8.4", "uuid": "^9.0.0", "winston-daily-rotate-file": "^4.6.1" }, @@ -69,7 +70,8 @@ "jest": "29.2.0", "lint-staged": "13.0.3", "nodemon": "2.0.20", - "prettier": "2.7.1" + "prettier": "2.7.1", + "prisma": "^4.5.0" }, "lint-staged": { "*.ts": "eslint --cache --fix" From fdde03b9411365c75f35ebc7a1e1ab91aaf25257 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 09:04:37 +0200 Subject: [PATCH 107/215] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20add?= =?UTF-8?q?=20default=20formatter=20for=20prisma=20in=20vscode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.vscode/settings.json b/.vscode/settings.json index 8a724b8..410753e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -27,5 +27,8 @@ }, "[dotenv]": { "editor.defaultFormatter": "foxundermoon.shell-format" + }, + "[prisma]": { + "editor.defaultFormatter": "Prisma.prisma" } } From 156b48dddb5a89a7f3ee215168ec1d8ad54512af Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 09:05:52 +0200 Subject: [PATCH 108/215] =?UTF-8?q?=F0=9F=99=88=20ignore=20prisma/*.db?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ff5dc1a..09464ea 100644 --- a/.gitignore +++ b/.gitignore @@ -144,4 +144,7 @@ dist # Docker database -docker-compose.local.yml \ No newline at end of file +docker-compose.local.yml + +# Prisma +prisma/*.db \ No newline at end of file From 0ecb6f2c4a02b24c067c37085fbd91c68d63062b Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 09:06:22 +0200 Subject: [PATCH 109/215] =?UTF-8?q?=F0=9F=9A=91=20Remove=20invalid=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commands/manage/modules/credits/modules/set/index.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/plugins/commands/manage/modules/credits/modules/set/index.ts b/src/plugins/commands/manage/modules/credits/modules/set/index.ts index 294f30a..8db2bd6 100644 --- a/src/plugins/commands/manage/modules/credits/modules/set/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/set/index.ts @@ -5,7 +5,7 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction, EmbedBuilder, - PermissionsBitField + PermissionsBitField, } from "discord.js"; // Configurations import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; @@ -13,9 +13,6 @@ import fetchUser from "../../../../../../../helpers/userData"; // Handlers import logger from "../../../../../../../middlewares/logger"; - -../../../../../../../helpers/userData - // Function export default { metadata: { From 709c9134266c1ea4989af3ba900b87ba721394a0 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 09:06:47 +0200 Subject: [PATCH 110/215] =?UTF-8?q?=F0=9F=97=83=EF=B8=8F=20Added=20prisma?= =?UTF-8?q?=20scheme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20221019063840_init/migration.sql | 24 ++++++++++++++ .../20221019064232_init/migration.sql | 14 +++++++++ prisma/migrations/migration_lock.toml | 3 ++ prisma/schema.prisma | 31 +++++++++++++++++++ 4 files changed, 72 insertions(+) create mode 100644 prisma/migrations/20221019063840_init/migration.sql create mode 100644 prisma/migrations/20221019064232_init/migration.sql create mode 100644 prisma/migrations/migration_lock.toml create mode 100644 prisma/schema.prisma diff --git a/prisma/migrations/20221019063840_init/migration.sql b/prisma/migrations/20221019063840_init/migration.sql new file mode 100644 index 0000000..56ad967 --- /dev/null +++ b/prisma/migrations/20221019063840_init/migration.sql @@ -0,0 +1,24 @@ +-- CreateTable +CREATE TABLE "Guild" ( + "id" TEXT NOT NULL +); + +-- CreateTable +CREATE TABLE "User" ( + "id" TEXT NOT NULL +); + +-- CreateTable +CREATE TABLE "GuildMember" ( + "userId" TEXT NOT NULL, + "guildId" TEXT NOT NULL +); + +-- CreateIndex +CREATE UNIQUE INDEX "Guild_id_key" ON "Guild"("id"); + +-- CreateIndex +CREATE UNIQUE INDEX "User_id_key" ON "User"("id"); + +-- CreateIndex +CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember"("userId", "guildId"); diff --git a/prisma/migrations/20221019064232_init/migration.sql b/prisma/migrations/20221019064232_init/migration.sql new file mode 100644 index 0000000..c1ab212 --- /dev/null +++ b/prisma/migrations/20221019064232_init/migration.sql @@ -0,0 +1,14 @@ +-- RedefineTables +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_GuildMember" ( + "userId" TEXT NOT NULL, + "guildId" TEXT NOT NULL, + CONSTRAINT "GuildMember_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, + CONSTRAINT "GuildMember_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE +); +INSERT INTO "new_GuildMember" ("guildId", "userId") SELECT "guildId", "userId" FROM "GuildMember"; +DROP TABLE "GuildMember"; +ALTER TABLE "new_GuildMember" RENAME TO "GuildMember"; +CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember"("userId", "guildId"); +PRAGMA foreign_key_check; +PRAGMA foreign_keys=ON; diff --git a/prisma/migrations/migration_lock.toml b/prisma/migrations/migration_lock.toml new file mode 100644 index 0000000..e5e5c47 --- /dev/null +++ b/prisma/migrations/migration_lock.toml @@ -0,0 +1,3 @@ +# Please do not edit this file manually +# It should be added in your version-control system (i.e. Git) +provider = "sqlite" \ No newline at end of file diff --git a/prisma/schema.prisma b/prisma/schema.prisma new file mode 100644 index 0000000..81c8a30 --- /dev/null +++ b/prisma/schema.prisma @@ -0,0 +1,31 @@ +// This is your Prisma schema file, +// learn more about it in the docs: https://pris.ly/d/prisma-schema + +generator client { + provider = "prisma-client-js" +} + +datasource db { + provider = "sqlite" + url = env("DATABASE_URL") +} + +model Guild { + id String @unique + GuildMember GuildMember[] +} + +model User { + id String @unique + GuildMember GuildMember[] +} + +model GuildMember { + userId String + guildId String + + user User @relation(fields: [userId], references: [id]) + guild Guild @relation(fields: [guildId], references: [id]) + + @@unique([userId, guildId]) +} From e5e5d3ed12c055e0725b31aeef48ec02eec11272 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 09:07:11 +0200 Subject: [PATCH 111/215] =?UTF-8?q?=E2=9C=A8=20prisma=20client?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/prisma.ts | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/prisma.ts diff --git a/src/prisma.ts b/src/prisma.ts new file mode 100644 index 0000000..2c3e98f --- /dev/null +++ b/src/prisma.ts @@ -0,0 +1,3 @@ +import { PrismaClient } from "@prisma/client"; + +export default new PrismaClient(); From d6983d47f8c4901f0cbd2cca2aa45a214e49d4e3 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 09:07:27 +0200 Subject: [PATCH 112/215] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Add?= =?UTF-8?q?ed=20prisma=20examples?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/createGuildMember.ts | 40 +++++++++++++++++++++++++++++++++++ examples/deleteGuildMember.ts | 11 ++++++++++ 2 files changed, 51 insertions(+) create mode 100644 examples/createGuildMember.ts create mode 100644 examples/deleteGuildMember.ts diff --git a/examples/createGuildMember.ts b/examples/createGuildMember.ts new file mode 100644 index 0000000..9522981 --- /dev/null +++ b/examples/createGuildMember.ts @@ -0,0 +1,40 @@ +const userId = "SNOWFLKAE"; +const guildId = "SNOWFLAKE"; + +const createGuildMember = await prisma.guildMember.upsert({ + where: { + userId_guildId: { + userId, + guildId, + }, + }, + update: {}, + create: { + user: { + connectOrCreate: { + create: { + id: userId, + }, + where: { + id: userId, + }, + }, + }, + guild: { + connectOrCreate: { + create: { + id: guildId, + }, + where: { + id: guildId, + }, + }, + }, + }, + include: { + user: true, + guild: true, + }, +}); + +console.log(createGuildMember); diff --git a/examples/deleteGuildMember.ts b/examples/deleteGuildMember.ts new file mode 100644 index 0000000..c3e2fd0 --- /dev/null +++ b/examples/deleteGuildMember.ts @@ -0,0 +1,11 @@ +const userId = "SNOWFLAKE"; +const guildId = "SNOWFLAKE"; + +const deleteGuildMember = await prisma.guildMember.deleteMany({ + where: { + userId, + guildId, + }, +}); + +console.log(deleteGuildMember); From d399230bff6e130ff124f36f001b97af563c9b67 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 09:07:42 +0200 Subject: [PATCH 113/215] =?UTF-8?q?=F0=9F=9A=9A=20Fixed=20wrong=20filepath?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/events/guildCreate/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/events/guildCreate/index.ts b/src/plugins/events/guildCreate/index.ts index c661913..ae05c63 100644 --- a/src/plugins/events/guildCreate/index.ts +++ b/src/plugins/events/guildCreate/index.ts @@ -1,5 +1,5 @@ import { Guild } from "discord.js"; -import fetchGuild from "../../../helpers/fetchGuild"; +import fetchGuild from "../../../helpers/guildData"; import updatePresence from "../../../helpers/updatePresence"; import { IEventOptions } from "../../../interfaces/EventOptions"; import logger from "../../../middlewares/logger"; From 255235630de97497d2f7cf738000692343ed9004 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 09:08:03 +0200 Subject: [PATCH 114/215] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Switched=20to=20Pr?= =?UTF-8?q?isma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/events/guildMemberAdd/index.ts | 39 +++++++++++++++++-- src/plugins/events/guildMemberRemove/index.ts | 14 +++++-- 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/src/plugins/events/guildMemberAdd/index.ts b/src/plugins/events/guildMemberAdd/index.ts index d65f42a..d1f554e 100644 --- a/src/plugins/events/guildMemberAdd/index.ts +++ b/src/plugins/events/guildMemberAdd/index.ts @@ -1,10 +1,9 @@ // 3rd party dependencies import { GuildMember } from "discord.js"; import updatePresence from "../../../helpers/updatePresence"; -// Dependencies -import fetchUser from "../../../helpers/userData"; import { IEventOptions } from "../../../interfaces/EventOptions"; import logger from "../../../middlewares/logger"; +import prisma from "../../../prisma"; import audits from "./audits"; import joinMessage from "./joinMessage"; @@ -21,6 +20,40 @@ export const execute = async (member: GuildMember) => { await audits.execute(member); await joinMessage.execute(member); - await fetchUser(user, guild); await updatePresence(client); + + // Create guildMember object + const createGuildMember = await prisma.guildMember.upsert({ + where: { + userId_guildId: { + userId: user.id, + guildId: guild.id, + }, + }, + update: {}, + create: { + user: { + connectOrCreate: { + create: { + id: user.id, + }, + where: { + id: user.id, + }, + }, + }, + guild: { + connectOrCreate: { + create: { + id: guild.id, + }, + where: { + id: guild.id, + }, + }, + }, + }, + }); + + logger.silly(createGuildMember); }; diff --git a/src/plugins/events/guildMemberRemove/index.ts b/src/plugins/events/guildMemberRemove/index.ts index 9c1bcbf..6c9c8c0 100644 --- a/src/plugins/events/guildMemberRemove/index.ts +++ b/src/plugins/events/guildMemberRemove/index.ts @@ -1,10 +1,9 @@ // 3rd party dependencies import { GuildMember } from "discord.js"; -// Dependencies -import dropUser from "../../../helpers/deleteUserData"; import updatePresence from "../../../helpers/updatePresence"; import { IEventOptions } from "../../../interfaces/EventOptions"; import logger from "../../../middlewares/logger"; +import prisma from "../../../prisma"; import audits from "./audits"; import leaveMessage from "./leaveMessage"; @@ -21,6 +20,15 @@ export const execute = async (member: GuildMember) => { await audits.execute(member); await leaveMessage.execute(member); - await dropUser(user, guild); await updatePresence(client); + + // Delete guildMember object + const deleteGuildMember = await prisma.guildMember.deleteMany({ + where: { + userId: user.id, + guildId: guild.id, + }, + }); + + console.log(deleteGuildMember); }; From 834a67b3f141747f0a6946a6a9545273c36bc4f0 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 09:11:07 +0200 Subject: [PATCH 115/215] =?UTF-8?q?=F0=9F=94=87=20unnessecery=20logging=20?= =?UTF-8?q?removed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/events/guildCreate/index.ts | 5 ----- src/plugins/events/guildDelete/index.ts | 5 ----- 2 files changed, 10 deletions(-) diff --git a/src/plugins/events/guildCreate/index.ts b/src/plugins/events/guildCreate/index.ts index ae05c63..4bec295 100644 --- a/src/plugins/events/guildCreate/index.ts +++ b/src/plugins/events/guildCreate/index.ts @@ -2,7 +2,6 @@ import { Guild } from "discord.js"; import fetchGuild from "../../../helpers/guildData"; import updatePresence from "../../../helpers/updatePresence"; import { IEventOptions } from "../../../interfaces/EventOptions"; -import logger from "../../../middlewares/logger"; export const options: IEventOptions = { type: "on", @@ -11,10 +10,6 @@ export const options: IEventOptions = { export const execute = async (guild: Guild) => { const { client } = guild; - logger?.silly(`Added to guild: ${guild.name} (${guild.id})`); - await fetchGuild(guild); await updatePresence(client); - - logger.silly(`guildCreate: ${guild}`); }; diff --git a/src/plugins/events/guildDelete/index.ts b/src/plugins/events/guildDelete/index.ts index c3355d5..113098d 100644 --- a/src/plugins/events/guildDelete/index.ts +++ b/src/plugins/events/guildDelete/index.ts @@ -4,7 +4,6 @@ import { Guild } from "discord.js"; import dropGuild from "../../../helpers/deleteGuildData"; import updatePresence from "../../../helpers/updatePresence"; import { IEventOptions } from "../../../interfaces/EventOptions"; -import logger from "../../../middlewares/logger"; export const options: IEventOptions = { type: "on", @@ -13,10 +12,6 @@ export const options: IEventOptions = { export const execute = async (guild: Guild) => { const { client } = guild; - logger?.silly(`Deleted from guild: ${guild.name} (${guild.id})`); - await dropGuild(guild); await updatePresence(client); - - logger.silly(`guildDelete: ${guild}`); }; From 832ad259e8e6bf09a5537cdf692fbac6bba4119c Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 09:37:32 +0200 Subject: [PATCH 116/215] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Add?= =?UTF-8?q?ed=20dropGuild=20example?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/dropGuild.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 examples/dropGuild.ts diff --git a/examples/dropGuild.ts b/examples/dropGuild.ts new file mode 100644 index 0000000..0e23066 --- /dev/null +++ b/examples/dropGuild.ts @@ -0,0 +1,18 @@ +const guildId = "SNOWFLAKE"; + +// Delete guildMember objects +const deleteGuildMembers = prisma.guildMember.deleteMany({ + where: { + guildId, + }, +}); + +// Delete guild object +const deleteGuild = prisma.guild.deleteMany({ + where: { + id: guildId, + }, +}); + +// The transaction runs synchronously so deleteUsers must run last. +await prisma.$transaction([deleteGuildMembers, deleteGuild]); From 574abd3930e778a59662057f3a8b2ac566609887 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 09:37:48 +0200 Subject: [PATCH 117/215] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20dropGuild=20is=20n?= =?UTF-8?q?ow=20done=20via=20Prisma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/events/guildDelete/index.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/plugins/events/guildDelete/index.ts b/src/plugins/events/guildDelete/index.ts index 113098d..48be748 100644 --- a/src/plugins/events/guildDelete/index.ts +++ b/src/plugins/events/guildDelete/index.ts @@ -4,6 +4,7 @@ import { Guild } from "discord.js"; import dropGuild from "../../../helpers/deleteGuildData"; import updatePresence from "../../../helpers/updatePresence"; import { IEventOptions } from "../../../interfaces/EventOptions"; +import prisma from "../../../prisma"; export const options: IEventOptions = { type: "on", @@ -12,6 +13,23 @@ export const options: IEventOptions = { export const execute = async (guild: Guild) => { const { client } = guild; - await dropGuild(guild); await updatePresence(client); + await dropGuild(guild); + + // Delete guildMember objects + const deleteGuildMembers = prisma.guildMember.deleteMany({ + where: { + guildId: guild.id, + }, + }); + + // Delete guild object + const deleteGuild = prisma.guild.deleteMany({ + where: { + id: guild.id, + }, + }); + + // The transaction runs synchronously so deleteUsers must run last. + await prisma.$transaction([deleteGuildMembers, deleteGuild]); }; From a568daaaddb6ca891d8b1b48bc65ddc161ef50d2 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 09:50:15 +0200 Subject: [PATCH 118/215] =?UTF-8?q?=F0=9F=94=A5=20remove=20old=20mongoose?= =?UTF-8?q?=20helper=20for=20guildDelete?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/events/guildDelete/index.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/plugins/events/guildDelete/index.ts b/src/plugins/events/guildDelete/index.ts index 48be748..6d65b36 100644 --- a/src/plugins/events/guildDelete/index.ts +++ b/src/plugins/events/guildDelete/index.ts @@ -1,7 +1,5 @@ // 3rd party dependencies import { Guild } from "discord.js"; -// Dependencies -import dropGuild from "../../../helpers/deleteGuildData"; import updatePresence from "../../../helpers/updatePresence"; import { IEventOptions } from "../../../interfaces/EventOptions"; import prisma from "../../../prisma"; @@ -14,7 +12,6 @@ export const execute = async (guild: Guild) => { const { client } = guild; await updatePresence(client); - await dropGuild(guild); // Delete guildMember objects const deleteGuildMembers = prisma.guildMember.deleteMany({ From 10283f911bcf36065c2944b912e01c49ff71aaa8 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 09:54:05 +0200 Subject: [PATCH 119/215] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Migrate=20guildCre?= =?UTF-8?q?ate=20to=20Prisma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/events/guildCreate/index.ts | 39 +++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/src/plugins/events/guildCreate/index.ts b/src/plugins/events/guildCreate/index.ts index 4bec295..37ec652 100644 --- a/src/plugins/events/guildCreate/index.ts +++ b/src/plugins/events/guildCreate/index.ts @@ -1,7 +1,8 @@ import { Guild } from "discord.js"; -import fetchGuild from "../../../helpers/guildData"; import updatePresence from "../../../helpers/updatePresence"; import { IEventOptions } from "../../../interfaces/EventOptions"; +import logger from "../../../middlewares/logger"; +import prisma from "../../../prisma"; export const options: IEventOptions = { type: "on", @@ -10,6 +11,40 @@ export const options: IEventOptions = { export const execute = async (guild: Guild) => { const { client } = guild; - await fetchGuild(guild); await updatePresence(client); + + // Create guildMember object + const createGuildMember = await prisma.guildMember.upsert({ + where: { + userId_guildId: { + userId: guild.ownerId, + guildId: guild.id, + }, + }, + update: {}, + create: { + user: { + connectOrCreate: { + create: { + id: guild.ownerId, + }, + where: { + id: guild.ownerId, + }, + }, + }, + guild: { + connectOrCreate: { + create: { + id: guild.id, + }, + where: { + id: guild.id, + }, + }, + }, + }, + }); + + logger.silly(createGuildMember); }; From 770064cf324bb26351cfa87f6feb1369ba1a12cb Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 09:54:25 +0200 Subject: [PATCH 120/215] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20add?= =?UTF-8?q?GuildAndGuildOwner=20example?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/addGuildAndGuildOwner.ts | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 examples/addGuildAndGuildOwner.ts diff --git a/examples/addGuildAndGuildOwner.ts b/examples/addGuildAndGuildOwner.ts new file mode 100644 index 0000000..153ce38 --- /dev/null +++ b/examples/addGuildAndGuildOwner.ts @@ -0,0 +1,37 @@ +const ownerId = "SNOWFLAKE"; +const guildId = "SNOWFLAKE"; + +// Create guildMember object +const createGuildMember = await prisma.guildMember.upsert({ + where: { + userId_guildId: { + userId: ownerId, + guildId, + }, + }, + update: {}, + create: { + user: { + connectOrCreate: { + create: { + id: ownerId, + }, + where: { + id: ownerId, + }, + }, + }, + guild: { + connectOrCreate: { + create: { + id: guildId, + }, + where: { + id: guildId, + }, + }, + }, + }, +}); + +logger.silly(createGuildMember); From f90b776b6f1105b910358e16997f5624482641a7 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 09:56:46 +0200 Subject: [PATCH 121/215] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20switch=20from=20co?= =?UTF-8?q?nsole=20to=20logger?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/events/guildMemberRemove/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/events/guildMemberRemove/index.ts b/src/plugins/events/guildMemberRemove/index.ts index 6c9c8c0..7248324 100644 --- a/src/plugins/events/guildMemberRemove/index.ts +++ b/src/plugins/events/guildMemberRemove/index.ts @@ -30,5 +30,5 @@ export const execute = async (member: GuildMember) => { }, }); - console.log(deleteGuildMember); + logger.silly(deleteGuildMember); }; From 551d0fbdcf1b373d6547d118d8d25957e432bf70 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 09:57:03 +0200 Subject: [PATCH 122/215] =?UTF-8?q?=F0=9F=94=8A=20add=20logging=20for=20gu?= =?UTF-8?q?ildDeletion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/events/guildDelete/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/plugins/events/guildDelete/index.ts b/src/plugins/events/guildDelete/index.ts index 6d65b36..2a4061c 100644 --- a/src/plugins/events/guildDelete/index.ts +++ b/src/plugins/events/guildDelete/index.ts @@ -1,5 +1,6 @@ // 3rd party dependencies import { Guild } from "discord.js"; +import logger from "middlewares/logger"; import updatePresence from "../../../helpers/updatePresence"; import { IEventOptions } from "../../../interfaces/EventOptions"; import prisma from "../../../prisma"; @@ -29,4 +30,7 @@ export const execute = async (guild: Guild) => { // The transaction runs synchronously so deleteUsers must run last. await prisma.$transaction([deleteGuildMembers, deleteGuild]); + + logger.silly(deleteGuildMembers); + logger.silly(deleteGuild); }; From 999612086b29870d2aecf8fa26637b8aa67638f5 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 10:21:15 +0200 Subject: [PATCH 123/215] =?UTF-8?q?=F0=9F=97=83=EF=B8=8F=20Added=20modules?= =?UTF-8?q?=20to=20Prisma=20Scheme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20221019081114_modules/migration.sql | 45 +++++++++++++++++++ .../20221019081816_modules/migration.sql | 23 ++++++++++ prisma/schema.prisma | 40 +++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 prisma/migrations/20221019081114_modules/migration.sql create mode 100644 prisma/migrations/20221019081816_modules/migration.sql diff --git a/prisma/migrations/20221019081114_modules/migration.sql b/prisma/migrations/20221019081114_modules/migration.sql new file mode 100644 index 0000000..2ada6f6 --- /dev/null +++ b/prisma/migrations/20221019081114_modules/migration.sql @@ -0,0 +1,45 @@ +-- AlterTable +ALTER TABLE "GuildMember" ADD COLUMN "creditsEarned" INTEGER; +ALTER TABLE "GuildMember" ADD COLUMN "pointsEarned" INTEGER; + +-- CreateTable +CREATE TABLE "GuildCounter" ( + "guildId" TEXT NOT NULL, + "channelId" TEXT NOT NULL, + "word" TEXT NOT NULL, + "counter" INTEGER NOT NULL DEFAULT 0, + CONSTRAINT "GuildCounter_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE +); + +-- RedefineTables +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_Guild" ( + "id" TEXT NOT NULL, + "creditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "creditsRate" INTEGER NOT NULL DEFAULT 1, + "creditsTimeout" INTEGER NOT NULL DEFAULT 5, + "creditsWorkRate" INTEGER NOT NULL DEFAULT 25, + "creditsWorkTimeout" INTEGER NOT NULL DEFAULT 86400, + "pointsEnabled" BOOLEAN NOT NULL DEFAULT false, + "pointsRate" INTEGER NOT NULL DEFAULT 1, + "pointsTimeout" INTEGER NOT NULL DEFAULT 5, + "reputationsEnabled" BOOLEAN NOT NULL DEFAULT false, + "countersEnabled" BOOLEAN NOT NULL DEFAULT false +); +INSERT INTO "new_Guild" ("id") SELECT "id" FROM "Guild"; +DROP TABLE "Guild"; +ALTER TABLE "new_Guild" RENAME TO "Guild"; +CREATE UNIQUE INDEX "Guild_id_key" ON "Guild"("id"); +CREATE TABLE "new_User" ( + "id" TEXT NOT NULL, + "reputationsEarned" INTEGER NOT NULL DEFAULT 0 +); +INSERT INTO "new_User" ("id") SELECT "id" FROM "User"; +DROP TABLE "User"; +ALTER TABLE "new_User" RENAME TO "User"; +CREATE UNIQUE INDEX "User_id_key" ON "User"("id"); +PRAGMA foreign_key_check; +PRAGMA foreign_keys=ON; + +-- CreateIndex +CREATE UNIQUE INDEX "GuildCounter_guildId_channelId_key" ON "GuildCounter"("guildId", "channelId"); diff --git a/prisma/migrations/20221019081816_modules/migration.sql b/prisma/migrations/20221019081816_modules/migration.sql new file mode 100644 index 0000000..4e87e61 --- /dev/null +++ b/prisma/migrations/20221019081816_modules/migration.sql @@ -0,0 +1,23 @@ +/* + Warnings: + + - You are about to drop the column `counter` on the `GuildCounter` table. All the data in the column will be lost. + - You are about to drop the column `word` on the `GuildCounter` table. All the data in the column will be lost. + - Added the required column `triggerWord` to the `GuildCounter` table without a default value. This is not possible if the table is not empty. + +*/ +-- RedefineTables +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_GuildCounter" ( + "guildId" TEXT NOT NULL, + "channelId" TEXT NOT NULL, + "triggerWord" TEXT NOT NULL, + "count" INTEGER NOT NULL DEFAULT 0, + CONSTRAINT "GuildCounter_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE +); +INSERT INTO "new_GuildCounter" ("channelId", "guildId") SELECT "channelId", "guildId" FROM "GuildCounter"; +DROP TABLE "GuildCounter"; +ALTER TABLE "new_GuildCounter" RENAME TO "GuildCounter"; +CREATE UNIQUE INDEX "GuildCounter_guildId_channelId_key" ON "GuildCounter"("guildId", "channelId"); +PRAGMA foreign_key_check; +PRAGMA foreign_keys=ON; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 81c8a30..be9bccf 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -13,11 +13,34 @@ datasource db { model Guild { id String @unique GuildMember GuildMember[] + + // Settings + + // Modules + creditsEnabled Boolean @default(false) + creditsRate Int @default(1) + creditsTimeout Int @default(5) + creditsWorkRate Int @default(25) + creditsWorkTimeout Int @default(86400) + + pointsEnabled Boolean @default(false) + pointsRate Int @default(1) + pointsTimeout Int @default(5) + + reputationsEnabled Boolean @default(false) + + countersEnabled Boolean @default(false) + counters GuildCounter[] } model User { id String @unique GuildMember GuildMember[] + + // Settings + + // Modules + reputationsEarned Int @default(0) } model GuildMember { @@ -27,5 +50,22 @@ model GuildMember { user User @relation(fields: [userId], references: [id]) guild Guild @relation(fields: [guildId], references: [id]) + // Settings + + // Modules + creditsEarned Int? + pointsEarned Int? + + // Unique Identifier @@unique([userId, guildId]) } + +model GuildCounter { + guildId String + channelId String + triggerWord String + count Int @default(0) + guild Guild @relation(fields: [guildId], references: [id]) + + @@unique([guildId, channelId]) +} From 145a8b3e9c94a54584864c854cf7971c520dd9a3 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 10:21:33 +0200 Subject: [PATCH 124/215] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Add?= =?UTF-8?q?ed=20more=20Prisma=20Examples?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/createGuildCounter.ts | 24 ++++++++++++++++++++++++ examples/findUniqueChannelCounter.ts | 8 ++++++++ 2 files changed, 32 insertions(+) create mode 100644 examples/createGuildCounter.ts create mode 100644 examples/findUniqueChannelCounter.ts diff --git a/examples/createGuildCounter.ts b/examples/createGuildCounter.ts new file mode 100644 index 0000000..0f87938 --- /dev/null +++ b/examples/createGuildCounter.ts @@ -0,0 +1,24 @@ +const createGuildCounter = await prisma.guildCounter.upsert({ + where: { + guildId_channelId: { + guildId: guild.id, + channelId: discordChannel.id, + }, + }, + update: {}, + create: { + channelId: discordChannel.id, + triggerWord, + count: startValue || 0, + guild: { + connectOrCreate: { + create: { + id: guild.id, + }, + where: { + id: guild.id, + }, + }, + }, + }, +}); diff --git a/examples/findUniqueChannelCounter.ts b/examples/findUniqueChannelCounter.ts new file mode 100644 index 0000000..2639bce --- /dev/null +++ b/examples/findUniqueChannelCounter.ts @@ -0,0 +1,8 @@ +const channelCounter = await prisma.guildCounter.findUnique({ + where: { + guildId_channelId: { + guildId: guild.id, + channelId: discordChannel.id, + }, + }, +}); From 9dc6c6e23c7d3cadd82020b88e842cf8cb3a9a66 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 10:22:05 +0200 Subject: [PATCH 125/215] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Migrated=20to=20Pr?= =?UTF-8?q?isma=20for=20Counter=20Add?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/counters/modules/add/index.ts | 91 +++++++++++-------- 1 file changed, 55 insertions(+), 36 deletions(-) diff --git a/src/plugins/commands/manage/modules/counters/modules/add/index.ts b/src/plugins/commands/manage/modules/counters/modules/add/index.ts index 0be235c..7ddbc3d 100644 --- a/src/plugins/commands/manage/modules/counters/modules/add/index.ts +++ b/src/plugins/commands/manage/modules/counters/modules/add/index.ts @@ -8,8 +8,8 @@ import { } from "discord.js"; // Configurations import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; -// Models -import counterSchema from "../../../../../../../models/counter"; +import logger from "../../../../../../../middlewares/logger"; +import prisma from "../../../../../../../prisma"; // Function export default { @@ -43,52 +43,71 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { - const { errorColor, successColor, footerText, footerIcon } = - await getEmbedConfig(interaction.guild); + const { successColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); const { options, guild } = interaction; const discordChannel = options?.getChannel("channel"); - const countingWord = options?.getString("word"); + const triggerWord = options?.getString("word"); const startValue = options?.getNumber("start"); - const embed = new EmbedBuilder() - .setTitle("[:toolbox:] Counters - Add") - .setTimestamp(new Date()) - .setFooter({ text: footerText, iconURL: footerIcon }); + if (!guild) throw new Error("We could not find a guild"); + if (!discordChannel) throw new Error("We could not find a channel"); + if (!triggerWord) throw new Error("We could not find a word"); - const counter = await counterSchema?.findOne({ - guildId: guild?.id, - channelId: discordChannel?.id, + const channelCounter = await prisma.guildCounter.findUnique({ + where: { + guildId_channelId: { + guildId: guild.id, + channelId: discordChannel.id, + }, + }, }); - if (counter) { - return interaction?.editReply({ + if (channelCounter) + throw new Error("A counter already exists for this channel."); + + const createGuildCounter = await prisma.guildCounter.upsert({ + where: { + guildId_channelId: { + guildId: guild.id, + channelId: discordChannel.id, + }, + }, + update: {}, + create: { + channelId: discordChannel.id, + triggerWord, + count: startValue || 0, + guild: { + connectOrCreate: { + create: { + id: guild.id, + }, + where: { + id: guild.id, + }, + }, + }, + }, + }); + + logger.silly(createGuildCounter); + + if (createGuildCounter) { + const embed = new EmbedBuilder() + .setTitle("[:toolbox:] Counters - Add") + .setTimestamp(new Date()) + .setFooter({ text: footerText, iconURL: footerIcon }); + + await interaction?.editReply({ embeds: [ embed - .setDescription(`A counter already exists for this channel.`) - .setColor(errorColor), + .setDescription(":white_check_mark: Counter created successfully.") + .setColor(successColor), ], }); } - - await counterSchema - ?.create({ - guildId: guild?.id, - channelId: discordChannel?.id, - word: countingWord, - counter: startValue || 0, - }) - .then(async () => { - await interaction?.editReply({ - embeds: [ - embed - .setDescription( - `Successfully created counter for ${discordChannel?.name}.` - ) - .setColor(successColor), - ], - }); - return; - }); }, }; From f758072e9d0f5ee8261c7e1d5d22bdba734a21cf Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 10:36:07 +0200 Subject: [PATCH 126/215] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Prisma=20instead?= =?UTF-8?q?=20of=20Mongoose?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/counters/modules/remove/index.ts | 59 +++++++++---------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/src/plugins/commands/manage/modules/counters/modules/remove/index.ts b/src/plugins/commands/manage/modules/counters/modules/remove/index.ts index 4a14d34..693541c 100644 --- a/src/plugins/commands/manage/modules/counters/modules/remove/index.ts +++ b/src/plugins/commands/manage/modules/counters/modules/remove/index.ts @@ -9,9 +9,7 @@ import { } from "discord.js"; // Configurations import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; -// Handlers -import logger from "../../../../../../../middlewares/logger"; -import counterSchema from "../../../../../../../models/counter"; +import prisma from "../../../../../../../prisma"; // Function export default { @@ -41,43 +39,44 @@ export default { const discordChannel = options?.getChannel("channel"); + if (!guild) throw new Error("We could not find a guild"); + if (!discordChannel) throw new Error("We could not find a channel"); + const embed = new EmbedBuilder() .setTitle("[:toolbox:] Counters - Remove") .setTimestamp(new Date()) .setFooter({ text: footerText, iconURL: footerIcon }); - const counter = await counterSchema?.findOne({ - guildId: guild?.id, - channelId: discordChannel?.id, + const channelCounter = await prisma.guildCounter.findUnique({ + where: { + guildId_channelId: { + guildId: guild.id, + channelId: discordChannel.id, + }, + }, }); - if (counter === null) { + if (!channelCounter) throw new Error( - "There is no counters in this channel, please add one first." + "There is no counter sin this channel, please add one first." ); - } - await counterSchema - ?.deleteOne({ - guildId: guild?.id, - channelId: discordChannel?.id, - }) - ?.then(async () => { - logger?.silly(`Counter deleted`); + const deleteGuildCounter = await prisma.guildCounter.deleteMany({ + where: { + guildId: guild.id, + channelId: discordChannel.id, + }, + }); - await interaction?.editReply({ - embeds: [ - embed - .setDescription( - ":white_check_mark: Counter deleted successfully." - ) - .setColor(successColor), - ], - }); - return; - }) - .catch(() => { - throw new Error("Failed deleting counter from database."); - }); + if (!deleteGuildCounter) + throw new Error("We could not find a counter for this guild"); + + await interaction?.editReply({ + embeds: [ + embed + .setDescription(":white_check_mark: Counter deleted successfully.") + .setColor(successColor), + ], + }); }, }; From 38f06ee771cc23d0227b630662c3ece343e5f98f Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 10:36:19 +0200 Subject: [PATCH 127/215] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Ano?= =?UTF-8?q?ther=20Prisma=20Example?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/deleteGuildCounter.ts | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 examples/deleteGuildCounter.ts diff --git a/examples/deleteGuildCounter.ts b/examples/deleteGuildCounter.ts new file mode 100644 index 0000000..c004152 --- /dev/null +++ b/examples/deleteGuildCounter.ts @@ -0,0 +1,6 @@ +const deleteGuildCounter = await prisma.guildCounter.deleteMany({ + where: { + guildId: guild.id, + channelId: discordChannel.id, + }, +}); From 2010b63646a6fac6e12716211a135ac975435387 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 10:39:07 +0200 Subject: [PATCH 128/215] =?UTF-8?q?=F0=9F=99=88=20wildcard=20prisma/*.db*?= =?UTF-8?q?=20instead?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 09464ea..fe6928b 100644 --- a/.gitignore +++ b/.gitignore @@ -147,4 +147,4 @@ database docker-compose.local.yml # Prisma -prisma/*.db \ No newline at end of file +prisma/*.db* \ No newline at end of file From 46d95b59efac41d401dd7b8f362b699546eee5c3 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 10:41:47 +0200 Subject: [PATCH 129/215] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Prisma=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commands/counters/modules/view/index.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/plugins/commands/counters/modules/view/index.ts b/src/plugins/commands/counters/modules/view/index.ts index 321206c..cc72c32 100644 --- a/src/plugins/commands/counters/modules/view/index.ts +++ b/src/plugins/commands/counters/modules/view/index.ts @@ -2,7 +2,7 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChannelType } from "discord-api-types/v10"; import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js"; import getEmbedConfig from "../../../../../helpers/getEmbedData"; -import counterSchema from "../../../../../models/counter"; +import prisma from "../../../../../prisma"; export default { metadata: { guildOnly: true, ephemeral: false }, @@ -41,21 +41,26 @@ export default { iconURL: footerIcon, }); - const counter = await counterSchema.findOne({ - guildId: guild.id, - channelId: discordChannel.id, + const channelCounter = await prisma.guildCounter.findUnique({ + where: { + guildId_channelId: { + guildId: guild.id, + channelId: discordChannel.id, + }, + }, }); - if (!counter) throw new Error("No counter found for channel"); + if (!channelCounter) throw new Error("No counter found for channel"); - return interaction.editReply({ + await interaction.editReply({ embeds: [ embed .setDescription( - `Viewing counter for channel ${discordChannel}: ${counter.counter}!` + `Viewing counter for channel ${discordChannel}: ${channelCounter.count}!` ) .setColor(successColor), ], }); + return; }, }; From 56e3110e2b348892f38136b01b9c9a098611f753 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 10:50:16 +0200 Subject: [PATCH 130/215] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Migrate=20counters?= =?UTF-8?q?=20to=20Prisma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/models/counter.ts | 42 -------------- .../messageCreate/modules/counters/index.ts | 56 ++++++++++--------- .../events/messageDelete/modules/counter.ts | 30 +++++----- .../events/messageUpdate/modules/counter.ts | 33 ++++++----- 4 files changed, 65 insertions(+), 96 deletions(-) delete mode 100644 src/models/counter.ts diff --git a/src/models/counter.ts b/src/models/counter.ts deleted file mode 100644 index a9c463a..0000000 --- a/src/models/counter.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { Snowflake } from "discord.js"; -import { model, Schema } from "mongoose"; - -export interface ICounter { - guildId: Snowflake; - channelId: Snowflake; - word: string; - counter: number; -} - -const counterSchema = new Schema( - { - guildId: { - type: String, - required: true, - unique: false, - index: true, - }, - channelId: { - type: String, - required: true, - unique: true, - index: true, - }, - word: { - type: String, - required: true, - unique: false, - index: true, - }, - counter: { - type: Number, - required: true, - unique: false, - index: true, - default: 0, - }, - }, - { timestamps: true } -); - -export default model("counter", counterSchema); diff --git a/src/plugins/events/messageCreate/modules/counters/index.ts b/src/plugins/events/messageCreate/modules/counters/index.ts index 341d0c0..16c648e 100644 --- a/src/plugins/events/messageCreate/modules/counters/index.ts +++ b/src/plugins/events/messageCreate/modules/counters/index.ts @@ -1,6 +1,6 @@ import { ChannelType, Message } from "discord.js"; import logger from "../../../../../middlewares/logger"; -import counterSchema from "../../../../../models/counter"; +import prisma from "../../../../../prisma"; export default { execute: async (message: Message) => { @@ -13,21 +13,20 @@ export default { const messages = await message.channel.messages.fetch({ limit: 2 }); const lastMessage = messages.last(); - const { id: guildId } = guild; - const { id: channelId } = channel; - - const counter = await counterSchema.findOne({ - guildId, - channelId, + const channelCounter = await prisma.guildCounter.findUnique({ + where: { + guildId_channelId: { + guildId: guild.id, + channelId: channel.id, + }, + }, }); - if (counter === null) { - throw new Error("No counter found in database."); - } + if (!channelCounter) throw new Error("No counters found in channel."); if ( lastMessage?.author.id === author.id && - channel.id === counter.channelId + channel.id === channelCounter.channelId ) { logger.silly( `${author.username} sent the last message therefor not allowing again.` @@ -36,29 +35,32 @@ export default { return; } - if (content !== counter.word) { + if (content !== channelCounter.triggerWord) { logger.silly( - `Counter word ${counter.word} does not match message ${content}` + `Counter word ${channelCounter.triggerWord} does not match message ${content}` ); await message.delete(); return; } - counter.counter += 1; - await counter - .save() - .then(() => { - logger.silly( - `Counter for guild ${guildId} and channel ${channelId} is now ${counter.counter}` - ); - }) - .catch(() => { - throw new Error(`Error saving counter to database.`); - }); + const updateGuildCounter = await prisma.guildCounter.update({ + where: { + guildId_channelId: { + guildId: guild.id, + channelId: channel.id, + }, + }, + data: { + count: { + increment: 1, + }, + }, + }); - logger.silly( - `Counter word ${counter.word} was found in message ${content} from ${author.tag} (${author.id}) in guild: ${guild?.name} (${guild?.id})` - ); + logger.silly(updateGuildCounter); + + if (!updateGuildCounter) + logger.error(`Failed to update counter - ${updateGuildCounter}`); }, }; diff --git a/src/plugins/events/messageDelete/modules/counter.ts b/src/plugins/events/messageDelete/modules/counter.ts index 65d8bc5..9689be6 100644 --- a/src/plugins/events/messageDelete/modules/counter.ts +++ b/src/plugins/events/messageDelete/modules/counter.ts @@ -1,36 +1,38 @@ // Dependencies import { Message } from "discord.js"; - // Models import logger from "../../../../middlewares/logger"; -import counterSchema from "../../../../models/counter"; +import prisma from "../../../../prisma"; export default async (message: Message) => { const { guild, channel, author, content } = message; - const counter = await counterSchema?.findOne({ - guildId: guild?.id, - channelId: channel?.id, + if (!guild) throw new Error("Guild not found"); + if (!channel) throw new Error("Channel not found"); + + const channelCounter = await prisma.guildCounter.findUnique({ + where: { + guildId_channelId: { + guildId: guild.id, + channelId: channel.id, + }, + }, }); - if (counter === null) - return logger?.silly( - `No counter found for guild: ${guild?.name} (${guild?.id})` - ); - const { word } = counter; + if (!channelCounter) throw new Error("No counter found in channel."); const messages = await message.channel.messages.fetch({ limit: 1 }); const lastMessage = messages.last(); if (!lastMessage) return; - if (content !== word) return; + if (content !== channelCounter.triggerWord) return; if (lastMessage.author.id === message.author.id) return; - channel?.send(`${author} said **${word}**.`); - logger?.silly(`${author} said ${word} in ${channel}`); + channel?.send(`${author} said **${channelCounter.triggerWord}**.`); + logger?.silly(`${author} said ${channelCounter.triggerWord} in ${channel}`); return logger?.silly( - `User: ${author?.tag} (${author?.id}) in guild: ${guild?.name} (${guild?.id}) said the counter word: ${word}` + `User: ${author?.tag} (${author?.id}) in guild: ${guild?.name} (${guild?.id}) said the counter word: ${channelCounter.triggerWord}` ); }; diff --git a/src/plugins/events/messageUpdate/modules/counter.ts b/src/plugins/events/messageUpdate/modules/counter.ts index f0ed934..0e34dde 100644 --- a/src/plugins/events/messageUpdate/modules/counter.ts +++ b/src/plugins/events/messageUpdate/modules/counter.ts @@ -2,31 +2,38 @@ import { Message } from "discord.js"; // Models import logger from "../../../../middlewares/logger"; -import counterSchema from "../../../../models/counter"; +import prisma from "../../../../prisma"; export default async (message: Message) => { const { guild, channel, author, content } = message; - const counter = await counterSchema?.findOne({ - guildId: guild?.id, - channelId: channel?.id, + if (!guild) throw new Error("Guild not found"); + + if (!channel) throw new Error("Channel not found"); + + const channelCounter = await prisma.guildCounter.findUnique({ + where: { + guildId_channelId: { + guildId: guild.id, + channelId: channel.id, + }, + }, }); - if (counter === null) + if (!channelCounter) throw new Error("No counters found in channel."); + + if (content === channelCounter.triggerWord) return logger?.silly( - `No counter found for guild: ${guild?.name} (${guild?.id})` - ); - const { word } = counter; - if (content === word) - return logger?.silly( - `User: ${author?.tag} (${author?.id}) in guild: ${guild?.name} (${guild?.id}) said the counter word: ${word}` + `User: ${author?.tag} (${author?.id}) in guild: ${guild?.name} (${guild?.id}) said the counter word: ${channelCounter.triggerWord}` ); await message .delete() .then(async () => { - await channel?.send(`${author} said **${word}**.`); - logger?.silly(`${author} said ${word} in ${channel}`); + await channel?.send(`${author} said **${channelCounter.triggerWord}**.`); + logger?.silly( + `${author} said ${channelCounter.triggerWord} in ${channel}` + ); }) .catch((error) => { logger.error(error); From 2371ee366c040f3ec1bbe2c760e9755f84bed598 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 10:50:28 +0200 Subject: [PATCH 131/215] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Add?= =?UTF-8?q?ed=20updateGuildCounter=20example?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/updateGuildCounter.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 examples/updateGuildCounter.ts diff --git a/examples/updateGuildCounter.ts b/examples/updateGuildCounter.ts new file mode 100644 index 0000000..2f53489 --- /dev/null +++ b/examples/updateGuildCounter.ts @@ -0,0 +1,13 @@ +const updateGuildCounter = await prisma.guildCounter.update({ + where: { + guildId_channelId: { + guildId: guild.id, + channelId: channel.id, + }, + }, + data: { + count: { + increment: 1, + }, + }, +}); From d25e917a0272946462a5add48adaf2523b33a688 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 19 Oct 2022 09:33:16 +0000 Subject: [PATCH 132/215] Update dependency i18next to v22 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 76f3672..b7aa2f8 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "discord.js": "^14.0.0", "dotenv": "^16.0.1", "i18n": "^0.15.0", - "i18next": "^21.6.13", + "i18next": "^22.0.0", "i18next-async-backend": "^2.0.0", "i18next-fs-backend": "^1.1.4", "i18next-http-backend": "^1.4.0", From f83cef06a8c9e23fb6535da56d09fefa5a142df4 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 13:47:11 +0200 Subject: [PATCH 133/215] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20messageCreate=20fu?= =?UTF-8?q?nctions=20are=20now=20using=20Prisma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/events/messageCreate/index.ts | 3 +- .../messageCreate/modules/credits/index.ts | 75 +++++++++++++----- .../messageCreate/modules/points/index.ts | 76 ++++++++++++++----- 3 files changed, 113 insertions(+), 41 deletions(-) diff --git a/src/plugins/events/messageCreate/index.ts b/src/plugins/events/messageCreate/index.ts index 06619f0..85f9c04 100644 --- a/src/plugins/events/messageCreate/index.ts +++ b/src/plugins/events/messageCreate/index.ts @@ -1,7 +1,6 @@ import { Message } from "discord.js"; -import modules from "../../events/messageCreate/modules"; - import { IEventOptions } from "../../../interfaces/EventOptions"; +import modules from "../../events/messageCreate/modules"; export const options: IEventOptions = { type: "on", diff --git a/src/plugins/events/messageCreate/modules/credits/index.ts b/src/plugins/events/messageCreate/modules/credits/index.ts index 4b954f5..f342237 100644 --- a/src/plugins/events/messageCreate/modules/credits/index.ts +++ b/src/plugins/events/messageCreate/modules/credits/index.ts @@ -1,8 +1,7 @@ import { ChannelType, Message } from "discord.js"; import { message as CooldownMessage } from "../../../../../helpers/cooldown"; -import fetchGuild from "../../../../../helpers/guildData"; -import fetchUser from "../../../../../helpers/userData"; import logger from "../../../../../middlewares/logger"; +import prisma from "../../../../../prisma"; export default { execute: async (message: Message) => { @@ -12,32 +11,70 @@ export default { if (author.bot) return; if (channel.type !== ChannelType.GuildText) return; - const { id: guildId } = guild; - const { id: userId } = author; + const createGuildMember = await prisma.guildMember.upsert({ + where: { + userId_guildId: { + userId: author.id, + guildId: guild.id, + }, + }, + update: {}, + create: { + user: { + connectOrCreate: { + create: { + id: author.id, + }, + where: { + id: author.id, + }, + }, + }, + guild: { + connectOrCreate: { + create: { + id: guild.id, + }, + where: { + id: guild.id, + }, + }, + }, + }, + include: { + user: true, + guild: true, + }, + }); - const guildData = await fetchGuild(guild); - const userData = await fetchUser(author, guild); + logger.silly(createGuildMember); - if (content.length < guildData.credits.minimumLength) return; + if (content.length < createGuildMember.guild.creditsMinimumLength) return; const isOnCooldown = await CooldownMessage( message, - guildData.credits.timeout, + createGuildMember.guild.creditsTimeout, "messageCreate-credits" ); if (isOnCooldown) return; - userData.credits += guildData.credits.rate; + const updateGuildMember = await prisma.guildMember.update({ + where: { + userId_guildId: { + userId: author.id, + guildId: guild.id, + }, + }, + data: { + creditsEarned: { + increment: createGuildMember.guild.creditsRate, + }, + }, + }); - await userData - .save() - .then(() => { - logger.silly( - `User ${userId} in guild ${guildId} has ${userData.credits} credits` - ); - }) - .catch(() => { - throw new Error(`Error saving credits to database.`); - }); + logger.silly(updateGuildMember); + + if (!updateGuildMember) + throw new Error("Failed to update guildMember object"); }, }; diff --git a/src/plugins/events/messageCreate/modules/points/index.ts b/src/plugins/events/messageCreate/modules/points/index.ts index 57f321e..6fca49d 100644 --- a/src/plugins/events/messageCreate/modules/points/index.ts +++ b/src/plugins/events/messageCreate/modules/points/index.ts @@ -1,8 +1,7 @@ import { ChannelType, Message } from "discord.js"; import { message as CooldownMessage } from "../../../../../helpers/cooldown"; -import fetchGuild from "../../../../../helpers/guildData"; -import fetchUser from "../../../../../helpers/userData"; import logger from "../../../../../middlewares/logger"; +import prisma from "../../../../../prisma"; export default { execute: async (message: Message) => { @@ -12,33 +11,70 @@ export default { if (author.bot) return; if (channel.type !== ChannelType.GuildText) return; - const guildData = await fetchGuild(guild); - const userData = await fetchUser(author, guild); + const createGuildMember = await prisma.guildMember.upsert({ + where: { + userId_guildId: { + userId: author.id, + guildId: guild.id, + }, + }, + update: {}, + create: { + user: { + connectOrCreate: { + create: { + id: author.id, + }, + where: { + id: author.id, + }, + }, + }, + guild: { + connectOrCreate: { + create: { + id: guild.id, + }, + where: { + id: guild.id, + }, + }, + }, + }, + include: { + user: true, + guild: true, + }, + }); - if (content.length < guildData.credits.minimumLength) return; + logger.silly(createGuildMember); + + if (content.length < createGuildMember.guild.pointsMinimumLength) return; const isOnCooldown = await CooldownMessage( message, - guildData.credits.timeout, + createGuildMember.guild.pointsTimeout, "messageCreate-points" ); if (isOnCooldown) return; - userData.points += guildData.points.rate; + const updateGuildMember = await prisma.guildMember.update({ + where: { + userId_guildId: { + userId: author.id, + guildId: guild.id, + }, + }, + data: { + pointsEarned: { + increment: createGuildMember.guild.pointsRate, + }, + }, + }); - await userData - .save() - .then(() => { - logger.silly( - `Successfully saved user ${author.tag} (${author.id}) in guild: ${guild?.name} (${guild?.id})` - ); - }) - .catch(() => { - throw new Error("Error saving points to database."); - }); + logger.silly(updateGuildMember); - logger.silly( - `User ${author.tag} (${author.id}) in guild: ${guild?.name} (${guild?.id}) has ${userData.points} points` - ); + if (!updateGuildMember) + throw new Error("Failed to update guildMember object"); }, }; From 98fff0a37dc2884a9755681a25af6561c80165e6 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 13:47:56 +0200 Subject: [PATCH 134/215] =?UTF-8?q?=F0=9F=97=83=EF=B8=8F=20Prisma=20Scheme?= =?UTF-8?q?=20added=20more=20module=20fields?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20221019113258_modules/migration.sql | 22 ++++++++ .../20221019114543_modules/migration.sql | 23 +++++++++ prisma/schema.prisma | 51 +++++++++++++++---- 3 files changed, 87 insertions(+), 9 deletions(-) create mode 100644 prisma/migrations/20221019113258_modules/migration.sql create mode 100644 prisma/migrations/20221019114543_modules/migration.sql diff --git a/prisma/migrations/20221019113258_modules/migration.sql b/prisma/migrations/20221019113258_modules/migration.sql new file mode 100644 index 0000000..c28690d --- /dev/null +++ b/prisma/migrations/20221019113258_modules/migration.sql @@ -0,0 +1,22 @@ +-- RedefineTables +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_Guild" ( + "id" TEXT NOT NULL, + "creditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "creditsRate" INTEGER NOT NULL DEFAULT 1, + "creditsTimeout" INTEGER NOT NULL DEFAULT 5, + "creditsWorkRate" INTEGER NOT NULL DEFAULT 25, + "creditsWorkTimeout" INTEGER NOT NULL DEFAULT 86400, + "creditsMinimumLength" INTEGER NOT NULL DEFAULT 5, + "pointsEnabled" BOOLEAN NOT NULL DEFAULT false, + "pointsRate" INTEGER NOT NULL DEFAULT 1, + "pointsTimeout" INTEGER NOT NULL DEFAULT 5, + "reputationsEnabled" BOOLEAN NOT NULL DEFAULT false, + "countersEnabled" BOOLEAN NOT NULL DEFAULT false +); +INSERT INTO "new_Guild" ("countersEnabled", "creditsEnabled", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "id", "pointsEnabled", "pointsRate", "pointsTimeout", "reputationsEnabled") SELECT "countersEnabled", "creditsEnabled", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "id", "pointsEnabled", "pointsRate", "pointsTimeout", "reputationsEnabled" FROM "Guild"; +DROP TABLE "Guild"; +ALTER TABLE "new_Guild" RENAME TO "Guild"; +CREATE UNIQUE INDEX "Guild_id_key" ON "Guild"("id"); +PRAGMA foreign_key_check; +PRAGMA foreign_keys=ON; diff --git a/prisma/migrations/20221019114543_modules/migration.sql b/prisma/migrations/20221019114543_modules/migration.sql new file mode 100644 index 0000000..aa9074e --- /dev/null +++ b/prisma/migrations/20221019114543_modules/migration.sql @@ -0,0 +1,23 @@ +-- RedefineTables +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_Guild" ( + "id" TEXT NOT NULL, + "creditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "creditsRate" INTEGER NOT NULL DEFAULT 1, + "creditsTimeout" INTEGER NOT NULL DEFAULT 5, + "creditsWorkRate" INTEGER NOT NULL DEFAULT 25, + "creditsWorkTimeout" INTEGER NOT NULL DEFAULT 86400, + "creditsMinimumLength" INTEGER NOT NULL DEFAULT 5, + "pointsEnabled" BOOLEAN NOT NULL DEFAULT false, + "pointsRate" INTEGER NOT NULL DEFAULT 1, + "pointsTimeout" INTEGER NOT NULL DEFAULT 5, + "pointsMinimumLength" INTEGER NOT NULL DEFAULT 5, + "reputationsEnabled" BOOLEAN NOT NULL DEFAULT false, + "countersEnabled" BOOLEAN NOT NULL DEFAULT false +); +INSERT INTO "new_Guild" ("countersEnabled", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "id", "pointsEnabled", "pointsRate", "pointsTimeout", "reputationsEnabled") SELECT "countersEnabled", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "id", "pointsEnabled", "pointsRate", "pointsTimeout", "reputationsEnabled" FROM "Guild"; +DROP TABLE "Guild"; +ALTER TABLE "new_Guild" RENAME TO "Guild"; +CREATE UNIQUE INDEX "Guild_id_key" ON "Guild"("id"); +PRAGMA foreign_key_check; +PRAGMA foreign_keys=ON; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index be9bccf..a1ab624 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -16,16 +16,49 @@ model Guild { // Settings - // Modules - creditsEnabled Boolean @default(false) - creditsRate Int @default(1) - creditsTimeout Int @default(5) - creditsWorkRate Int @default(25) - creditsWorkTimeout Int @default(86400) + // { + // url: { + // iv: { + // type: String, + // required: true, + // unique: false, + // index: true, + // } + // , + // content: { + // type: String, + // required: true, + // unique: false, + // index: true, + // }, + // }, + // token: { + // iv: { + // type: String, + // required: true, + // unique: false, + // index: true, + // }, + // content: { + // type: String, + // required: true, + // unique: false, + // index: true, + // }, + // }, - pointsEnabled Boolean @default(false) - pointsRate Int @default(1) - pointsTimeout Int @default(5) + // Modules + creditsEnabled Boolean @default(false) + creditsRate Int @default(1) + creditsTimeout Int @default(5) + creditsWorkRate Int @default(25) + creditsWorkTimeout Int @default(86400) + creditsMinimumLength Int @default(5) + + pointsEnabled Boolean @default(false) + pointsRate Int @default(1) + pointsTimeout Int @default(5) + pointsMinimumLength Int @default(5) reputationsEnabled Boolean @default(false) From 250c1344323a150445b449341dadd741801b4a01 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 13:49:25 +0200 Subject: [PATCH 135/215] =?UTF-8?q?=F0=9F=9A=A7=20Cooldowns=20not=20using?= =?UTF-8?q?=20Prisma=20yet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/helpers/cooldown/index.ts | 257 +++++++++++++++++----------------- 1 file changed, 130 insertions(+), 127 deletions(-) diff --git a/src/helpers/cooldown/index.ts b/src/helpers/cooldown/index.ts index 12246e5..b6357fb 100644 --- a/src/helpers/cooldown/index.ts +++ b/src/helpers/cooldown/index.ts @@ -1,154 +1,157 @@ // Dependencies import { ButtonInteraction, CommandInteraction, Message } from "discord.js"; - import logger from "../../middlewares/logger"; -import addSeconds from "../../helpers/addSeconds"; -import timeoutSchema from "../../models/timeout"; - export const command = async (i: CommandInteraction, cooldown: number) => { - const { guild, user, commandId } = i; + // const { guild, user, commandId } = i; - // Check if user has a timeout - const hasTimeout = await timeoutSchema.findOne({ - guildId: guild?.id || "0", - userId: user.id, - cooldown: cooldown, - timeoutId: commandId, - }); + // // Check if user has a timeout + // const hasTimeout = await timeoutSchema.findOne({ + // guildId: guild?.id || "0", + // userId: user.id, + // cooldown: cooldown, + // timeoutId: commandId, + // }); - // If user is not on timeout - if (hasTimeout) { - const { guildId, userId, timeoutId, createdAt } = hasTimeout; - const overDue = (await addSeconds(cooldown, createdAt)) < new Date(); + // // If user is not on timeout + // if (hasTimeout) { + // const { guildId, userId, timeoutId, createdAt } = hasTimeout; + // const overDue = (await addSeconds(cooldown, createdAt)) < new Date(); - if (!overDue) { - const diff = Math.round( - (new Date(hasTimeout.createdAt).getTime() - new Date().getTime()) / 1000 - ); + // if (!overDue) { + // const diff = Math.round( + // (new Date(hasTimeout.createdAt).getTime() - new Date().getTime()) / 1000 + // ); - throw new Error( - `You must wait ${diff} seconds before using this command.` - ); - } + // throw new Error( + // `You must wait ${diff} seconds before using this command.` + // ); + // } - // Delete timeout - await timeoutSchema - .deleteOne({ - guildId, - userId, - timeoutId, - cooldown, - }) - .then(async () => { - logger.debug( - `Timeout document ${timeoutId} has been deleted from user ${userId}.` - ); - }); - } - // Create timeout - await timeoutSchema.create({ - guildId: guild?.id || "0", - userId: user.id, - cooldown: cooldown, - timeoutId: commandId, - }); + // // Delete timeout + // await timeoutSchema + // .deleteOne({ + // guildId, + // userId, + // timeoutId, + // cooldown, + // }) + // .then(async () => { + // logger.debug( + // `Timeout document ${timeoutId} has been deleted from user ${userId}.` + // ); + // }); + // } + // // Create timeout + // await timeoutSchema.create({ + // guildId: guild?.id || "0", + // userId: user.id, + // cooldown: cooldown, + // timeoutId: commandId, + // }); + logger.warn("Command cooldown function is not working with Prisma yet!"); + return false; }; export const button = async (i: ButtonInteraction, cooldown: number) => { - const { guild, user, customId } = i; + // const { guild, user, customId } = i; - // Check if user has a timeout - const hasTimeout = await timeoutSchema.findOne({ - guildId: guild?.id || "0", - userId: user.id, - cooldown: cooldown, - timeoutId: customId, - }); + // // Check if user has a timeout + // const hasTimeout = await timeoutSchema.findOne({ + // guildId: guild?.id || "0", + // userId: user.id, + // cooldown: cooldown, + // timeoutId: customId, + // }); - // If user is not on timeout - if (hasTimeout) { - const { guildId, userId, timeoutId, createdAt } = hasTimeout; - const overDue = (await addSeconds(cooldown, createdAt)) < new Date(); + // // If user is not on timeout + // if (hasTimeout) { + // const { guildId, userId, timeoutId, createdAt } = hasTimeout; + // const overDue = (await addSeconds(cooldown, createdAt)) < new Date(); - if (!overDue) { - const diff = Math.round( - (new Date(hasTimeout.createdAt).getTime() - new Date().getTime()) / 1000 - ); + // if (!overDue) { + // const diff = Math.round( + // (new Date(hasTimeout.createdAt).getTime() - new Date().getTime()) / 1000 + // ); - throw new Error( - `You must wait ${diff} seconds before using this command.` - ); - } + // throw new Error( + // `You must wait ${diff} seconds before using this command.` + // ); + // } - // Delete timeout - await timeoutSchema - .deleteOne({ - guildId, - userId, - timeoutId, - cooldown, - }) - .then(async () => { - logger.debug( - `Timeout document ${timeoutId} has been deleted from user ${userId}.` - ); - }); - } - // Create timeout - await timeoutSchema.create({ - guildId: guild?.id || "0", - userId: user.id, - cooldown: cooldown, - timeoutId: customId, - }); + // // Delete timeout + // await timeoutSchema + // .deleteOne({ + // guildId, + // userId, + // timeoutId, + // cooldown, + // }) + // .then(async () => { + // logger.debug( + // `Timeout document ${timeoutId} has been deleted from user ${userId}.` + // ); + // }); + // } + // // Create timeout + // await timeoutSchema.create({ + // guildId: guild?.id || "0", + // userId: user.id, + // cooldown: cooldown, + // timeoutId: customId, + // }); + logger.warn("Button cooldown function is not working with Prisma yet!"); + return false; }; export const message = async (msg: Message, cooldown: number, id: string) => { - const { guild, member } = msg; - if (!guild) throw new Error("Guild is undefined"); - if (!member) throw new Error("Member is undefined"); + // const { guild, member } = msg; + // if (!guild) throw new Error("Guild is undefined"); + // if (!member) throw new Error("Member is undefined"); - // Check if user has a timeout - const hasTimeout = await timeoutSchema.findOne({ - guildId: guild?.id || "0", - userId: member.id, - cooldown: cooldown, - timeoutId: id, - }); + // // Check if user has a timeout + // const hasTimeout = await timeoutSchema.findOne({ + // guildId: guild?.id || "0", + // userId: member.id, + // cooldown: cooldown, + // timeoutId: id, + // }); - // If user is not on timeout - if (hasTimeout) { - const { guildId, userId, timeoutId, createdAt } = hasTimeout; - const overDue = (await addSeconds(cooldown, createdAt)) < new Date(); + // // If user is not on timeout + // if (hasTimeout) { + // const { guildId, userId, timeoutId, createdAt } = hasTimeout; + // const overDue = (await addSeconds(cooldown, createdAt)) < new Date(); - if (!overDue) { - const diff = Math.round( - (new Date(hasTimeout.createdAt).getTime() - new Date().getTime()) / 1000 - ); + // if (!overDue) { + // const diff = Math.round( + // (new Date(hasTimeout.createdAt).getTime() - new Date().getTime()) / 1000 + // ); - return `User: ${userId} on timeout-id: ${id} with cooldown: ${cooldown} secs with remaining: ${diff} secs.`; - } + // return `User: ${userId} on timeout-id: ${id} with cooldown: ${cooldown} secs with remaining: ${diff} secs.`; + // } - // Delete timeout - await timeoutSchema - .deleteOne({ - guildId, - userId: member.id, - timeoutId: id, - cooldown, - }) - .then(async () => { - logger.debug( - `Timeout document ${timeoutId} has been deleted from user ${userId}.` - ); - }); - } - // Create timeout - await timeoutSchema.create({ - guildId: guild?.id || "0", - userId: member.id, - cooldown: cooldown, - timeoutId: id, - }); + // // Delete timeout + // await timeoutSchema + // .deleteOne({ + // guildId, + // userId: member.id, + // timeoutId: id, + // cooldown, + // }) + // .then(async () => { + // logger.debug( + // `Timeout document ${timeoutId} has been deleted from user ${userId}.` + // ); + // }); + // } + // // Create timeout + // await timeoutSchema.create({ + // guildId: guild?.id || "0", + // userId: member.id, + // cooldown: cooldown, + // timeoutId: id, + // }); + + logger.warn("Message cooldown function is not working with Prisma yet!"); + return false; }; From 8bd01a448b685bffe9a05bf43389f1f9a804e4e6 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 13:50:24 +0200 Subject: [PATCH 136/215] =?UTF-8?q?=F0=9F=8E=A8=20Reorganized=20imports?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/events/guildDelete/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/events/guildDelete/index.ts b/src/plugins/events/guildDelete/index.ts index 2a4061c..fc3817a 100644 --- a/src/plugins/events/guildDelete/index.ts +++ b/src/plugins/events/guildDelete/index.ts @@ -1,8 +1,8 @@ // 3rd party dependencies import { Guild } from "discord.js"; -import logger from "middlewares/logger"; import updatePresence from "../../../helpers/updatePresence"; import { IEventOptions } from "../../../interfaces/EventOptions"; +import logger from "../../../middlewares/logger"; import prisma from "../../../prisma"; export const options: IEventOptions = { From 5a1c085f1a6ae946d045c330b7ee70b486dd6eae Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 13:51:08 +0200 Subject: [PATCH 137/215] =?UTF-8?q?=F0=9F=8E=A8=20move=20empty=20line?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index ec86855..6e58d4d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,8 @@ import { Client, Collection, GatewayIntentBits } from "discord.js"; // discord.js import "dotenv/config"; - import * as managers from "./managers"; + // Main process that starts all other sub processes const main = async () => { // Initiate client object From cded0f94400f5fdf9864c36efca93b73bd162441 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 13:51:58 +0200 Subject: [PATCH 138/215] =?UTF-8?q?=F0=9F=9A=A7=20=20Dynamic=20embed=20con?= =?UTF-8?q?figs=20not=20using=20Prisma=20yet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/helpers/getEmbedData/index.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/helpers/getEmbedData/index.ts b/src/helpers/getEmbedData/index.ts index 3ac9ac8..bb54e80 100644 --- a/src/helpers/getEmbedData/index.ts +++ b/src/helpers/getEmbedData/index.ts @@ -1,5 +1,3 @@ -import guildSchema from "../../models/guild"; - import { Guild } from "discord.js"; export default async (guild?: Guild | null) => { @@ -23,10 +21,12 @@ export default async (guild?: Guild | null) => { return defaultEmbedConfig; } - const guildConfig = await guildSchema.findOne({ guildId: guild.id }); - if (!guildConfig) { - return defaultEmbedConfig; - } + return defaultEmbedConfig; - return guildConfig.embeds; + // const guildConfig = await guildSchema.findOne({ guildId: guild.id }); + // if (!guildConfig) { + // return defaultEmbedConfig; + // } + + // return guildConfig.embeds; }; From 9f191dd8e81c62db3c76d38198acbbb033a7fc8b Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 13:52:15 +0200 Subject: [PATCH 139/215] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Add?= =?UTF-8?q?ed=20example=20on=20how=20to=20get=20a=20guildMember?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/getGuildMember.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 examples/getGuildMember.ts diff --git a/examples/getGuildMember.ts b/examples/getGuildMember.ts new file mode 100644 index 0000000..a60c21a --- /dev/null +++ b/examples/getGuildMember.ts @@ -0,0 +1,11 @@ +const getGuildMember = await prisma.guildMember.findUnique({ + where: { + userId_guildId: { + userId: author.id, + guildId: guild.id, + }, + }, + include: { + guild: true, + }, +}); From 4f528377e41e8d4db4857c94a61e6df7b8fc0ed1 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 16:28:49 +0200 Subject: [PATCH 140/215] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20EMEBD=5FCOLOR=5FSU?= =?UTF-8?q?CCESS=20fixed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 51665d3..3fd7d4f 100644 --- a/.env.example +++ b/.env.example @@ -13,7 +13,7 @@ ENCRYPTION_ALGORITHM="aes-256-ctr" ENCRYPTION_SECRET="A RANDOM STRING WITH LENGTH OF 32" #Embed -EMEBD_COLOR_SUCCESS="#22bb33" +EMBED_COLOR_SUCCESS="#22bb33" EMBED_COLOR_WAIT="#f0ad4e" EMBED_COLOR_ERROR="#bb2124" EMBED_FOOTER_TEXT="https://github.com/ZynerOrg/xyter" From 55270d30abfcabc8e29513d4e7017c6c88f83db9 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 17:04:30 +0200 Subject: [PATCH 141/215] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Fix?= =?UTF-8?q?ed=20an=20transfer=20transaction=20helper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20221019142757_modules/migration.sql | 16 ++++ prisma/schema.prisma | 7 +- src/helpers/transferCredits.ts | 93 +++++++++++++++++++ 3 files changed, 113 insertions(+), 3 deletions(-) create mode 100644 prisma/migrations/20221019142757_modules/migration.sql create mode 100644 src/helpers/transferCredits.ts diff --git a/prisma/migrations/20221019142757_modules/migration.sql b/prisma/migrations/20221019142757_modules/migration.sql new file mode 100644 index 0000000..ec153f0 --- /dev/null +++ b/prisma/migrations/20221019142757_modules/migration.sql @@ -0,0 +1,16 @@ +-- RedefineTables +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_GuildMember" ( + "userId" TEXT NOT NULL, + "guildId" TEXT NOT NULL, + "creditsEarned" INTEGER NOT NULL DEFAULT 0, + "pointsEarned" INTEGER NOT NULL DEFAULT 0, + CONSTRAINT "GuildMember_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, + CONSTRAINT "GuildMember_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE +); +INSERT INTO "new_GuildMember" ("creditsEarned", "guildId", "pointsEarned", "userId") SELECT coalesce("creditsEarned", 0) AS "creditsEarned", "guildId", coalesce("pointsEarned", 0) AS "pointsEarned", "userId" FROM "GuildMember"; +DROP TABLE "GuildMember"; +ALTER TABLE "new_GuildMember" RENAME TO "GuildMember"; +CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember"("userId", "guildId"); +PRAGMA foreign_key_check; +PRAGMA foreign_keys=ON; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index a1ab624..7b621c1 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -2,7 +2,8 @@ // learn more about it in the docs: https://pris.ly/d/prisma-schema generator client { - provider = "prisma-client-js" + provider = "prisma-client-js" + previewFeatures = ["interactiveTransactions"] } datasource db { @@ -86,8 +87,8 @@ model GuildMember { // Settings // Modules - creditsEarned Int? - pointsEarned Int? + creditsEarned Int @default(0) + pointsEarned Int @default(0) // Unique Identifier @@unique([userId, guildId]) diff --git a/src/helpers/transferCredits.ts b/src/helpers/transferCredits.ts new file mode 100644 index 0000000..538eee9 --- /dev/null +++ b/src/helpers/transferCredits.ts @@ -0,0 +1,93 @@ +import { Guild, User } from "discord.js"; +import prisma from "../prisma"; + +export default async (guild: Guild, from: User, to: User, amount: number) => { + return await prisma.$transaction(async (tx) => { + // 1. Decrement amount from the sender. + const sender = await tx.guildMember.upsert({ + update: { + creditsEarned: { + decrement: amount, + }, + }, + create: { + user: { + connectOrCreate: { + create: { + id: from.id, + }, + where: { + id: from.id, + }, + }, + }, + guild: { + connectOrCreate: { + create: { + id: guild.id, + }, + where: { + id: guild.id, + }, + }, + }, + creditsEarned: -amount, + }, + where: { + userId_guildId: { + userId: from.id, + guildId: guild.id, + }, + }, + }); + + if (!sender) throw new Error("No sender available"); + + if (!sender.creditsEarned) throw new Error("No credits available"); + + // 2. Verify that the sender's balance didn't go below zero. + if (sender.creditsEarned < 0) { + throw new Error(`${from} doesn't have enough to send ${amount}`); + } + + // 3. Increment the recipient's balance by amount + const recipient = await tx.guildMember.upsert({ + update: { + creditsEarned: { + increment: amount, + }, + }, + create: { + user: { + connectOrCreate: { + create: { + id: to.id, + }, + where: { + id: to.id, + }, + }, + }, + guild: { + connectOrCreate: { + create: { + id: guild.id, + }, + where: { + id: guild.id, + }, + }, + }, + creditsEarned: +amount, + }, + where: { + userId_guildId: { + userId: to.id, + guildId: guild.id, + }, + }, + }); + + return recipient; + }); +}; From ef05794ed5059d6950ed4c15354aed74895774bf Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 17:04:56 +0200 Subject: [PATCH 142/215] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Changed=20to=20Pri?= =?UTF-8?q?sma=20for=20credits=20module?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commands/credits/modules/balance/index.ts | 68 ++++--- .../commands/credits/modules/gift/index.ts | 171 +----------------- .../commands/credits/modules/top/index.ts | 30 +-- .../commands/credits/modules/work/index.ts | 80 +++++--- 4 files changed, 124 insertions(+), 225 deletions(-) diff --git a/src/plugins/commands/credits/modules/balance/index.ts b/src/plugins/commands/credits/modules/balance/index.ts index 3cddb4b..153e73b 100644 --- a/src/plugins/commands/credits/modules/balance/index.ts +++ b/src/plugins/commands/credits/modules/balance/index.ts @@ -1,8 +1,8 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { CommandInteraction, EmbedBuilder } from "discord.js"; import getEmbedConfig from "../../../../../helpers/getEmbedData"; -import fetchUser from "../../../../../helpers/userData"; import logger from "../../../../../middlewares/logger"; +import prisma from "../../../../../prisma"; export default { metadata: { guildOnly: true, ephemeral: true }, @@ -38,39 +38,53 @@ export default { }); } - const userObj = await fetchUser(discordUser || user, guild); + const createGuildMember = await prisma.guildMember.upsert({ + where: { + userId_guildId: { + userId: (discordUser || user).id, + guildId: guild.id, + }, + }, + update: {}, + create: { + user: { + connectOrCreate: { + create: { + id: (discordUser || user).id, + }, + where: { + id: (discordUser || user).id, + }, + }, + }, + guild: { + connectOrCreate: { + create: { + id: guild.id, + }, + where: { + id: guild.id, + }, + }, + }, + }, + include: { + user: true, + guild: true, + }, + }); - if (userObj === null) { - logger.silly(`User not found`); + logger.silly(createGuildMember); - return interaction.editReply({ - embeds: [ - embed - .setDescription( - "User is not found. Please try again with a valid user." - ) - .setColor(errorColor), - ], - }); - } - - if (userObj.credits === null) { - logger.silly(`User has no credits`); - - return interaction.editReply({ - embeds: [ - embed.setDescription("Credits not found").setColor(errorColor), - ], - }); - } - - logger.silly(`Found user ${discordUser || user}`); + if (!createGuildMember) throw new Error("No guild member exists."); return interaction.editReply({ embeds: [ embed .setDescription( - `${discordUser || user} currently has ${userObj.credits} credits.` + `${discordUser || user} currently has ${ + createGuildMember.creditsEarned + } credits.` ) .setColor(successColor), ], diff --git a/src/plugins/commands/credits/modules/gift/index.ts b/src/plugins/commands/credits/modules/gift/index.ts index ca2f554..b811e3a 100644 --- a/src/plugins/commands/credits/modules/gift/index.ts +++ b/src/plugins/commands/credits/modules/gift/index.ts @@ -5,12 +5,10 @@ import { EmbedBuilder, SlashCommandSubcommandBuilder, } from "discord.js"; -import mongoose from "mongoose"; +import transferCredits from "../../../../../helpers/transferCredits"; // Configurations import getEmbedConfig from "../../../../../helpers/getEmbedData"; -import fetchUser from "../../../../../helpers/userData"; // Handlers -import logger from "../../../../../middlewares/logger"; // Function export default { @@ -50,164 +48,11 @@ export default { .setTimestamp(new Date()) .setFooter({ text: footerText, iconURL: footerIcon }); - if (guild === null) { - logger.silly(`Guild is null`); + if (!guild) throw new Error("Guild not found"); + if (!optionUser) throw new Error("No receiver found"); + if (!optionAmount) throw new Error("Amount not found"); - return interaction.editReply({ - embeds: [ - embed.setDescription("Guild is not found").setColor(errorColor), - ], - }); - } - - if (optionUser === null) { - logger.silly(`User not found`); - - return interaction.editReply({ - embeds: [ - embed - .setDescription(`User is not found in this guild`) - .setColor(errorColor), - ], - }); - } - - // Get fromUserDB object - const fromUserDB = await fetchUser(user, guild); - - // Get toUserDB object - const toUserDB = await fetchUser(optionUser, guild); - - if (fromUserDB === null) { - logger.silly(`User not found`); - - return interaction.editReply({ - embeds: [ - embed - .setDescription( - "You do not have any credits. Please write something in the chat to get some." - ) - .setColor(errorColor), - ], - }); - } - - if (toUserDB === null) { - logger.silly(`User not found`); - - return interaction.editReply({ - embeds: [ - embed - .setDescription( - "The user you want to gift credits to does not have any credits. Please wait until that user has typed something in the chat to get some." - ) - .setColor(errorColor), - ], - }); - } - - // If receiver is same as sender - if (optionUser.id === user.id) { - logger.silly(`User is same as sender`); - - return interaction.editReply({ - embeds: [ - embed - .setDescription( - "You can't gift credits to yourself. Please choose a different user." - ) - .setColor(errorColor), - ], - }); - } - - // If amount is null - if (optionAmount === null) { - logger.silly(`Amount is null`); - - return interaction.editReply({ - embeds: [ - embed - .setDescription( - "Please specify the amount of credits you want to gift." - ) - .setColor(errorColor), - ], - }); - } - - // If amount is zero or below - if (optionAmount <= 0) { - logger.silly(`Amount is zero or below`); - - return interaction.editReply({ - embeds: [ - embed - .setDescription( - "Please specify a valid amount of credits you want to gift." - ) - .setColor(errorColor), - ], - }); - } - - // If user has below gifting amount - if (fromUserDB.credits < optionAmount) { - logger.silly(`User has below gifting amount`); - - return interaction.editReply({ - embeds: [ - embed - .setDescription( - "You don't have enough credits to gift that amount. Please try again with a lower amount." - ) - .setColor(errorColor), - ], - }); - } - - // If toUserDB has no credits - if (toUserDB === null) { - logger.silly(`User has no credits`); - - return interaction.editReply({ - embeds: [ - embed - .setDescription( - "The user you want to gift credits to does not have any credits. Please wait until that user has typed something in the chat to get some." - ) - .setColor(errorColor), - ], - }); - } - - const session = await mongoose.startSession(); - - session.startTransaction(); - - try { - // Withdraw amount from fromUserDB - fromUserDB.credits -= optionAmount; - - // Deposit amount to toUserDB - toUserDB.credits += optionAmount; - - await fromUserDB.save(); - - await toUserDB.save(); - - await session.commitTransaction(); - } catch (error) { - await session.abortTransaction(); - session.endSession(); - - throw new Error( - "An error occurred while trying to gift credits. Please try again later." - ); - } finally { - // ending the session - session.endSession(); - } + await transferCredits(guild, user, optionUser, optionAmount); // Get DM user object const dmUser = client.users.cache.get(optionUser.id); @@ -231,9 +76,9 @@ export default { embeds: [ embed .setDescription( - `Successfully gifted ${optionAmount} credits to ${ - optionUser.tag - } with reason: ${optionReason || "unspecified"}` + `Successfully gifted ${optionAmount} credits to ${optionUser} with reason: ${ + optionReason || "unspecified" + }` ) .setColor(successColor), ], diff --git a/src/plugins/commands/credits/modules/top/index.ts b/src/plugins/commands/credits/modules/top/index.ts index 0ad0bb1..98dc814 100644 --- a/src/plugins/commands/credits/modules/top/index.ts +++ b/src/plugins/commands/credits/modules/top/index.ts @@ -1,8 +1,9 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import { GuildMember } from "@prisma/client"; import { CommandInteraction, EmbedBuilder } from "discord.js"; import getEmbedConfig from "../../../../../helpers/getEmbedData"; import logger from "../../../../../middlewares/logger"; -import userSchema, { IUser } from "../../../../../models/user"; +import prisma from "../../../../../prisma"; export default { metadata: { guildOnly: true, ephemeral: false }, @@ -34,19 +35,25 @@ export default { }); } - const usersDB = await userSchema.find({ guildId: guild.id }); + // const usersDB = await userSchema.find({ guildId: guild.id }); - const topTen = usersDB + const topTen = await prisma.guildMember.findMany({ + where: { + guildId: guild.id, + }, + orderBy: { + creditsEarned: "desc", + }, + take: 10, + }); - // Sort them after credits amount (ascending) - .sort((a, b) => (a.credits > b.credits ? -1 : 1)) - - // Return the top 10 - .slice(0, 10); + logger.silly(topTen); // Create entry object - const entry = (x: IUser, index: number) => - `${index + 1}. <@${x.userId}> - ${x.credits} credits`; + const entry = (guildMember: GuildMember, index: number) => + `${index + 1}. <@${guildMember.userId}> - ${ + guildMember.creditsEarned + } credits`; return interaction.editReply({ embeds: [ @@ -54,8 +61,7 @@ export default { .setDescription( `Below are the top ten members in this guild. - ${topTen.map(entry).join("\n")} - ` + ${topTen.map(entry).join("\n")}` ) .setColor(successColor), ], diff --git a/src/plugins/commands/credits/modules/work/index.ts b/src/plugins/commands/credits/modules/work/index.ts index d9be719..716eb47 100644 --- a/src/plugins/commands/credits/modules/work/index.ts +++ b/src/plugins/commands/credits/modules/work/index.ts @@ -7,10 +7,9 @@ import * as cooldown from "../../../../../helpers/cooldown"; // Configurations import getEmbedConfig from "../../../../../helpers/getEmbedData"; // Helpers -import fetchGuild from "../../../../../helpers/guildData"; -import fetchUser from "../../../../../helpers/userData"; // Handlers import logger from "../../../../../middlewares/logger"; +import prisma from "../../../../../prisma"; export default { metadata: { guildOnly: true, ephemeral: true }, @@ -39,35 +38,70 @@ export default { return logger?.silly(`Guild is null`); } - const guildDB = await fetchGuild(guild); + const createGuild = await prisma.guild.upsert({ + where: { + id: guild.id, + }, + update: {}, + create: { + id: guild.id, + }, + }); - await cooldown.command(interaction, guildDB?.credits?.workTimeout); + logger.silly(createGuild); + + await cooldown.command(interaction, createGuild.creditsWorkTimeout); const creditsEarned = chance.integer({ min: 0, - max: guildDB?.credits?.workRate, + max: createGuild.creditsWorkRate, }); - const userDB = await fetchUser(user, guild); + const createGuildMember = await prisma.guildMember.upsert({ + where: { + userId_guildId: { + userId: user.id, + guildId: guild.id, + }, + }, + update: { creditsEarned: { increment: creditsEarned } }, + create: { + creditsEarned, + user: { + connectOrCreate: { + create: { + id: user.id, + }, + where: { + id: user.id, + }, + }, + }, + guild: { + connectOrCreate: { + create: { + id: guild.id, + }, + where: { + id: guild.id, + }, + }, + }, + }, + include: { + user: true, + guild: true, + }, + }); - if (userDB === null) { - return logger?.silly(`User not found`); - } + logger.silly(createGuildMember); - userDB.credits += creditsEarned; - - await userDB?.save()?.then(() => { - logger?.silly( - `User ${userDB?.userId} worked and earned ${creditsEarned} credits` - ); - - return interaction.editReply({ - embeds: [ - embed - .setDescription(`You worked and earned ${creditsEarned} credits.`) - .setColor(successColor), - ], - }); + return interaction.editReply({ + embeds: [ + embed + .setDescription(`You worked and earned ${creditsEarned} credits.`) + .setColor(successColor), + ], }); }, }; From d26a8367dda27b4f26f474adab326ffbf07deece Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 17:05:26 +0200 Subject: [PATCH 143/215] =?UTF-8?q?=E2=9A=B0=EF=B8=8F=20errorColor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/commands/credits/modules/gift/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/commands/credits/modules/gift/index.ts b/src/plugins/commands/credits/modules/gift/index.ts index b811e3a..b62aeff 100644 --- a/src/plugins/commands/credits/modules/gift/index.ts +++ b/src/plugins/commands/credits/modules/gift/index.ts @@ -35,8 +35,9 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { - const { errorColor, successColor, footerText, footerIcon } = - await getEmbedConfig(interaction.guild); + const { successColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); const { options, user, guild, client } = interaction; const optionUser = options.getUser("user"); From 7da0d9a97f4e434ce3065615f6b4672b0c81777a Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 17:13:08 +0200 Subject: [PATCH 144/215] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Migrated=20more=20?= =?UTF-8?q?credits=20module=20to=20Prisma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/credits/modules/give/index.ts | 87 +++++---- .../modules/credits/modules/set/index.ts | 98 +++++----- .../modules/credits/modules/take/index.ts | 105 +++++----- .../modules/credits/modules/transfer/index.ts | 184 +----------------- 4 files changed, 156 insertions(+), 318 deletions(-) diff --git a/src/plugins/commands/manage/modules/credits/modules/give/index.ts b/src/plugins/commands/manage/modules/credits/modules/give/index.ts index cab7050..4ed822c 100644 --- a/src/plugins/commands/manage/modules/credits/modules/give/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/give/index.ts @@ -5,14 +5,14 @@ import { EmbedBuilder, PermissionsBitField, } from "discord.js"; +import logger from "../../../../../../../middlewares/logger"; // Configurations import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; // Helpers../../../../../../../helpers/userData import pluralize from "../../../../../../../helpers/pluralize"; // Models -import fetchUser from "../../../../../../../helpers/userData"; // Handlers - +import prisma from "../../../../../../../prisma"; // Function export default { metadata: { @@ -48,50 +48,67 @@ export default { const creditAmount = options?.getInteger("amount"); // If amount option is null - if (creditAmount === null) { + if (creditAmount === null) throw new Error("You need to provide a credit amount."); - } // If amount is zero or below - if (creditAmount <= 0) { + if (creditAmount <= 0) throw new Error("You must provide a credit amount greater than zero"); - } - if (discordReceiver === null) { + if (discordReceiver === null) throw new Error("We could not get the receiving user from Discord"); - } - if (guild === null) { + + if (guild === null) throw new Error("We could not get the current guild from discord."); - } - const toUser = await fetchUser(discordReceiver, guild); + const createGuildMember = await prisma.guildMember.upsert({ + where: { + userId_guildId: { + userId: discordReceiver.id, + guildId: guild.id, + }, + }, + update: { creditsEarned: { increment: creditAmount } }, + create: { + creditsEarned: creditAmount, + user: { + connectOrCreate: { + create: { + id: discordReceiver.id, + }, + where: { + id: discordReceiver.id, + }, + }, + }, + guild: { + connectOrCreate: { + create: { + id: guild.id, + }, + where: { + id: guild.id, + }, + }, + }, + }, + }); - if (toUser === null) { - throw new Error("The receiving user is not found."); - } - - if (toUser?.credits === null) { - throw new Error("The receiving user's credits value could not found."); - } - - // Deposit amount to toUser - toUser.credits += creditAmount; + logger.silly(createGuildMember); // Save toUser - await toUser?.save()?.then(async () => { - await interaction?.editReply({ - embeds: [ - new EmbedBuilder() - .setTitle("[:toolbox:] Manage - Credits (Give)") - .setDescription( - `Successfully gave ${pluralize(creditAmount, "credit")}` - ) - .setTimestamp(new Date()) - .setColor(successColor) - .setFooter({ text: footerText, iconURL: footerIcon }), - ], - }); - return; + await interaction?.editReply({ + embeds: [ + new EmbedBuilder() + .setTitle("[:toolbox:] Manage - Credits (Give)") + .setDescription( + `Successfully gave ${pluralize(creditAmount, "credit")}` + ) + .setTimestamp(new Date()) + .setColor(successColor) + .setFooter({ text: footerText, iconURL: footerIcon }), + ], }); + return; }, }; diff --git a/src/plugins/commands/manage/modules/credits/modules/set/index.ts b/src/plugins/commands/manage/modules/credits/modules/set/index.ts index 8db2bd6..562ca32 100644 --- a/src/plugins/commands/manage/modules/credits/modules/set/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/set/index.ts @@ -9,9 +9,9 @@ import { } from "discord.js"; // Configurations import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; -import fetchUser from "../../../../../../../helpers/userData"; // Handlers import logger from "../../../../../../../middlewares/logger"; +import prisma from "../../../../../../../prisma"; // Function export default { @@ -91,60 +91,52 @@ export default { }); } - // toUser Information - const toUser = await fetchUser(discordUser, guild); + const createGuildMember = await prisma.guildMember.upsert({ + where: { + userId_guildId: { + userId: discordUser.id, + guildId: guild.id, + }, + }, + update: { creditsEarned: creditAmount }, + create: { + creditsEarned: creditAmount, + user: { + connectOrCreate: { + create: { + id: discordUser.id, + }, + where: { + id: discordUser.id, + }, + }, + }, + guild: { + connectOrCreate: { + create: { + id: guild.id, + }, + where: { + id: guild.id, + }, + }, + }, + }, + }); - // If toUser does not exist - if (toUser === null) { - logger?.silly(`User does not exist`); + logger.silly(createGuildMember); - return interaction?.editReply({ - embeds: [ - new EmbedBuilder() - .setTitle("[:toolbox:] Manage - Credits (Set)") - .setDescription(`The user you provided does not exist.`) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }), - ], - }); - } - - // If toUser.credits does not exist - if (toUser?.credits === null) { - logger?.silly(`User does not have any credits`); - - return interaction?.editReply({ - embeds: [ - new EmbedBuilder() - .setTitle("[:toolbox:] Manage - Credits (Set)") - .setDescription(`The user you provided does not have any credits.`) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }), - ], - }); - } - - // Set toUser with amount - toUser.credits = creditAmount; - - // Save toUser - await toUser?.save()?.then(async () => { - logger?.silly(`Saved user`); - - return interaction?.editReply({ - embeds: [ - new EmbedBuilder() - .setTitle("[:toolbox:] Manage - Credits (Set)") - .setDescription( - `Set **${discordUser}**'s credits to **${creditAmount}**.` - ) - .setTimestamp(new Date()) - .setColor(successColor) - .setFooter({ text: footerText, iconURL: footerIcon }), - ], - }); + return interaction?.editReply({ + embeds: [ + new EmbedBuilder() + .setTitle("[:toolbox:] Manage - Credits (Set)") + .setDescription( + `Set **${discordUser}**'s credits to **${creditAmount}**.` + ) + .setTimestamp(new Date()) + .setColor(successColor) + .setFooter({ text: footerText, iconURL: footerIcon }), + ], }); }, }; diff --git a/src/plugins/commands/manage/modules/credits/modules/take/index.ts b/src/plugins/commands/manage/modules/credits/modules/take/index.ts index 5b920ba..1c5f256 100644 --- a/src/plugins/commands/manage/modules/credits/modules/take/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/take/index.ts @@ -10,9 +10,9 @@ import { import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; // Helpers../../../../../../../helpers/userData import pluralize from "../../../../../../../helpers/pluralize"; -import fetchUser from "../../../../../../../helpers/userData"; // Handlers import logger from "../../../../../../../middlewares/logger"; +import prisma from "../../../../../../../prisma"; // Function export default { @@ -45,7 +45,7 @@ export default { const { guild, options } = interaction; // User option - const optionUser = options?.getUser("user"); + const discordReceiver = options?.getUser("user"); // Amount option const optionAmount = options?.getInteger("amount"); @@ -82,7 +82,7 @@ export default { }); } - if (optionUser === null) { + if (discordReceiver === null) { logger?.silly(`Discord receiver is null`); return interaction?.editReply({ @@ -111,59 +111,52 @@ export default { }); } - // toUser Information - const toUser = await fetchUser(optionUser, guild); - - // If toUser does not exist - if (toUser === null) { - logger?.silly(`ToUser is null`); - - return interaction?.editReply({ - embeds: [ - new EmbedBuilder() - .setTitle("[:toolbox:] Manage - Credits (Take)") - .setDescription(`The user you provided does not exist.`) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }), - ], - }); - } - - // If toUser.credits does not exist - if (toUser?.credits === null) { - logger?.silly(`ToUser.credits is null`); - - return interaction?.editReply({ - embeds: [ - new EmbedBuilder() - .setTitle("[:toolbox:] Manage - Credits (Take)") - .setDescription(`The user you provided does not have credits.`) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }), - ], - }); - } - - // Withdraw amount from toUser - toUser.credits -= optionAmount; - - // Save toUser - await toUser?.save()?.then(async () => { - await interaction?.editReply({ - embeds: [ - new EmbedBuilder() - .setTitle("[:toolbox:] Manage - Credits (Take)") - .setDescription( - `Took ${pluralize(optionAmount, "credit")} from ${optionUser}.` - ) - .setTimestamp(new Date()) - .setColor(successColor) - .setFooter({ text: footerText, iconURL: footerIcon }), - ], - }); - return; + const createGuildMember = await prisma.guildMember.upsert({ + where: { + userId_guildId: { + userId: discordReceiver.id, + guildId: guild.id, + }, + }, + update: { creditsEarned: { decrement: optionAmount } }, + create: { + creditsEarned: -optionAmount, + user: { + connectOrCreate: { + create: { + id: discordReceiver.id, + }, + where: { + id: discordReceiver.id, + }, + }, + }, + guild: { + connectOrCreate: { + create: { + id: guild.id, + }, + where: { + id: guild.id, + }, + }, + }, + }, }); + + logger.silly(createGuildMember); + await interaction?.editReply({ + embeds: [ + new EmbedBuilder() + .setTitle("[:toolbox:] Manage - Credits (Take)") + .setDescription( + `Took ${pluralize(optionAmount, "credit")} from ${discordReceiver}.` + ) + .setTimestamp(new Date()) + .setColor(successColor) + .setFooter({ text: footerText, iconURL: footerIcon }), + ], + }); + return; }, }; diff --git a/src/plugins/commands/manage/modules/credits/modules/transfer/index.ts b/src/plugins/commands/manage/modules/credits/modules/transfer/index.ts index 62a9425..cfe959e 100644 --- a/src/plugins/commands/manage/modules/credits/modules/transfer/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/transfer/index.ts @@ -6,12 +6,10 @@ import { EmbedBuilder, PermissionsBitField, } from "discord.js"; -import mongoose from "mongoose"; +import transferCredits from "../../../../../../../helpers/transferCredits"; // Configurations import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; -import fetchUser from "../../../../../../../helpers/userData"; // Handlers../../../../../../../helpers/userData -import logger from "../../../../../../../middlewares/logger"; // Function export default { @@ -54,188 +52,26 @@ export default { const optionToUser = options?.getUser("to"); const optionAmount = options?.getInteger("amount"); - // If amount is null - if (optionAmount === null) { - logger?.silly(`Amount is null`); + if (optionAmount === null) throw new Error("Amount is not specified"); - return interaction?.editReply({ - embeds: [ - new EmbedBuilder() - .setTitle("[:toolbox:] Manage - Credits (Transfer)") - .setDescription(`You must provide an amount.`) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }), - ], - }); - } + if (optionAmount <= 0) + throw new Error("You need to set amount above zero to transfer."); - if (guild === null) { - logger?.silly(`Guild is null`); + if (!guild) throw new Error(`We could not find this guild.`); - return interaction?.editReply({ - embeds: [ - new EmbedBuilder() - .setTitle("[:toolbox:] Manage - Credits (Transfer)") - .setDescription(`You must be in a guild.`) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }), - ], - }); - } - if (optionFromUser === null) { - logger?.silly(`From user is null`); + if (!optionFromUser) + throw new Error("You must provide a user to transfer from."); - return interaction?.editReply({ - embeds: [ - new EmbedBuilder() - .setTitle("[:toolbox:] Manage - Credits (Transfer)") - .setDescription(`You must provide a user to transfer from.`) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }), - ], - }); - } - if (optionToUser === null) { - logger?.silly(`To user is null`); + if (!optionToUser) + throw new Error("You must provide a user to transfer to."); - return interaction?.editReply({ - embeds: [ - new EmbedBuilder() - .setTitle("[:toolbox:] Manage - Credits (Transfer)") - .setDescription(`You must provide a user to transfer to.`) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }), - ], - }); - } - - // Get fromUser object - const fromUser = await fetchUser(optionFromUser, guild); - - // Get toUser object - const toUser = await fetchUser(optionToUser, guild); - - // If toUser does not exist - if (fromUser === null) { - logger?.silly(`From user does not exist`); - - return interaction?.editReply({ - embeds: [ - new EmbedBuilder() - .setTitle("[:toolbox:] Manage - Credits (Transfer)") - .setDescription( - `The user you provided to transfer from does not exist.` - ) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }), - ], - }); - } - - // If toUser.credits does not exist - if (!fromUser?.credits) { - logger?.silly(`From user does not have credits`); - - return interaction?.editReply({ - embeds: [ - new EmbedBuilder() - .setTitle("[:toolbox:] Manage - Credits (Transfer)") - .setDescription( - `The user you provided to transfer from does not have credits.` - ) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }), - ], - }); - } - - // If toUser does not exist - if (toUser === null) { - logger?.silly(`To user does not exist`); - - return interaction?.editReply({ - embeds: [ - new EmbedBuilder() - .setTitle("[:toolbox:] Manage - Credits (Transfer)") - .setDescription( - `The user you provided to transfer to does not exist.` - ) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }), - ], - }); - } - - // If toUser.credits does not exist - if (toUser?.credits === null) { - logger?.silly(`To user does not have credits`); - - return interaction?.editReply({ - embeds: [ - new EmbedBuilder() - .setTitle("[:toolbox:] Manage - Credits (Transfer)") - .setDescription( - `The user you provided to transfer to does not have credits.` - ) - .setTimestamp(new Date()) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }), - ], - }); - } - - const session = await mongoose.startSession(); - - session.startTransaction(); - - try { - // Withdraw amount from fromUserDB - fromUser.credits -= optionAmount; - - // Deposit amount to toUserDB - toUser.credits += optionAmount; - - await fromUser.save(); - - await toUser.save(); - - await session.commitTransaction(); - } catch (error: unknown) { - await session.abortTransaction(); - session.endSession(); - - throw new Error( - "An error occurred while trying to gift credits. Please try again later." - ); - } finally { - // ending the session - session.endSession(); - } + await transferCredits(guild, optionFromUser, optionToUser, optionAmount); return interaction?.editReply({ embeds: [ new EmbedBuilder() .setTitle("[:toolbox:] Manage - Credits (Transfer)") .setDescription(`Transferred ${optionAmount} credits.`) - .addFields( - { - name: `${optionFromUser?.username} Balance`, - value: `${fromUser?.credits}`, - inline: true, - }, - { - name: `${optionToUser?.username} Balance`, - value: `${toUser?.credits}`, - inline: true, - } - ) .setTimestamp(new Date()) .setColor(successColor) .setFooter({ text: footerText, iconURL: footerIcon }), From f737ec084cbb160d0dd930c9829e5982dae64704 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 17:25:01 +0200 Subject: [PATCH 145/215] =?UTF-8?q?=F0=9F=90=9B=20=F0=9F=92=A1=20Negative?= =?UTF-8?q?=20transfers=20fixed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/helpers/transferCredits.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/helpers/transferCredits.ts b/src/helpers/transferCredits.ts index 538eee9..4d648ba 100644 --- a/src/helpers/transferCredits.ts +++ b/src/helpers/transferCredits.ts @@ -41,16 +41,23 @@ export default async (guild: Guild, from: User, to: User, amount: number) => { }, }); + // 2. Verify that the sender actually is created. if (!sender) throw new Error("No sender available"); + // 3. Verify that the sender's balance exists. if (!sender.creditsEarned) throw new Error("No credits available"); - // 2. Verify that the sender's balance didn't go below zero. + // 4. Verify that the sender's balance didn't go below zero. if (sender.creditsEarned < 0) { throw new Error(`${from} doesn't have enough to send ${amount}`); } - // 3. Increment the recipient's balance by amount + // 5. Verify that the sender is not trying to send less that one credits. + if (amount <= 0) { + throw new Error("You can't give negative amounts."); + } + + // 6. Increment the recipient's balance by amount const recipient = await tx.guildMember.upsert({ update: { creditsEarned: { From 4a386b9b0090ade2c0efad17a97501125b3f9534 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 20:40:09 +0200 Subject: [PATCH 146/215] Update command_request.yaml --- .github/ISSUE_TEMPLATE/command_request.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/command_request.yaml b/.github/ISSUE_TEMPLATE/command_request.yaml index e6d047c..bb03656 100644 --- a/.github/ISSUE_TEMPLATE/command_request.yaml +++ b/.github/ISSUE_TEMPLATE/command_request.yaml @@ -42,7 +42,7 @@ body: id: terms attributes: label: Code of Conduct - description: By submitting this issue, you agree to follow our [Code of Conduct](https://example.com) + description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/ZynerOrg/xyter/blob/main/CODE_OF_CONDUCT.md) options: - label: I agree to follow this project's Code of Conduct required: true From ecee0f747e6be91c5c31a2249ccc1cc45c953821 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 20:56:47 +0200 Subject: [PATCH 147/215] =?UTF-8?q?=F0=9F=97=83=EF=B8=8F=20Updated=20schem?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20221019153247_cooldowns/migration.sql | 12 +++ .../20221019153652_audit_dates/migration.sql | 86 +++++++++++++++++++ .../20221019172846_embedconfig/migration.sql | 30 +++++++ prisma/schema.prisma | 39 ++++++++- 4 files changed, 164 insertions(+), 3 deletions(-) create mode 100644 prisma/migrations/20221019153247_cooldowns/migration.sql create mode 100644 prisma/migrations/20221019153652_audit_dates/migration.sql create mode 100644 prisma/migrations/20221019172846_embedconfig/migration.sql diff --git a/prisma/migrations/20221019153247_cooldowns/migration.sql b/prisma/migrations/20221019153247_cooldowns/migration.sql new file mode 100644 index 0000000..ddaf6d9 --- /dev/null +++ b/prisma/migrations/20221019153247_cooldowns/migration.sql @@ -0,0 +1,12 @@ +-- CreateTable +CREATE TABLE "Cooldown" ( + "guildId" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "cooldown" INTEGER NOT NULL, + "timeoutId" TEXT NOT NULL, + CONSTRAINT "Cooldown_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, + CONSTRAINT "Cooldown_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE +); + +-- CreateIndex +CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown"("guildId", "userId", "timeoutId"); diff --git a/prisma/migrations/20221019153652_audit_dates/migration.sql b/prisma/migrations/20221019153652_audit_dates/migration.sql new file mode 100644 index 0000000..7bc464b --- /dev/null +++ b/prisma/migrations/20221019153652_audit_dates/migration.sql @@ -0,0 +1,86 @@ +/* + Warnings: + + - Added the required column `updatedAt` to the `Guild` table without a default value. This is not possible if the table is not empty. + - Added the required column `updatedAt` to the `Cooldown` table without a default value. This is not possible if the table is not empty. + - Added the required column `updatedAt` to the `GuildCounter` table without a default value. This is not possible if the table is not empty. + - Added the required column `updatedAt` to the `User` table without a default value. This is not possible if the table is not empty. + - Added the required column `updatedAt` to the `GuildMember` table without a default value. This is not possible if the table is not empty. + +*/ +-- RedefineTables +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_Guild" ( + "id" TEXT NOT NULL, + "creditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "creditsRate" INTEGER NOT NULL DEFAULT 1, + "creditsTimeout" INTEGER NOT NULL DEFAULT 5, + "creditsWorkRate" INTEGER NOT NULL DEFAULT 25, + "creditsWorkTimeout" INTEGER NOT NULL DEFAULT 86400, + "creditsMinimumLength" INTEGER NOT NULL DEFAULT 5, + "pointsEnabled" BOOLEAN NOT NULL DEFAULT false, + "pointsRate" INTEGER NOT NULL DEFAULT 1, + "pointsTimeout" INTEGER NOT NULL DEFAULT 5, + "pointsMinimumLength" INTEGER NOT NULL DEFAULT 5, + "reputationsEnabled" BOOLEAN NOT NULL DEFAULT false, + "countersEnabled" BOOLEAN NOT NULL DEFAULT false, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL +); +INSERT INTO "new_Guild" ("countersEnabled", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled") SELECT "countersEnabled", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled" FROM "Guild"; +DROP TABLE "Guild"; +ALTER TABLE "new_Guild" RENAME TO "Guild"; +CREATE UNIQUE INDEX "Guild_id_key" ON "Guild"("id"); +CREATE TABLE "new_Cooldown" ( + "guildId" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "cooldown" INTEGER NOT NULL, + "timeoutId" TEXT NOT NULL, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + CONSTRAINT "Cooldown_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, + CONSTRAINT "Cooldown_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE +); +INSERT INTO "new_Cooldown" ("cooldown", "guildId", "timeoutId", "userId") SELECT "cooldown", "guildId", "timeoutId", "userId" FROM "Cooldown"; +DROP TABLE "Cooldown"; +ALTER TABLE "new_Cooldown" RENAME TO "Cooldown"; +CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown"("guildId", "userId", "timeoutId"); +CREATE TABLE "new_GuildCounter" ( + "guildId" TEXT NOT NULL, + "channelId" TEXT NOT NULL, + "triggerWord" TEXT NOT NULL, + "count" INTEGER NOT NULL DEFAULT 0, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + CONSTRAINT "GuildCounter_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE +); +INSERT INTO "new_GuildCounter" ("channelId", "count", "guildId", "triggerWord") SELECT "channelId", "count", "guildId", "triggerWord" FROM "GuildCounter"; +DROP TABLE "GuildCounter"; +ALTER TABLE "new_GuildCounter" RENAME TO "GuildCounter"; +CREATE UNIQUE INDEX "GuildCounter_guildId_channelId_key" ON "GuildCounter"("guildId", "channelId"); +CREATE TABLE "new_User" ( + "id" TEXT NOT NULL, + "reputationsEarned" INTEGER NOT NULL DEFAULT 0, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL +); +INSERT INTO "new_User" ("id", "reputationsEarned") SELECT "id", "reputationsEarned" FROM "User"; +DROP TABLE "User"; +ALTER TABLE "new_User" RENAME TO "User"; +CREATE UNIQUE INDEX "User_id_key" ON "User"("id"); +CREATE TABLE "new_GuildMember" ( + "userId" TEXT NOT NULL, + "guildId" TEXT NOT NULL, + "creditsEarned" INTEGER NOT NULL DEFAULT 0, + "pointsEarned" INTEGER NOT NULL DEFAULT 0, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + CONSTRAINT "GuildMember_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, + CONSTRAINT "GuildMember_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE +); +INSERT INTO "new_GuildMember" ("creditsEarned", "guildId", "pointsEarned", "userId") SELECT "creditsEarned", "guildId", "pointsEarned", "userId" FROM "GuildMember"; +DROP TABLE "GuildMember"; +ALTER TABLE "new_GuildMember" RENAME TO "GuildMember"; +CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember"("userId", "guildId"); +PRAGMA foreign_key_check; +PRAGMA foreign_keys=ON; diff --git a/prisma/migrations/20221019172846_embedconfig/migration.sql b/prisma/migrations/20221019172846_embedconfig/migration.sql new file mode 100644 index 0000000..f2d2415 --- /dev/null +++ b/prisma/migrations/20221019172846_embedconfig/migration.sql @@ -0,0 +1,30 @@ +-- RedefineTables +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_Guild" ( + "id" TEXT NOT NULL, + "embedColorSuccess" TEXT NOT NULL DEFAULT '#22bb33', + "embedColorWait" TEXT NOT NULL DEFAULT '#f0ad4e', + "embedColorError" TEXT NOT NULL DEFAULT '#bb2124', + "embedFooterText" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg/xyter', + "embedFooterIcon" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg.png', + "creditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "creditsRate" INTEGER NOT NULL DEFAULT 1, + "creditsTimeout" INTEGER NOT NULL DEFAULT 5, + "creditsWorkRate" INTEGER NOT NULL DEFAULT 25, + "creditsWorkTimeout" INTEGER NOT NULL DEFAULT 86400, + "creditsMinimumLength" INTEGER NOT NULL DEFAULT 5, + "pointsEnabled" BOOLEAN NOT NULL DEFAULT false, + "pointsRate" INTEGER NOT NULL DEFAULT 1, + "pointsTimeout" INTEGER NOT NULL DEFAULT 5, + "pointsMinimumLength" INTEGER NOT NULL DEFAULT 5, + "reputationsEnabled" BOOLEAN NOT NULL DEFAULT false, + "countersEnabled" BOOLEAN NOT NULL DEFAULT false, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL +); +INSERT INTO "new_Guild" ("countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "updatedAt") SELECT "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "updatedAt" FROM "Guild"; +DROP TABLE "Guild"; +ALTER TABLE "new_Guild" RENAME TO "Guild"; +CREATE UNIQUE INDEX "Guild_id_key" ON "Guild"("id"); +PRAGMA foreign_key_check; +PRAGMA foreign_keys=ON; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 7b621c1..0c19c74 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -12,10 +12,16 @@ datasource db { } model Guild { - id String @unique - GuildMember GuildMember[] + id String @unique + guildMembers GuildMember[] + cooldowns Cooldown[] // Settings + embedColorSuccess String @default("#22bb33") + embedColorWait String @default("#f0ad4e") + embedColorError String @default("#bb2124") + embedFooterText String @default("https://github.com/ZynerOrg/xyter") + embedFooterIcon String @default("https://github.com/ZynerOrg.png") // { // url: { @@ -65,6 +71,9 @@ model Guild { countersEnabled Boolean @default(false) counters GuildCounter[] + + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt } model User { @@ -74,7 +83,11 @@ model User { // Settings // Modules - reputationsEarned Int @default(0) + reputationsEarned Int @default(0) + Cooldown Cooldown[] + + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt } model GuildMember { @@ -90,6 +103,9 @@ model GuildMember { creditsEarned Int @default(0) pointsEarned Int @default(0) + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + // Unique Identifier @@unique([userId, guildId]) } @@ -101,5 +117,22 @@ model GuildCounter { count Int @default(0) guild Guild @relation(fields: [guildId], references: [id]) + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + @@unique([guildId, channelId]) } + +model Cooldown { + guild Guild @relation(fields: [guildId], references: [id]) + user User @relation(fields: [userId], references: [id]) + guildId String + userId String + cooldown Int + timeoutId String + + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + + @@unique([guildId, userId, timeoutId]) +} From 8e16c7fb644e0f8a488860ddb93d511151c7c2cc Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 20:57:24 +0200 Subject: [PATCH 148/215] =?UTF-8?q?=E2=9A=B0=EF=B8=8Fremove=20old=20helper?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/helpers/deleteGuildData/index.ts | 72 ---------------------------- src/helpers/deleteUserData/index.ts | 18 ------- src/helpers/guildData/index.ts | 29 ----------- src/helpers/userData/index.ts | 37 -------------- 4 files changed, 156 deletions(-) delete mode 100644 src/helpers/deleteGuildData/index.ts delete mode 100644 src/helpers/deleteUserData/index.ts delete mode 100644 src/helpers/guildData/index.ts delete mode 100644 src/helpers/userData/index.ts diff --git a/src/helpers/deleteGuildData/index.ts b/src/helpers/deleteGuildData/index.ts deleted file mode 100644 index 8d770b3..0000000 --- a/src/helpers/deleteGuildData/index.ts +++ /dev/null @@ -1,72 +0,0 @@ -import apiSchema from "../../models/api"; -import counterSchema from "../../models/counter"; -import guildSchema from "../../models/guild"; -import shopRoleSchema from "../../models/shopRole"; -import timeoutSchema from "../../models/timeout"; -import userSchema from "../../models/user"; - -import logger from "../../middlewares/logger"; - -import { Guild } from "discord.js"; - -export default async (guild: Guild) => { - await guildSchema - .deleteMany({ guildId: guild.id }) - .then(async () => { - return logger?.silly(`Deleted guild: ${guild.id}`); - }) - .catch(async (error) => { - logger?.error(`Error deleting guild: ${guild.id} - ${error}`); - }); - - await userSchema - .deleteMany({ guildId: guild.id }) - .then(async () => { - logger?.silly(`Deleted users for guild: ${guild.id} from database`); - }) - .catch(async (error) => { - logger?.error(`Error deleting users for guild: ${guild.id} - ${error}`); - }); - - await apiSchema - .deleteMany({ guildId: guild.id }) - .then(async () => { - logger?.silly(`Deleted apis for guild: ${guild.id} from database`); - }) - .catch(async (error) => { - logger?.error(`Error deleting apis for guild: ${guild.id} - ${error}`); - }); - - await counterSchema - .deleteMany({ guildId: guild.id }) - .then(async () => { - logger?.silly(`Deleted counters for guild: ${guild.id} from database`); - }) - .catch(async (error) => { - logger?.error( - `Error deleting counters for guild: ${guild.id} - ${error}` - ); - }); - - await shopRoleSchema - .deleteMany({ guildId: guild.id }) - .then(async () => { - logger?.silly(`Deleted shop roles for guild: ${guild.id} from database`); - }) - .catch(async (error) => { - logger?.error( - `Error deleting shop roles for guild: ${guild.id} - ${error}` - ); - }); - - await timeoutSchema - .deleteMany({ guildId: guild.id }) - .then(async () => { - logger?.silly(`Deleted timeouts for guild: ${guild.id} from database`); - }) - .catch(async (error) => { - logger?.error( - `Error deleting timeouts for guild: ${guild.id} - ${error}` - ); - }); -}; diff --git a/src/helpers/deleteUserData/index.ts b/src/helpers/deleteUserData/index.ts deleted file mode 100644 index 035661a..0000000 --- a/src/helpers/deleteUserData/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -import userSchema from "../../models/user"; - -import logger from "../../middlewares/logger"; - -import { Guild, User } from "discord.js"; - -export default async (user: User, guild: Guild) => { - await userSchema - .deleteOne({ userId: user.id, guildId: guild.id }) - .then(async () => { - logger?.silly(`Deleted user: ${user?.id} from guild: ${guild?.id}`); - }) - .catch(async (error) => { - logger?.error( - `Error deleting user: ${user?.id} from guild: ${guild?.id} - ${error}` - ); - }); -}; diff --git a/src/helpers/guildData/index.ts b/src/helpers/guildData/index.ts deleted file mode 100644 index a5c1dd4..0000000 --- a/src/helpers/guildData/index.ts +++ /dev/null @@ -1,29 +0,0 @@ -// Dependencies -import { Guild } from "discord.js"; - -// Models -import guildSchema from "../../models/guild"; - -// Handlers -import logger from "../../middlewares/logger"; - -// Function -export default async (guild: Guild) => { - const guildObj = await guildSchema?.findOne({ guildId: guild.id }); - if (guildObj === null) { - const newGuildObj = new guildSchema({ guildId: guild.id }); - - await newGuildObj - .save() - .then(async () => { - logger?.silly(`Created guild: ${guild.id}`); - }) - .catch(async (error) => { - logger?.error(`Error creating guild: ${guild.id} - ${error}`); - }); - - return newGuildObj; - } else { - return guildObj; - } -}; diff --git a/src/helpers/userData/index.ts b/src/helpers/userData/index.ts deleted file mode 100644 index acd3b02..0000000 --- a/src/helpers/userData/index.ts +++ /dev/null @@ -1,37 +0,0 @@ -// Dependencies -import { Guild, User } from "discord.js"; - -// Models -import userSchema from "../../models/user"; - -// Handlers -import logger from "../../middlewares/logger"; - -// Function -export default async (user: User, guild: Guild) => { - const userObj = await userSchema?.findOne({ - userId: user.id, - guildId: guild.id, - }); - if (userObj === null) { - const newUserObj = new userSchema({ - userId: user.id, - guildId: guild.id, - }); - - await newUserObj - .save() - .then(async () => { - logger?.silly(`Created user: ${user.id} for guild: ${guild.id}`); - }) - .catch(async (error) => { - logger?.error( - `Error creating user: ${user.id} for guild: ${guild.id} - ${error}` - ); - }); - - return newUserObj; - } else { - return userObj; - } -}; From 5aa373bff3a88890dfbc3c048f4da4d0c16f1b63 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 20:58:12 +0200 Subject: [PATCH 149/215] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Cooldowns=20now=20?= =?UTF-8?q?in=20Prisma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/helpers/cooldown/index.ts | 375 ++++++++++++++++++++++------------ 1 file changed, 246 insertions(+), 129 deletions(-) diff --git a/src/helpers/cooldown/index.ts b/src/helpers/cooldown/index.ts index b6357fb..3847060 100644 --- a/src/helpers/cooldown/index.ts +++ b/src/helpers/cooldown/index.ts @@ -1,157 +1,274 @@ // Dependencies import { ButtonInteraction, CommandInteraction, Message } from "discord.js"; +import addSeconds from "../../helpers/addSeconds"; import logger from "../../middlewares/logger"; +import prisma from "../../prisma"; export const command = async (i: CommandInteraction, cooldown: number) => { - // const { guild, user, commandId } = i; + const { guild, user, commandId } = i; - // // Check if user has a timeout - // const hasTimeout = await timeoutSchema.findOne({ - // guildId: guild?.id || "0", - // userId: user.id, - // cooldown: cooldown, - // timeoutId: commandId, - // }); + if (!guild) throw new Error("Guild not found"); - // // If user is not on timeout - // if (hasTimeout) { - // const { guildId, userId, timeoutId, createdAt } = hasTimeout; - // const overDue = (await addSeconds(cooldown, createdAt)) < new Date(); + // Check if user has a timeout + const hasTimeout = await prisma.cooldown.findUnique({ + where: { + guildId_userId_timeoutId: { + guildId: guild.id, + userId: user.id, + timeoutId: commandId, + }, + }, + }); - // if (!overDue) { - // const diff = Math.round( - // (new Date(hasTimeout.createdAt).getTime() - new Date().getTime()) / 1000 - // ); + logger.silly(hasTimeout); - // throw new Error( - // `You must wait ${diff} seconds before using this command.` - // ); - // } + // If user is not on timeout + if (hasTimeout) { + const { guildId, userId, timeoutId, createdAt } = hasTimeout; + const overDue = (await addSeconds(cooldown, createdAt)) < new Date(); - // // Delete timeout - // await timeoutSchema - // .deleteOne({ - // guildId, - // userId, - // timeoutId, - // cooldown, - // }) - // .then(async () => { - // logger.debug( - // `Timeout document ${timeoutId} has been deleted from user ${userId}.` - // ); - // }); - // } - // // Create timeout - // await timeoutSchema.create({ - // guildId: guild?.id || "0", - // userId: user.id, - // cooldown: cooldown, - // timeoutId: commandId, - // }); - logger.warn("Command cooldown function is not working with Prisma yet!"); - return false; + if (!overDue) { + const diff = Math.round( + (new Date(hasTimeout.createdAt).getTime() - new Date().getTime()) / 1000 + ); + + throw new Error( + `You must wait ${diff} seconds before using this command.` + ); + } + + // Delete timeout + const deleteCooldown = await prisma.cooldown.delete({ + where: { + guildId_userId_timeoutId: { + guildId: guild.id, + userId: user.id, + timeoutId: commandId, + }, + }, + }); + + logger.silly(deleteCooldown); + + logger.debug( + `Timeout document ${timeoutId} has been deleted from user ${userId}.` + ); + } + + // Create timeout + const createCooldown = await prisma.cooldown.upsert({ + where: { + guildId_userId_timeoutId: { + userId: user.id, + guildId: guild.id, + timeoutId: commandId, + }, + }, + update: {}, + create: { + guild: { + connectOrCreate: { + create: { + id: guild.id, + }, + where: { + id: guild.id, + }, + }, + }, + user: { + connectOrCreate: { + create: { + id: user.id, + }, + where: { + id: user.id, + }, + }, + }, + timeoutId: commandId, + cooldown, + }, + }); + + logger.silly(createCooldown); }; export const button = async (i: ButtonInteraction, cooldown: number) => { - // const { guild, user, customId } = i; + const { guild, user, customId } = i; - // // Check if user has a timeout - // const hasTimeout = await timeoutSchema.findOne({ - // guildId: guild?.id || "0", - // userId: user.id, - // cooldown: cooldown, - // timeoutId: customId, - // }); + if (!guild) throw new Error("Guild not found"); - // // If user is not on timeout - // if (hasTimeout) { - // const { guildId, userId, timeoutId, createdAt } = hasTimeout; - // const overDue = (await addSeconds(cooldown, createdAt)) < new Date(); + // Check if user has a timeout + const hasTimeout = await prisma.cooldown.findUnique({ + where: { + guildId_userId_timeoutId: { + guildId: guild.id, + userId: user.id, + timeoutId: customId, + }, + }, + }); - // if (!overDue) { - // const diff = Math.round( - // (new Date(hasTimeout.createdAt).getTime() - new Date().getTime()) / 1000 - // ); + logger.silly(hasTimeout); - // throw new Error( - // `You must wait ${diff} seconds before using this command.` - // ); - // } + // If user is not on timeout + if (hasTimeout) { + const { guildId, userId, timeoutId, createdAt } = hasTimeout; + const overDue = (await addSeconds(cooldown, createdAt)) < new Date(); - // // Delete timeout - // await timeoutSchema - // .deleteOne({ - // guildId, - // userId, - // timeoutId, - // cooldown, - // }) - // .then(async () => { - // logger.debug( - // `Timeout document ${timeoutId} has been deleted from user ${userId}.` - // ); - // }); - // } - // // Create timeout - // await timeoutSchema.create({ - // guildId: guild?.id || "0", - // userId: user.id, - // cooldown: cooldown, - // timeoutId: customId, - // }); - logger.warn("Button cooldown function is not working with Prisma yet!"); - return false; + if (!overDue) { + const diff = Math.round( + (new Date(hasTimeout.createdAt).getTime() - new Date().getTime()) / 1000 + ); + + throw new Error( + `You must wait ${diff} seconds before using this command.` + ); + } + + // Delete timeout + const deleteCooldown = await prisma.cooldown.delete({ + where: { + guildId_userId_timeoutId: { + guildId: guild.id, + userId: user.id, + timeoutId: customId, + }, + }, + }); + + logger.silly(deleteCooldown); + + logger.debug( + `Timeout document ${timeoutId} has been deleted from user ${userId}.` + ); + } + + // Create timeout + const createCooldown = await prisma.cooldown.upsert({ + where: { + guildId_userId_timeoutId: { + userId: user.id, + guildId: guild.id, + timeoutId: customId, + }, + }, + update: {}, + create: { + guild: { + connectOrCreate: { + create: { + id: guild.id, + }, + where: { + id: guild.id, + }, + }, + }, + user: { + connectOrCreate: { + create: { + id: user.id, + }, + where: { + id: user.id, + }, + }, + }, + timeoutId: customId, + cooldown, + }, + }); + + logger.silly(createCooldown); }; export const message = async (msg: Message, cooldown: number, id: string) => { - // const { guild, member } = msg; - // if (!guild) throw new Error("Guild is undefined"); - // if (!member) throw new Error("Member is undefined"); + const { guild, member } = msg; - // // Check if user has a timeout - // const hasTimeout = await timeoutSchema.findOne({ - // guildId: guild?.id || "0", - // userId: member.id, - // cooldown: cooldown, - // timeoutId: id, - // }); + if (!guild) throw new Error("Guild not found"); + if (!member) throw new Error("Member is undefined"); - // // If user is not on timeout - // if (hasTimeout) { - // const { guildId, userId, timeoutId, createdAt } = hasTimeout; - // const overDue = (await addSeconds(cooldown, createdAt)) < new Date(); + // Check if user has a timeout + const hasTimeout = await prisma.cooldown.findUnique({ + where: { + guildId_userId_timeoutId: { + guildId: guild.id, + userId: member.id, + timeoutId: id, + }, + }, + }); - // if (!overDue) { - // const diff = Math.round( - // (new Date(hasTimeout.createdAt).getTime() - new Date().getTime()) / 1000 - // ); + logger.silly(hasTimeout); - // return `User: ${userId} on timeout-id: ${id} with cooldown: ${cooldown} secs with remaining: ${diff} secs.`; - // } + // If user is not on timeout + if (hasTimeout) { + const { guildId, userId, timeoutId, createdAt } = hasTimeout; + const overDue = (await addSeconds(cooldown, createdAt)) < new Date(); - // // Delete timeout - // await timeoutSchema - // .deleteOne({ - // guildId, - // userId: member.id, - // timeoutId: id, - // cooldown, - // }) - // .then(async () => { - // logger.debug( - // `Timeout document ${timeoutId} has been deleted from user ${userId}.` - // ); - // }); - // } - // // Create timeout - // await timeoutSchema.create({ - // guildId: guild?.id || "0", - // userId: member.id, - // cooldown: cooldown, - // timeoutId: id, - // }); + if (!overDue) { + const diff = Math.round( + (new Date(hasTimeout.createdAt).getTime() - new Date().getTime()) / 1000 + ); - logger.warn("Message cooldown function is not working with Prisma yet!"); - return false; + return `User: ${userId} on timeout-id: ${id} with cooldown: ${cooldown} secs with remaining: ${diff} secs.`; + } + + // Delete timeout + const deleteCooldown = await prisma.cooldown.delete({ + where: { + guildId_userId_timeoutId: { + guildId: guild.id, + userId: member.id, + timeoutId: id, + }, + }, + }); + + logger.silly(deleteCooldown); + + logger.debug( + `Timeout document ${timeoutId} has been deleted from user ${userId}.` + ); + } + + // Create timeout + const createCooldown = await prisma.cooldown.upsert({ + where: { + guildId_userId_timeoutId: { + userId: member.id, + guildId: guild.id, + timeoutId: id, + }, + }, + update: {}, + create: { + guild: { + connectOrCreate: { + create: { + id: guild.id, + }, + where: { + id: guild.id, + }, + }, + }, + user: { + connectOrCreate: { + create: { + id: member.id, + }, + where: { + id: member.id, + }, + }, + }, + timeoutId: id, + cooldown, + }, + }); + + logger.silly(createCooldown); }; From 1039d8feb8d4f5ebd8e8b6100ddd5de24287aeb3 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 20:58:35 +0200 Subject: [PATCH 150/215] =?UTF-8?q?=F0=9F=A5=85=20Deny=20to=20bot=20and=20?= =?UTF-8?q?from=20and=20to=20same=20id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/helpers/transferCredits.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/helpers/transferCredits.ts b/src/helpers/transferCredits.ts index 4d648ba..58d96b0 100644 --- a/src/helpers/transferCredits.ts +++ b/src/helpers/transferCredits.ts @@ -54,10 +54,16 @@ export default async (guild: Guild, from: User, to: User, amount: number) => { // 5. Verify that the sender is not trying to send less that one credits. if (amount <= 0) { - throw new Error("You can't give negative amounts."); + throw new Error("You can't transfer below one credit."); } - // 6. Increment the recipient's balance by amount + // 6. Verify that recipient are not an bot. + if (to.bot) throw new Error("You can't transfer to an bot."); + + // 7. Verify that sender and recipient are not the same user. + if (from.id === to.id) throw new Error("You can't transfer to yourself."); + + // 8. Increment the recipient's balance by amount. const recipient = await tx.guildMember.upsert({ update: { creditsEarned: { From ce3369ba83cb47fca667f95ba141b5d24992ff56 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 20:59:12 +0200 Subject: [PATCH 151/215] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20getEmbedData=20now?= =?UTF-8?q?=20via=20Prisma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/helpers/getEmbedData/index.ts | 57 +++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 7 deletions(-) diff --git a/src/helpers/getEmbedData/index.ts b/src/helpers/getEmbedData/index.ts index bb54e80..7f244e3 100644 --- a/src/helpers/getEmbedData/index.ts +++ b/src/helpers/getEmbedData/index.ts @@ -1,4 +1,6 @@ -import { Guild } from "discord.js"; +import { ColorResolvable, Guild } from "discord.js"; +import logger from "../../middlewares/logger"; +import prisma from "../../prisma"; export default async (guild?: Guild | null) => { const { @@ -21,12 +23,53 @@ export default async (guild?: Guild | null) => { return defaultEmbedConfig; } - return defaultEmbedConfig; + const createGuildMember = await prisma.guildMember.upsert({ + where: { + userId_guildId: { + userId: guild?.ownerId, + guildId: guild.id, + }, + }, + update: {}, + create: { + user: { + connectOrCreate: { + create: { + id: guild.ownerId, + }, + where: { + id: guild.ownerId, + }, + }, + }, + guild: { + connectOrCreate: { + create: { + id: guild.id, + }, + where: { + id: guild.id, + }, + }, + }, + }, + include: { + user: true, + guild: true, + }, + }); - // const guildConfig = await guildSchema.findOne({ guildId: guild.id }); - // if (!guildConfig) { - // return defaultEmbedConfig; - // } + logger.silly(createGuildMember); - // return guildConfig.embeds; + if (!createGuildMember) { + return defaultEmbedConfig; + } + + return { + successColor: createGuildMember.guild.embedColorSuccess, + waitColor: createGuildMember.guild.embedColorWait, + errorColor: createGuildMember.guild.embedColorError, + footerText: createGuildMember.guild.embedFooterText, + footerIcon: createGuildMember.guild.embedFooterIcon, + }; }; From 7437fddd84c0a05a0a910095f12416a2867bcd61 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 20:59:39 +0200 Subject: [PATCH 152/215] =?UTF-8?q?=F0=9F=90=9B=20amount=200=20made=20not?= =?UTF-8?q?=20found?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/commands/credits/modules/gift/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/commands/credits/modules/gift/index.ts b/src/plugins/commands/credits/modules/gift/index.ts index b62aeff..64d12be 100644 --- a/src/plugins/commands/credits/modules/gift/index.ts +++ b/src/plugins/commands/credits/modules/gift/index.ts @@ -51,7 +51,7 @@ export default { if (!guild) throw new Error("Guild not found"); if (!optionUser) throw new Error("No receiver found"); - if (!optionAmount) throw new Error("Amount not found"); + if (optionAmount === null) throw new Error("Amount not found"); await transferCredits(guild, user, optionUser, optionAmount); From fcf98e5a4e467cbe856a347a8f64600aa1c2b32c Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 21:00:13 +0200 Subject: [PATCH 153/215] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20/config=20embeds?= =?UTF-8?q?=20now=20on=20Prisma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../embeds/components/getValues/index.ts | 55 +++++++---- .../commands/config/modules/embeds/index.ts | 95 ++++++++++--------- 2 files changed, 88 insertions(+), 62 deletions(-) diff --git a/src/plugins/commands/config/modules/embeds/components/getValues/index.ts b/src/plugins/commands/config/modules/embeds/components/getValues/index.ts index 068b82c..4ae15c0 100644 --- a/src/plugins/commands/config/modules/embeds/components/getValues/index.ts +++ b/src/plugins/commands/config/modules/embeds/components/getValues/index.ts @@ -1,6 +1,7 @@ import { ChatInputCommandInteraction, ColorResolvable } from "discord.js"; import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; -import guildSchema from "../../../../../../../models/guild"; +import logger from "../../../../../../../middlewares/logger"; +import prisma from "../../../../../../../prisma"; export default async (interaction: ChatInputCommandInteraction) => { const { options, guild } = interaction; @@ -10,26 +11,46 @@ export default async (interaction: ChatInputCommandInteraction) => { const embedConfig = await getEmbedConfig(guild); if (!embedConfig) throw new Error("Embed config not found"); - const newSuccessColor = options.getString("success-color") as ColorResolvable; - const newWaitColor = options.getString("wait-color") as ColorResolvable; - const newErrorColor = options.getString("error-color") as ColorResolvable; + const newSuccessColor = options.getString("success-color"); + const newWaitColor = options.getString("wait-color"); + const newErrorColor = options.getString("error-color"); const newFooterIcon = options.getString("footer-icon"); const newFooterText = options.getString("footer-text"); - const guildData = await guildSchema.findOne({ - guildId: guild.id, - }); - if (!guildData) throw new Error("Guild data not found"); - if (!guildData?.embeds) - throw new Error("Guild embed configuration not found"); - let { successColor, waitColor, errorColor, footerText, footerIcon } = - guildData.embeds; + if (!newSuccessColor) throw new Error("Success color not found"); + if (!newWaitColor) throw new Error("Wait color not found"); + if (!newErrorColor) throw new Error("Error color not found"); + if (!newFooterIcon) throw new Error("Footer icon not found"); + if (!newFooterText) throw new Error("Footer text not found"); - successColor = newSuccessColor || successColor; - waitColor = newWaitColor || waitColor; - errorColor = newErrorColor || errorColor; - footerIcon = newFooterIcon || footerIcon; - footerText = newFooterText || footerText; + const createGuild = await prisma.guild.upsert({ + where: { + id: guild.id, + }, + update: { + embedColorSuccess: newSuccessColor, + embedColorWait: newWaitColor, + embedColorError: newErrorColor, + embedFooterIcon: newFooterIcon, + embedFooterText: newFooterText, + }, + create: { + id: guild.id, + embedColorSuccess: newSuccessColor, + embedColorWait: newWaitColor, + embedColorError: newErrorColor, + embedFooterIcon: newFooterIcon, + embedFooterText: newFooterText, + }, + }); + + logger.silly(createGuild); + + const successColor = createGuild.embedColorSuccess; + const waitColor = createGuild.embedColorWait; + const errorColor = createGuild.embedColorError; + const footerText = createGuild.embedFooterText; + const footerIcon = createGuild.embedFooterIcon; return { successColor, waitColor, errorColor, footerText, footerIcon }; }; diff --git a/src/plugins/commands/config/modules/embeds/index.ts b/src/plugins/commands/config/modules/embeds/index.ts index 6835f0a..3ec6661 100644 --- a/src/plugins/commands/config/modules/embeds/index.ts +++ b/src/plugins/commands/config/modules/embeds/index.ts @@ -5,7 +5,6 @@ import { } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import guildSchema from "../../../../../models/guild"; import getValues from "./components/getValues"; export default { @@ -23,18 +22,31 @@ export default { option .setName("success-color") .setDescription("No provided description") + .setRequired(true) ) .addStringOption((option) => - option.setName("wait-color").setDescription("No provided description") + option + .setName("wait-color") + .setDescription("No provided description") + .setRequired(true) ) .addStringOption((option) => - option.setName("error-color").setDescription("No provided description") + option + .setName("error-color") + .setDescription("No provided description") + .setRequired(true) ) .addStringOption((option) => - option.setName("footer-icon").setDescription("No provided description") + option + .setName("footer-icon") + .setDescription("No provided description") + .setRequired(true) ) .addStringOption((option) => - option.setName("footer-text").setDescription("No provided description") + option + .setName("footer-text") + .setDescription("No provided description") + .setRequired(true) ); }, execute: async (interaction: ChatInputCommandInteraction) => { @@ -49,47 +61,40 @@ export default { .setFooter({ text: footerText, iconURL: footerIcon }) .setTimestamp(new Date()); - const guildData = await guildSchema.findOne({ - guildId: guild.id, - }); - if (!guildData) throw new Error("Guild data not found"); + embed + .setDescription("Following embed configuration will be used.") + .setColor(successColor) + .addFields([ + { + name: "🟢 Success Color", + value: `${successColor}`, + inline: true, + }, + { + name: "🟡 Wait Color", + value: `${waitColor}`, + inline: true, + }, + { + name: "🔴 Error Color", + value: `${errorColor}`, + inline: true, + }, + { + name: "🖼️ Footer Icon", + value: `${footerIcon}`, + inline: true, + }, + { + name: "📄 Footer Text", + value: `${footerText}`, + inline: true, + }, + ]); - await guildData.save().then(async () => { - embed - .setDescription("Following embed configuration will be used.") - .setColor(successColor) - .addFields([ - { - name: "🟢 Success Color", - value: `${successColor}`, - inline: true, - }, - { - name: "🟡 Wait Color", - value: `${waitColor}`, - inline: true, - }, - { - name: "🔴 Error Color", - value: `${errorColor}`, - inline: true, - }, - { - name: "🖼️ Footer Icon", - value: `${footerIcon}`, - inline: true, - }, - { - name: "📄 Footer Text", - value: `${footerText}`, - inline: true, - }, - ]); - - await interaction.editReply({ - embeds: [embed], - }); - return; + await interaction.editReply({ + embeds: [embed], }); + return; }, }; From ea2fc1e5857bd1da9bb8828a33855cd6d3323224 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 21:01:53 +0200 Subject: [PATCH 154/215] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20reputation=20now?= =?UTF-8?q?=20on=20Prisma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commands/reputation/modules/give/index.ts | 76 +++++++++++++------ 1 file changed, 52 insertions(+), 24 deletions(-) diff --git a/src/plugins/commands/reputation/modules/give/index.ts b/src/plugins/commands/reputation/modules/give/index.ts index 147be04..e134612 100644 --- a/src/plugins/commands/reputation/modules/give/index.ts +++ b/src/plugins/commands/reputation/modules/give/index.ts @@ -2,10 +2,11 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js"; import { command as CooldownCommand } from "../../../../../helpers/cooldown"; import getEmbedConfig from "../../../../../helpers/getEmbedData"; -import fetchUser from "../../../../../helpers/userData"; import logger from "../../../../../middlewares/logger"; import noSelfReputation from "./components/noSelfReputation"; +import prisma from "../../../../../prisma"; + export default { metadata: { guildOnly: true, ephemeral: true }, @@ -38,15 +39,13 @@ export default { const { successColor, footerText, footerIcon } = await getEmbedConfig( guild - ); // Destructure + ); const optionTarget = options?.getUser("target"); const optionType = options?.getString("type"); if (!guild) throw new Error("Guild is undefined"); - - const userObj = await fetchUser(user, guild); - if (!userObj) throw new Error("User is undefined"); + if (!optionTarget) throw new Error("Target is not defined"); // Pre-checks noSelfReputation(optionTarget, user); @@ -55,31 +54,60 @@ export default { await CooldownCommand(interaction, process.env.REPUTATION_TIMEOUT); switch (optionType) { - case "positive": - userObj.reputation += 1; + case "positive": { + const createUser = await prisma.user.upsert({ + where: { + id: optionTarget.id, + }, + update: { + reputationsEarned: { + increment: 1, + }, + }, + create: { + id: optionTarget.id, + reputationsEarned: 1, + }, + }); + + logger.silly(createUser); break; - case "negative": - userObj.reputation += 1; + } + case "negative": { + const createUser = await prisma.user.upsert({ + where: { + id: optionTarget.id, + }, + update: { + reputationsEarned: { + decrement: 1, + }, + }, + create: { + id: optionTarget.id, + reputationsEarned: -1, + }, + }); + + logger.silly(createUser); break; - default: + } + default: { throw new Error("Invalid reputation type"); + } } - await userObj.save().then(async () => { - logger.silly(`User reputation has been updated`); + const interactionEmbed = new EmbedBuilder() + .setTitle("[:loudspeaker:] Give") + .setDescription( + `You have given a ${optionType} repute to ${optionTarget}` + ) + .setTimestamp() + .setColor(successColor) + .setFooter({ text: footerText, iconURL: footerIcon }); - const interactionEmbed = new EmbedBuilder() - .setTitle("[:loudspeaker:] Give") - .setDescription( - `You have given a ${optionType} repute to ${optionTarget}` - ) - .setTimestamp() - .setColor(successColor) - .setFooter({ text: footerText, iconURL: footerIcon }); - - await interaction.editReply({ - embeds: [interactionEmbed], - }); + await interaction.editReply({ + embeds: [interactionEmbed], }); }, }; From 44cbecd3f15d276732f39fcc2bc37e135f928f32 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 21:02:06 +0200 Subject: [PATCH 155/215] =?UTF-8?q?=F0=9F=9A=A7=20Disable=20old=20Mongoose?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/managers/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/managers/index.ts b/src/managers/index.ts index 47d7eb7..330fde7 100644 --- a/src/managers/index.ts +++ b/src/managers/index.ts @@ -1,12 +1,11 @@ import { Client } from "discord.js"; import * as command from "./command"; -import * as database from "./database"; import * as event from "./event"; import * as schedule from "./schedule"; export const start = async (client: Client) => { - await database.connect(); + // await database.connect(); await schedule.start(client); await command.register(client); await event.register(client); From 1f18e423283d74810449fa4d0e7dc2802c0bffa6 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 21:02:48 +0200 Subject: [PATCH 156/215] =?UTF-8?q?=F0=9F=9A=B8=20Removed=20code=20block?= =?UTF-8?q?=20on=20errors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/events/interactionCreate/handlers/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/events/interactionCreate/handlers/index.ts b/src/plugins/events/interactionCreate/handlers/index.ts index 75e3189..e12e56a 100644 --- a/src/plugins/events/interactionCreate/handlers/index.ts +++ b/src/plugins/events/interactionCreate/handlers/index.ts @@ -29,7 +29,7 @@ export const handleCommandInteraction = async ( embeds: [ new EmbedBuilder() .setTitle(`[:x:] ${capitalizeFirstLetter(interaction.commandName)}`) - .setDescription(`${"``"}${err}${"``"}`) + .setDescription(`${err}`) .setColor(errorColor) .setTimestamp(new Date()) .setFooter({ text: footerText, iconURL: footerIcon }), From 7281a4e53b93c51f8296755f915698061de68891 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 21:03:26 +0200 Subject: [PATCH 157/215] =?UTF-8?q?=F0=9F=9A=A7=20Disable=20audits=20inter?= =?UTF-8?q?action=20migration=20to=20Prisma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/events/interactionCreate/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/plugins/events/interactionCreate/index.ts b/src/plugins/events/interactionCreate/index.ts index a1d1692..639feed 100644 --- a/src/plugins/events/interactionCreate/index.ts +++ b/src/plugins/events/interactionCreate/index.ts @@ -6,7 +6,6 @@ import { } from "discord.js"; import { IEventOptions } from "../../../interfaces/EventOptions"; import logger from "../../../middlewares/logger"; -import audits from "./audits"; // Dependencies import { handleCommandInteraction as HandlersHandleCommandInteraction } from "./handlers"; @@ -22,7 +21,7 @@ export const execute = async (interaction: BaseInteraction) => { `New interaction: ${id} in guild: ${guild?.name} (${guild?.id})` ); - await audits.execute(interaction); + // await audits.execute(interaction); switch (interaction.type) { case InteractionType.ApplicationCommand: From 9536478730f071168bb65fdff3ecfde56305da13 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 21:21:19 +0200 Subject: [PATCH 158/215] =?UTF-8?q?=F0=9F=8E=A8=20reorganized=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/{managers => handlers}/command/index.ts | 0 src/{helpers => handlers}/cooldown/index.ts | 2 +- src/{helpers => handlers}/deferReply/index.ts | 2 +- .../deployCommands/index.ts | 0 src/{helpers => handlers}/devMode/index.ts | 0 src/{managers => handlers}/event/index.ts | 0 src/{managers => handlers}/schedule/index.ts | 6 +-- .../updatePresence/index.ts | 0 src/helpers/embedBuilder/index.ts | 8 ---- src/helpers/getDiscordCommandJSON/index.ts | 43 ------------------- src/helpers/getEmbedData/index.ts | 2 +- src/helpers/getPluginCommandBuilder/index.ts | 11 ----- src/helpers/getPluginCommandOptions/index.ts | 10 ----- src/helpers/getPluginCommands/index.ts | 24 ----------- src/helpers/getPluginMetadata/index.ts | 8 ---- src/helpers/getPluginStructure/index.ts | 34 --------------- src/helpers/getPlugins/index.ts | 10 ----- src/helpers/registerDiscordCommands/index.ts | 22 ---------- .../index.ts} | 2 +- src/index.ts | 9 ++-- src/managers/database/index.ts | 22 ---------- src/managers/index.ts | 12 ------ .../embeds/components/getValues/index.ts | 2 +- .../commands/counters/modules/view/index.ts | 2 +- .../commands/credits/modules/balance/index.ts | 2 +- .../commands/credits/modules/top/index.ts | 2 +- .../commands/credits/modules/work/index.ts | 4 +- .../modules/counters/modules/add/index.ts | 2 +- .../modules/counters/modules/remove/index.ts | 2 +- .../modules/credits/modules/give/index.ts | 2 +- .../modules/credits/modules/set/index.ts | 2 +- .../modules/credits/modules/take/index.ts | 2 +- .../commands/reputation/modules/give/index.ts | 4 +- src/plugins/events/guildCreate/index.ts | 4 +- src/plugins/events/guildDelete/index.ts | 4 +- src/plugins/events/guildMemberAdd/index.ts | 4 +- src/plugins/events/guildMemberRemove/index.ts | 4 +- .../handlers/button/index.ts | 4 +- .../handlers/command/index.ts | 4 +- .../messageCreate/modules/counters/index.ts | 2 +- .../messageCreate/modules/credits/index.ts | 4 +- .../messageCreate/modules/points/index.ts | 4 +- .../events/messageDelete/modules/counter.ts | 2 +- .../events/messageUpdate/modules/counter.ts | 2 +- src/plugins/events/ready/index.ts | 6 +-- src/prisma.ts | 3 -- src/{jobs => schedules}/shop/index.ts | 0 .../modules/roles/components/dueForPayment.ts | 0 .../roles/components/overDueForPayment.ts | 0 .../shop/modules/roles/index.ts | 0 src/{jobs => schedules}/timeouts/index.ts | 0 51 files changed, 48 insertions(+), 252 deletions(-) rename src/{managers => handlers}/command/index.ts (100%) rename src/{helpers => handlers}/cooldown/index.ts (99%) rename src/{helpers => handlers}/deferReply/index.ts (92%) rename src/{helpers => handlers}/deployCommands/index.ts (100%) rename src/{helpers => handlers}/devMode/index.ts (100%) rename src/{managers => handlers}/event/index.ts (100%) rename src/{managers => handlers}/schedule/index.ts (75%) rename src/{helpers => handlers}/updatePresence/index.ts (100%) delete mode 100644 src/helpers/embedBuilder/index.ts delete mode 100644 src/helpers/getDiscordCommandJSON/index.ts delete mode 100644 src/helpers/getPluginCommandBuilder/index.ts delete mode 100644 src/helpers/getPluginCommandOptions/index.ts delete mode 100644 src/helpers/getPluginCommands/index.ts delete mode 100644 src/helpers/getPluginMetadata/index.ts delete mode 100644 src/helpers/getPluginStructure/index.ts delete mode 100644 src/helpers/getPlugins/index.ts delete mode 100644 src/helpers/registerDiscordCommands/index.ts rename src/helpers/{transferCredits.ts => transferCredits/index.ts} (98%) delete mode 100644 src/managers/database/index.ts delete mode 100644 src/managers/index.ts delete mode 100644 src/prisma.ts rename src/{jobs => schedules}/shop/index.ts (100%) rename src/{jobs => schedules}/shop/modules/roles/components/dueForPayment.ts (100%) rename src/{jobs => schedules}/shop/modules/roles/components/overDueForPayment.ts (100%) rename src/{jobs => schedules}/shop/modules/roles/index.ts (100%) rename src/{jobs => schedules}/timeouts/index.ts (100%) diff --git a/src/managers/command/index.ts b/src/handlers/command/index.ts similarity index 100% rename from src/managers/command/index.ts rename to src/handlers/command/index.ts diff --git a/src/helpers/cooldown/index.ts b/src/handlers/cooldown/index.ts similarity index 99% rename from src/helpers/cooldown/index.ts rename to src/handlers/cooldown/index.ts index 3847060..c2753b1 100644 --- a/src/helpers/cooldown/index.ts +++ b/src/handlers/cooldown/index.ts @@ -2,7 +2,7 @@ import { ButtonInteraction, CommandInteraction, Message } from "discord.js"; import addSeconds from "../../helpers/addSeconds"; import logger from "../../middlewares/logger"; -import prisma from "../../prisma"; +import prisma from "../database"; export const command = async (i: CommandInteraction, cooldown: number) => { const { guild, user, commandId } = i; diff --git a/src/helpers/deferReply/index.ts b/src/handlers/deferReply/index.ts similarity index 92% rename from src/helpers/deferReply/index.ts rename to src/handlers/deferReply/index.ts index ae9e16b..e795799 100644 --- a/src/helpers/deferReply/index.ts +++ b/src/handlers/deferReply/index.ts @@ -1,5 +1,5 @@ import { BaseInteraction, EmbedBuilder } from "discord.js"; -import getEmbedConfig from "../getEmbedData"; +import getEmbedConfig from "../../helpers/getEmbedData"; export default async (interaction: BaseInteraction, ephemeral: boolean) => { if (!interaction.isRepliable()) diff --git a/src/helpers/deployCommands/index.ts b/src/handlers/deployCommands/index.ts similarity index 100% rename from src/helpers/deployCommands/index.ts rename to src/handlers/deployCommands/index.ts diff --git a/src/helpers/devMode/index.ts b/src/handlers/devMode/index.ts similarity index 100% rename from src/helpers/devMode/index.ts rename to src/handlers/devMode/index.ts diff --git a/src/managers/event/index.ts b/src/handlers/event/index.ts similarity index 100% rename from src/managers/event/index.ts rename to src/handlers/event/index.ts diff --git a/src/managers/schedule/index.ts b/src/handlers/schedule/index.ts similarity index 75% rename from src/managers/schedule/index.ts rename to src/handlers/schedule/index.ts index ab8e51f..b3b3e2f 100644 --- a/src/managers/schedule/index.ts +++ b/src/handlers/schedule/index.ts @@ -1,18 +1,18 @@ import { Client } from "discord.js"; import schedule from "node-schedule"; -import listDir from "../../helpers/checkDirectory"; +import checkDirectory from "../../helpers/checkDirectory"; import { IJob } from "../../interfaces/Job"; import logger from "../../middlewares/logger"; export const start = async (client: Client) => { logger.info("⏰ Started job management"); - const jobNames = await listDir("jobs"); + const jobNames = await checkDirectory("schedules"); if (!jobNames) return logger.warn("No available jobs found"); await Promise.all( jobNames.map(async (jobName) => { - const job: IJob = await import(`../../jobs/${jobName}`); + const job: IJob = await import(`../../schedules/${jobName}`); schedule.scheduleJob(job.options.schedule, async () => { logger.verbose(`⏰ Performed the job "${jobName}"`); diff --git a/src/helpers/updatePresence/index.ts b/src/handlers/updatePresence/index.ts similarity index 100% rename from src/helpers/updatePresence/index.ts rename to src/handlers/updatePresence/index.ts diff --git a/src/helpers/embedBuilder/index.ts b/src/helpers/embedBuilder/index.ts deleted file mode 100644 index ef36024..0000000 --- a/src/helpers/embedBuilder/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { EmbedBuilder } from "discord.js"; - -export default new EmbedBuilder() - .setFooter({ - text: process.env.EMBED_FOOTER_TEXT, - iconURL: process.env.EMBED_FOOTER_ICON, - }) - .setTimestamp(new Date()); diff --git a/src/helpers/getDiscordCommandJSON/index.ts b/src/helpers/getDiscordCommandJSON/index.ts deleted file mode 100644 index f69deab..0000000 --- a/src/helpers/getDiscordCommandJSON/index.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* eslint-disable no-loops/no-loops */ - -import { SlashCommandBuilder } from "discord.js"; -import logger from "../../middlewares/logger"; -import getPluginCommands from "../getPluginCommands"; -import getPlugins from "../getPlugins"; - -export default async () => { - logger.debug("Processing complete builder for plugins"); - const plugins = await getPlugins("plugins"); - const pluginBuilders = []; - - for await (const plugin of plugins) { - logger.debug(`Processing builder for plugin: ${plugin}`); - - const commands = await getPluginCommands(plugin); - - const builderStructure = new SlashCommandBuilder() - .setName(plugin) - .setDescription("Get info about a user or a server!"); - - for await (const command of commands) { - logger.debug(`Processing builder of command: ${command.name}`); - if (command?.options?.group) { - logger.debug(`Processing subcommand group: ${command.builder.name}`); - builderStructure.addSubcommandGroup(command.builder); - logger.verbose(`Processed subcommand group: ${command.builder.name}!`); - } else { - logger.debug(`Processing subcommand: ${command.builder.name}`); - builderStructure.addSubcommand(command.builder); - logger.verbose(`Processed subcommand: ${command.builder.name}!`); - } - logger.verbose(`Processed builder of command: ${command.name}!`); - } - - pluginBuilders.push(builderStructure); - - logger.verbose(`Processed builder for plugin: ${plugin}!`); - } - - logger.verbose("Processed complete builder for plugins!"); - return pluginBuilders; -}; diff --git a/src/helpers/getEmbedData/index.ts b/src/helpers/getEmbedData/index.ts index 7f244e3..069ce9b 100644 --- a/src/helpers/getEmbedData/index.ts +++ b/src/helpers/getEmbedData/index.ts @@ -1,6 +1,6 @@ import { ColorResolvable, Guild } from "discord.js"; +import prisma from "../../handlers/database"; import logger from "../../middlewares/logger"; -import prisma from "../../prisma"; export default async (guild?: Guild | null) => { const { diff --git a/src/helpers/getPluginCommandBuilder/index.ts b/src/helpers/getPluginCommandBuilder/index.ts deleted file mode 100644 index c7036a4..0000000 --- a/src/helpers/getPluginCommandBuilder/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -import logger from "../../middlewares/logger"; - -export default async (plugin: string, command: string) => { - logger.debug(`Processing builder for command: ${command}`); - const { builder } = await import( - `../../plugins/${plugin}/commands/${command}` - ); - logger.verbose(`Processed builder for command: ${command}!`); - - return builder; -}; diff --git a/src/helpers/getPluginCommandOptions/index.ts b/src/helpers/getPluginCommandOptions/index.ts deleted file mode 100644 index e9e6a1d..0000000 --- a/src/helpers/getPluginCommandOptions/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -import logger from "../../middlewares/logger"; - -export default async (plugin: string, command: string) => { - logger.debug(`Processing options for command: ${command}`); - const { options } = - (await import(`../../plugins/${plugin}/commands/${command}`)) || []; - logger.verbose(`Processed options for command: ${command}!`); - - return options; -}; diff --git a/src/helpers/getPluginCommands/index.ts b/src/helpers/getPluginCommands/index.ts deleted file mode 100644 index 33547c0..0000000 --- a/src/helpers/getPluginCommands/index.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* eslint-disable no-loops/no-loops */ -import logger from "../../middlewares/logger"; -import listDir from "../checkDirectory"; -import getPluginCommandBuilder from "../getPluginCommandBuilder"; -import getPluginCommandOptions from "../getPluginCommandOptions"; - -export default async (plugin: string) => { - logger.debug(`Processing commands for plugin: ${plugin}`); - const commands = (await listDir(`plugins/${plugin}/commands`)) || []; - const commandStructure = []; - - for await (const command of commands) { - logger.debug(`Processing command: ${command}`); - - const builder = await getPluginCommandBuilder(plugin, command); - const options = await getPluginCommandOptions(plugin, command); - - commandStructure.push({ name: command, builder, options }); - logger.verbose(`Processed command: ${command}!`); - } - - logger.verbose(`Processed commands for plugin: ${plugin}!`); - return commandStructure; -}; diff --git a/src/helpers/getPluginMetadata/index.ts b/src/helpers/getPluginMetadata/index.ts deleted file mode 100644 index 36a1eaf..0000000 --- a/src/helpers/getPluginMetadata/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -import logger from "../../middlewares/logger"; - -export default async (plugin: string) => { - logger.debug(`Processing metadata for plugin: ${plugin}`); - const metadata = await import(`../../plugins/${plugin}/metadata`); - logger.verbose(`Processed metadata for plugin: ${plugin}!`); - return metadata.default; -}; diff --git a/src/helpers/getPluginStructure/index.ts b/src/helpers/getPluginStructure/index.ts deleted file mode 100644 index 6642bb8..0000000 --- a/src/helpers/getPluginStructure/index.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* eslint-disable no-loops/no-loops */ - -import { Client } from "discord.js"; -import logger from "../../middlewares/logger"; -import getPluginCommands from "../getPluginCommands"; -import getPluginMetadata from "../getPluginMetadata"; -import getPlugins from "../getPlugins"; - -export default async (client: Client, dir: string) => { - const plugins = await getPlugins(dir); - const pluginStructure = []; - - logger.debug("Processing structure of plugins..."); - - for await (const plugin of plugins) { - logger.debug(`Processing structure of plugin: ${plugin}`); - const commands = await getPluginCommands(plugin); - const metadata = await getPluginMetadata(plugin); - - pluginStructure.push({ - plugin, - commands, - metadata, - }); - - client.commands.set(plugin, commands); - - logger.verbose(`Processed structure of plugin: ${plugin}!`); - } - - logger.verbose("Processed structure of plugins!"); - - return pluginStructure; -}; diff --git a/src/helpers/getPlugins/index.ts b/src/helpers/getPlugins/index.ts deleted file mode 100644 index 4146a4f..0000000 --- a/src/helpers/getPlugins/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -import logger from "../../middlewares/logger"; -import listDir from "../checkDirectory"; - -export default async (dir: string) => { - logger.debug("Processing list of plugins..."); - const plugins = await listDir(dir); - logger.verbose("Processed list of plugins!"); - - return plugins || []; -}; diff --git a/src/helpers/registerDiscordCommands/index.ts b/src/helpers/registerDiscordCommands/index.ts deleted file mode 100644 index d258687..0000000 --- a/src/helpers/registerDiscordCommands/index.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { REST } from "@discordjs/rest"; -import { Routes, SlashCommandBuilder } from "discord.js"; -import logger from "../../middlewares/logger"; - -export default async (builder: SlashCommandBuilder) => { - const rest = new REST({ version: "10" }).setToken(process.env.DISCORD_TOKEN); - - await rest.put( - Routes.applicationGuildCommands( - process.env.DISCORD_CLIENT_ID, - process.env.DISCORD_GUILD_ID - ), - { body: builder } - ); - - await rest - .put(Routes.applicationCommands(process.env.DISCORD_CLIENT_ID as string), { - body: builder, - }) - .then(() => logger.info("Successfully deployed to Discord")) - .catch(() => logger.error("Failed to deployed to Discord")); -}; diff --git a/src/helpers/transferCredits.ts b/src/helpers/transferCredits/index.ts similarity index 98% rename from src/helpers/transferCredits.ts rename to src/helpers/transferCredits/index.ts index 58d96b0..f349b4b 100644 --- a/src/helpers/transferCredits.ts +++ b/src/helpers/transferCredits/index.ts @@ -1,5 +1,5 @@ import { Guild, User } from "discord.js"; -import prisma from "../prisma"; +import prisma from "../../handlers/database"; export default async (guild: Guild, from: User, to: User, amount: number) => { return await prisma.$transaction(async (tx) => { diff --git a/src/index.ts b/src/index.ts index 6e58d4d..b65b076 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,8 @@ import { Client, Collection, GatewayIntentBits } from "discord.js"; // discord.js import "dotenv/config"; -import * as managers from "./managers"; - +import * as command from "./handlers/command"; +import * as event from "./handlers/event"; +import * as schedule from "./handlers/schedule"; // Main process that starts all other sub processes const main = async () => { @@ -18,7 +19,9 @@ const main = async () => { // Create command collection client.commands = new Collection(); - await managers.start(client); + await schedule.start(client); + await event.register(client); + await command.register(client); // Authorize with Discord's API await client.login(process.env.DISCORD_TOKEN); diff --git a/src/managers/database/index.ts b/src/managers/database/index.ts deleted file mode 100644 index 930f449..0000000 --- a/src/managers/database/index.ts +++ /dev/null @@ -1,22 +0,0 @@ -import mongoose from "mongoose"; -import logger from "../../middlewares/logger"; - -// Function to connect to MongoDB server -export const connect = async () => { - await mongoose - .connect(process.env.MONGO_URL) - .then((connection) => { - logger.info(`💾 Connected to database: ${connection.connection.name}`); - }) - .catch(() => { - throw new Error("Error connecting to database."); - }); - - mongoose.connection.on("error", () => { - throw new Error("Failed to connect to database."); - }); - - mongoose.connection.on("warn", (warning) => { - logger.warn(`💾 ${warning}`); - }); -}; diff --git a/src/managers/index.ts b/src/managers/index.ts deleted file mode 100644 index 330fde7..0000000 --- a/src/managers/index.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Client } from "discord.js"; - -import * as command from "./command"; -import * as event from "./event"; -import * as schedule from "./schedule"; - -export const start = async (client: Client) => { - // await database.connect(); - await schedule.start(client); - await command.register(client); - await event.register(client); -}; diff --git a/src/plugins/commands/config/modules/embeds/components/getValues/index.ts b/src/plugins/commands/config/modules/embeds/components/getValues/index.ts index 4ae15c0..f772cbc 100644 --- a/src/plugins/commands/config/modules/embeds/components/getValues/index.ts +++ b/src/plugins/commands/config/modules/embeds/components/getValues/index.ts @@ -1,7 +1,7 @@ import { ChatInputCommandInteraction, ColorResolvable } from "discord.js"; +import prisma from "../../../../../../../handlers/database"; import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; import logger from "../../../../../../../middlewares/logger"; -import prisma from "../../../../../../../prisma"; export default async (interaction: ChatInputCommandInteraction) => { const { options, guild } = interaction; diff --git a/src/plugins/commands/counters/modules/view/index.ts b/src/plugins/commands/counters/modules/view/index.ts index cc72c32..858658e 100644 --- a/src/plugins/commands/counters/modules/view/index.ts +++ b/src/plugins/commands/counters/modules/view/index.ts @@ -1,8 +1,8 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChannelType } from "discord-api-types/v10"; import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js"; +import prisma from "../../../../../handlers/database"; import getEmbedConfig from "../../../../../helpers/getEmbedData"; -import prisma from "../../../../../prisma"; export default { metadata: { guildOnly: true, ephemeral: false }, diff --git a/src/plugins/commands/credits/modules/balance/index.ts b/src/plugins/commands/credits/modules/balance/index.ts index 153e73b..da8f1d3 100644 --- a/src/plugins/commands/credits/modules/balance/index.ts +++ b/src/plugins/commands/credits/modules/balance/index.ts @@ -1,8 +1,8 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { CommandInteraction, EmbedBuilder } from "discord.js"; +import prisma from "../../../../../handlers/database"; import getEmbedConfig from "../../../../../helpers/getEmbedData"; import logger from "../../../../../middlewares/logger"; -import prisma from "../../../../../prisma"; export default { metadata: { guildOnly: true, ephemeral: true }, diff --git a/src/plugins/commands/credits/modules/top/index.ts b/src/plugins/commands/credits/modules/top/index.ts index 98dc814..c045d95 100644 --- a/src/plugins/commands/credits/modules/top/index.ts +++ b/src/plugins/commands/credits/modules/top/index.ts @@ -1,9 +1,9 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { GuildMember } from "@prisma/client"; import { CommandInteraction, EmbedBuilder } from "discord.js"; +import prisma from "../../../../../handlers/database"; import getEmbedConfig from "../../../../../helpers/getEmbedData"; import logger from "../../../../../middlewares/logger"; -import prisma from "../../../../../prisma"; export default { metadata: { guildOnly: true, ephemeral: false }, diff --git a/src/plugins/commands/credits/modules/work/index.ts b/src/plugins/commands/credits/modules/work/index.ts index 716eb47..8b88d81 100644 --- a/src/plugins/commands/credits/modules/work/index.ts +++ b/src/plugins/commands/credits/modules/work/index.ts @@ -3,13 +3,13 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import Chance from "chance"; import { CommandInteraction, EmbedBuilder } from "discord.js"; // Models -import * as cooldown from "../../../../../helpers/cooldown"; +import * as cooldown from "../../../../../handlers/cooldown"; // Configurations import getEmbedConfig from "../../../../../helpers/getEmbedData"; // Helpers // Handlers +import prisma from "../../../../../handlers/database"; import logger from "../../../../../middlewares/logger"; -import prisma from "../../../../../prisma"; export default { metadata: { guildOnly: true, ephemeral: true }, diff --git a/src/plugins/commands/manage/modules/counters/modules/add/index.ts b/src/plugins/commands/manage/modules/counters/modules/add/index.ts index 7ddbc3d..38f6f51 100644 --- a/src/plugins/commands/manage/modules/counters/modules/add/index.ts +++ b/src/plugins/commands/manage/modules/counters/modules/add/index.ts @@ -7,9 +7,9 @@ import { PermissionsBitField, } from "discord.js"; // Configurations +import prisma from "../../../../../../../handlers/database"; import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; import logger from "../../../../../../../middlewares/logger"; -import prisma from "../../../../../../../prisma"; // Function export default { diff --git a/src/plugins/commands/manage/modules/counters/modules/remove/index.ts b/src/plugins/commands/manage/modules/counters/modules/remove/index.ts index 693541c..7b35ec4 100644 --- a/src/plugins/commands/manage/modules/counters/modules/remove/index.ts +++ b/src/plugins/commands/manage/modules/counters/modules/remove/index.ts @@ -8,8 +8,8 @@ import { PermissionsBitField, } from "discord.js"; // Configurations +import prisma from "../../../../../../../handlers/database"; import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; -import prisma from "../../../../../../../prisma"; // Function export default { diff --git a/src/plugins/commands/manage/modules/credits/modules/give/index.ts b/src/plugins/commands/manage/modules/credits/modules/give/index.ts index 4ed822c..aaf018a 100644 --- a/src/plugins/commands/manage/modules/credits/modules/give/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/give/index.ts @@ -12,7 +12,7 @@ import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; import pluralize from "../../../../../../../helpers/pluralize"; // Models // Handlers -import prisma from "../../../../../../../prisma"; +import prisma from "../../../../../../../handlers/database"; // Function export default { metadata: { diff --git a/src/plugins/commands/manage/modules/credits/modules/set/index.ts b/src/plugins/commands/manage/modules/credits/modules/set/index.ts index 562ca32..794d7ca 100644 --- a/src/plugins/commands/manage/modules/credits/modules/set/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/set/index.ts @@ -10,8 +10,8 @@ import { // Configurations import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; // Handlers +import prisma from "../../../../../../../handlers/database"; import logger from "../../../../../../../middlewares/logger"; -import prisma from "../../../../../../../prisma"; // Function export default { diff --git a/src/plugins/commands/manage/modules/credits/modules/take/index.ts b/src/plugins/commands/manage/modules/credits/modules/take/index.ts index 1c5f256..42516af 100644 --- a/src/plugins/commands/manage/modules/credits/modules/take/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/take/index.ts @@ -11,8 +11,8 @@ import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; // Helpers../../../../../../../helpers/userData import pluralize from "../../../../../../../helpers/pluralize"; // Handlers +import prisma from "../../../../../../../handlers/database"; import logger from "../../../../../../../middlewares/logger"; -import prisma from "../../../../../../../prisma"; // Function export default { diff --git a/src/plugins/commands/reputation/modules/give/index.ts b/src/plugins/commands/reputation/modules/give/index.ts index e134612..33c550a 100644 --- a/src/plugins/commands/reputation/modules/give/index.ts +++ b/src/plugins/commands/reputation/modules/give/index.ts @@ -1,11 +1,11 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js"; -import { command as CooldownCommand } from "../../../../../helpers/cooldown"; +import { command as CooldownCommand } from "../../../../../handlers/cooldown"; import getEmbedConfig from "../../../../../helpers/getEmbedData"; import logger from "../../../../../middlewares/logger"; import noSelfReputation from "./components/noSelfReputation"; -import prisma from "../../../../../prisma"; +import prisma from "../../../../../handlers/database"; export default { metadata: { guildOnly: true, ephemeral: true }, diff --git a/src/plugins/events/guildCreate/index.ts b/src/plugins/events/guildCreate/index.ts index 37ec652..72eb3c7 100644 --- a/src/plugins/events/guildCreate/index.ts +++ b/src/plugins/events/guildCreate/index.ts @@ -1,8 +1,8 @@ import { Guild } from "discord.js"; -import updatePresence from "../../../helpers/updatePresence"; +import prisma from "../../../handlers/database"; +import updatePresence from "../../../handlers/updatePresence"; import { IEventOptions } from "../../../interfaces/EventOptions"; import logger from "../../../middlewares/logger"; -import prisma from "../../../prisma"; export const options: IEventOptions = { type: "on", diff --git a/src/plugins/events/guildDelete/index.ts b/src/plugins/events/guildDelete/index.ts index fc3817a..99dff25 100644 --- a/src/plugins/events/guildDelete/index.ts +++ b/src/plugins/events/guildDelete/index.ts @@ -1,9 +1,9 @@ // 3rd party dependencies import { Guild } from "discord.js"; -import updatePresence from "../../../helpers/updatePresence"; +import prisma from "../../../handlers/database"; +import updatePresence from "../../../handlers/updatePresence"; import { IEventOptions } from "../../../interfaces/EventOptions"; import logger from "../../../middlewares/logger"; -import prisma from "../../../prisma"; export const options: IEventOptions = { type: "on", diff --git a/src/plugins/events/guildMemberAdd/index.ts b/src/plugins/events/guildMemberAdd/index.ts index d1f554e..27a6192 100644 --- a/src/plugins/events/guildMemberAdd/index.ts +++ b/src/plugins/events/guildMemberAdd/index.ts @@ -1,9 +1,9 @@ // 3rd party dependencies import { GuildMember } from "discord.js"; -import updatePresence from "../../../helpers/updatePresence"; +import prisma from "../../../handlers/database"; +import updatePresence from "../../../handlers/updatePresence"; import { IEventOptions } from "../../../interfaces/EventOptions"; import logger from "../../../middlewares/logger"; -import prisma from "../../../prisma"; import audits from "./audits"; import joinMessage from "./joinMessage"; diff --git a/src/plugins/events/guildMemberRemove/index.ts b/src/plugins/events/guildMemberRemove/index.ts index 7248324..d1a662f 100644 --- a/src/plugins/events/guildMemberRemove/index.ts +++ b/src/plugins/events/guildMemberRemove/index.ts @@ -1,9 +1,9 @@ // 3rd party dependencies import { GuildMember } from "discord.js"; -import updatePresence from "../../../helpers/updatePresence"; +import prisma from "../../../handlers/database"; +import updatePresence from "../../../handlers/updatePresence"; import { IEventOptions } from "../../../interfaces/EventOptions"; import logger from "../../../middlewares/logger"; -import prisma from "../../../prisma"; import audits from "./audits"; import leaveMessage from "./leaveMessage"; diff --git a/src/plugins/events/interactionCreate/handlers/button/index.ts b/src/plugins/events/interactionCreate/handlers/button/index.ts index 8fac9dd..9f5b5b1 100644 --- a/src/plugins/events/interactionCreate/handlers/button/index.ts +++ b/src/plugins/events/interactionCreate/handlers/button/index.ts @@ -1,7 +1,7 @@ // Dependencies import { BaseInteraction } from "discord.js"; -import { button as CooldownButton } from "../../../../../helpers/cooldown"; -import deferReply from "../../../../../helpers/deferReply"; +import { button as CooldownButton } from "../../../../../handlers/cooldown"; +import deferReply from "../../../../../handlers/deferReply"; export default async (interaction: BaseInteraction) => { if (!interaction.isButton()) return; diff --git a/src/plugins/events/interactionCreate/handlers/command/index.ts b/src/plugins/events/interactionCreate/handlers/command/index.ts index 4e9cc59..9f5169c 100644 --- a/src/plugins/events/interactionCreate/handlers/command/index.ts +++ b/src/plugins/events/interactionCreate/handlers/command/index.ts @@ -1,7 +1,7 @@ // Dependencies import { ChatInputCommandInteraction } from "discord.js"; -import { command as CooldownCommand } from "../../../../../helpers/cooldown"; -import deferReply from "../../../../../helpers/deferReply"; +import { command as CooldownCommand } from "../../../../../handlers/cooldown"; +import deferReply from "../../../../../handlers/deferReply"; import getCommandMetadata from "../../../../../helpers/getCommandMetadata"; export default async (interaction: ChatInputCommandInteraction) => { diff --git a/src/plugins/events/messageCreate/modules/counters/index.ts b/src/plugins/events/messageCreate/modules/counters/index.ts index 16c648e..98decfe 100644 --- a/src/plugins/events/messageCreate/modules/counters/index.ts +++ b/src/plugins/events/messageCreate/modules/counters/index.ts @@ -1,6 +1,6 @@ import { ChannelType, Message } from "discord.js"; +import prisma from "../../../../../handlers/database"; import logger from "../../../../../middlewares/logger"; -import prisma from "../../../../../prisma"; export default { execute: async (message: Message) => { diff --git a/src/plugins/events/messageCreate/modules/credits/index.ts b/src/plugins/events/messageCreate/modules/credits/index.ts index f342237..7037438 100644 --- a/src/plugins/events/messageCreate/modules/credits/index.ts +++ b/src/plugins/events/messageCreate/modules/credits/index.ts @@ -1,7 +1,7 @@ import { ChannelType, Message } from "discord.js"; -import { message as CooldownMessage } from "../../../../../helpers/cooldown"; +import { message as CooldownMessage } from "../../../../../handlers/cooldown"; +import prisma from "../../../../../handlers/database"; import logger from "../../../../../middlewares/logger"; -import prisma from "../../../../../prisma"; export default { execute: async (message: Message) => { diff --git a/src/plugins/events/messageCreate/modules/points/index.ts b/src/plugins/events/messageCreate/modules/points/index.ts index 6fca49d..dde559e 100644 --- a/src/plugins/events/messageCreate/modules/points/index.ts +++ b/src/plugins/events/messageCreate/modules/points/index.ts @@ -1,7 +1,7 @@ import { ChannelType, Message } from "discord.js"; -import { message as CooldownMessage } from "../../../../../helpers/cooldown"; +import { message as CooldownMessage } from "../../../../../handlers/cooldown"; +import prisma from "../../../../../handlers/database"; import logger from "../../../../../middlewares/logger"; -import prisma from "../../../../../prisma"; export default { execute: async (message: Message) => { diff --git a/src/plugins/events/messageDelete/modules/counter.ts b/src/plugins/events/messageDelete/modules/counter.ts index 9689be6..ac12127 100644 --- a/src/plugins/events/messageDelete/modules/counter.ts +++ b/src/plugins/events/messageDelete/modules/counter.ts @@ -1,8 +1,8 @@ // Dependencies import { Message } from "discord.js"; // Models +import prisma from "../../../../handlers/database"; import logger from "../../../../middlewares/logger"; -import prisma from "../../../../prisma"; export default async (message: Message) => { const { guild, channel, author, content } = message; diff --git a/src/plugins/events/messageUpdate/modules/counter.ts b/src/plugins/events/messageUpdate/modules/counter.ts index 0e34dde..f630024 100644 --- a/src/plugins/events/messageUpdate/modules/counter.ts +++ b/src/plugins/events/messageUpdate/modules/counter.ts @@ -1,8 +1,8 @@ // Dependencies import { Message } from "discord.js"; // Models +import prisma from "../../../../handlers/database"; import logger from "../../../../middlewares/logger"; -import prisma from "../../../../prisma"; export default async (message: Message) => { const { guild, channel, author, content } = message; diff --git a/src/plugins/events/ready/index.ts b/src/plugins/events/ready/index.ts index e45fd39..cf043c1 100644 --- a/src/plugins/events/ready/index.ts +++ b/src/plugins/events/ready/index.ts @@ -1,9 +1,9 @@ // Dependencies import { Client } from "discord.js"; // Helpers -import deployCommands from "../../../helpers/deployCommands"; -import devMode from "../../../helpers/devMode"; -import updatePresence from "../../../helpers/updatePresence"; +import deployCommands from "../../../handlers/deployCommands"; +import devMode from "../../../handlers/devMode"; +import updatePresence from "../../../handlers/updatePresence"; import { IEventOptions } from "../../../interfaces/EventOptions"; import logger from "../../../middlewares/logger"; diff --git a/src/prisma.ts b/src/prisma.ts deleted file mode 100644 index 2c3e98f..0000000 --- a/src/prisma.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { PrismaClient } from "@prisma/client"; - -export default new PrismaClient(); diff --git a/src/jobs/shop/index.ts b/src/schedules/shop/index.ts similarity index 100% rename from src/jobs/shop/index.ts rename to src/schedules/shop/index.ts diff --git a/src/jobs/shop/modules/roles/components/dueForPayment.ts b/src/schedules/shop/modules/roles/components/dueForPayment.ts similarity index 100% rename from src/jobs/shop/modules/roles/components/dueForPayment.ts rename to src/schedules/shop/modules/roles/components/dueForPayment.ts diff --git a/src/jobs/shop/modules/roles/components/overDueForPayment.ts b/src/schedules/shop/modules/roles/components/overDueForPayment.ts similarity index 100% rename from src/jobs/shop/modules/roles/components/overDueForPayment.ts rename to src/schedules/shop/modules/roles/components/overDueForPayment.ts diff --git a/src/jobs/shop/modules/roles/index.ts b/src/schedules/shop/modules/roles/index.ts similarity index 100% rename from src/jobs/shop/modules/roles/index.ts rename to src/schedules/shop/modules/roles/index.ts diff --git a/src/jobs/timeouts/index.ts b/src/schedules/timeouts/index.ts similarity index 100% rename from src/jobs/timeouts/index.ts rename to src/schedules/timeouts/index.ts From 9731dff86dd5ed46d8ba3dbab240482e20eeb045 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 21:23:50 +0200 Subject: [PATCH 159/215] =?UTF-8?q?=F0=9F=8E=A8=20move=20away=20from=20plu?= =?UTF-8?q?gins=20folder?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/{plugins => }/buttons/primary/index.ts | 0 src/{plugins => }/commands/config/index.ts | 0 src/{plugins => }/commands/config/modules/audits/index.ts | 0 src/{plugins => }/commands/config/modules/cpgg/index.ts | 0 src/{plugins => }/commands/config/modules/credits/index.ts | 0 .../commands/config/modules/embeds/components/getValues/index.ts | 0 src/{plugins => }/commands/config/modules/embeds/index.ts | 0 src/{plugins => }/commands/config/modules/index.ts | 0 src/{plugins => }/commands/config/modules/points/index.ts | 0 src/{plugins => }/commands/config/modules/shop/index.ts | 0 src/{plugins => }/commands/config/modules/welcome/index.ts | 0 src/{plugins => }/commands/counters/index.ts | 0 src/{plugins => }/commands/counters/modules/index.ts | 0 src/{plugins => }/commands/counters/modules/view/index.ts | 0 src/{plugins => }/commands/credits/index.ts | 0 src/{plugins => }/commands/credits/modules/balance/index.ts | 0 src/{plugins => }/commands/credits/modules/gift/index.ts | 0 src/{plugins => }/commands/credits/modules/index.ts | 0 src/{plugins => }/commands/credits/modules/top/index.ts | 0 src/{plugins => }/commands/credits/modules/work/index.ts | 0 src/{plugins => }/commands/dns/index.ts | 0 src/{plugins => }/commands/dns/modules/index.ts | 0 src/{plugins => }/commands/dns/modules/lookup/index.ts | 0 src/{plugins => }/commands/fun/index.ts | 0 src/{plugins => }/commands/fun/modules/index.ts | 0 src/{plugins => }/commands/fun/modules/meme/index.ts | 0 src/{plugins => }/commands/manage/index.ts | 0 src/{plugins => }/commands/manage/modules/counters/index.ts | 0 .../commands/manage/modules/counters/modules/add/index.ts | 0 .../commands/manage/modules/counters/modules/index.ts | 0 .../commands/manage/modules/counters/modules/remove/index.ts | 0 src/{plugins => }/commands/manage/modules/credits/index.ts | 0 .../commands/manage/modules/credits/modules/give/index.ts | 0 .../commands/manage/modules/credits/modules/giveaway/index.ts | 0 .../commands/manage/modules/credits/modules/index.ts | 0 .../commands/manage/modules/credits/modules/set/index.ts | 0 .../commands/manage/modules/credits/modules/take/index.ts | 0 .../commands/manage/modules/credits/modules/transfer/index.ts | 0 src/{plugins => }/commands/manage/modules/index.ts | 0 src/{plugins => }/commands/moderation/index.ts | 0 src/{plugins => }/commands/moderation/modules/index.ts | 0 src/{plugins => }/commands/moderation/modules/prune/index.ts | 0 src/{plugins => }/commands/profile/index.ts | 0 src/{plugins => }/commands/profile/modules/index.ts | 0 src/{plugins => }/commands/profile/modules/view/index.ts | 0 src/{plugins => }/commands/reputation/index.ts | 0 .../reputation/modules/give/components/noSelfReputation.ts | 0 src/{plugins => }/commands/reputation/modules/give/index.ts | 0 src/{plugins => }/commands/reputation/modules/index.ts | 0 src/{plugins => }/commands/shop/index.ts | 0 src/{plugins => }/commands/shop/modules/cpgg/index.ts | 0 src/{plugins => }/commands/shop/modules/index.ts | 0 src/{plugins => }/commands/shop/modules/roles/index.ts | 0 .../commands/shop/modules/roles/modules/buy/index.ts | 0 .../commands/shop/modules/roles/modules/cancel/index.ts | 0 src/{plugins => }/commands/shop/modules/roles/modules/index.ts | 0 src/{plugins => }/commands/utility/index.ts | 0 src/{plugins => }/commands/utility/modules/about/index.ts | 0 src/{plugins => }/commands/utility/modules/avatar/index.ts | 0 src/{plugins => }/commands/utility/modules/index.ts | 0 src/{plugins => }/commands/utility/modules/ping/index.ts | 0 src/{plugins => }/commands/utility/modules/stats/index.ts | 0 src/{plugins => }/events/guildCreate/index.ts | 0 src/{plugins => }/events/guildDelete/index.ts | 0 src/{plugins => }/events/guildMemberAdd/audits.ts | 0 src/{plugins => }/events/guildMemberAdd/index.ts | 0 src/{plugins => }/events/guildMemberAdd/joinMessage.ts | 0 src/{plugins => }/events/guildMemberRemove/audits.ts | 0 src/{plugins => }/events/guildMemberRemove/index.ts | 0 src/{plugins => }/events/guildMemberRemove/leaveMessage.ts | 0 src/{plugins => }/events/interactionCreate/audits.ts | 0 .../events/interactionCreate/handlers/button/index.ts | 0 .../events/interactionCreate/handlers/command/index.ts | 0 src/{plugins => }/events/interactionCreate/handlers/index.ts | 0 src/{plugins => }/events/interactionCreate/index.ts | 0 src/{plugins => }/events/messageCreate/index.ts | 0 src/{plugins => }/events/messageCreate/modules/counters/index.ts | 0 src/{plugins => }/events/messageCreate/modules/credits/index.ts | 0 src/{plugins => }/events/messageCreate/modules/index.ts | 0 src/{plugins => }/events/messageCreate/modules/points/index.ts | 0 src/{plugins => }/events/messageDelete/audits.ts | 0 src/{plugins => }/events/messageDelete/index.ts | 0 src/{plugins => }/events/messageDelete/modules/counter.ts | 0 src/{plugins => }/events/messageUpdate/audits.ts | 0 src/{plugins => }/events/messageUpdate/index.ts | 0 src/{plugins => }/events/messageUpdate/modules/counter.ts | 0 src/{plugins => }/events/rateLimit/index.ts | 0 src/{plugins => }/events/ready/index.ts | 0 88 files changed, 0 insertions(+), 0 deletions(-) rename src/{plugins => }/buttons/primary/index.ts (100%) rename src/{plugins => }/commands/config/index.ts (100%) rename src/{plugins => }/commands/config/modules/audits/index.ts (100%) rename src/{plugins => }/commands/config/modules/cpgg/index.ts (100%) rename src/{plugins => }/commands/config/modules/credits/index.ts (100%) rename src/{plugins => }/commands/config/modules/embeds/components/getValues/index.ts (100%) rename src/{plugins => }/commands/config/modules/embeds/index.ts (100%) rename src/{plugins => }/commands/config/modules/index.ts (100%) rename src/{plugins => }/commands/config/modules/points/index.ts (100%) rename src/{plugins => }/commands/config/modules/shop/index.ts (100%) rename src/{plugins => }/commands/config/modules/welcome/index.ts (100%) rename src/{plugins => }/commands/counters/index.ts (100%) rename src/{plugins => }/commands/counters/modules/index.ts (100%) rename src/{plugins => }/commands/counters/modules/view/index.ts (100%) rename src/{plugins => }/commands/credits/index.ts (100%) rename src/{plugins => }/commands/credits/modules/balance/index.ts (100%) rename src/{plugins => }/commands/credits/modules/gift/index.ts (100%) rename src/{plugins => }/commands/credits/modules/index.ts (100%) rename src/{plugins => }/commands/credits/modules/top/index.ts (100%) rename src/{plugins => }/commands/credits/modules/work/index.ts (100%) rename src/{plugins => }/commands/dns/index.ts (100%) rename src/{plugins => }/commands/dns/modules/index.ts (100%) rename src/{plugins => }/commands/dns/modules/lookup/index.ts (100%) rename src/{plugins => }/commands/fun/index.ts (100%) rename src/{plugins => }/commands/fun/modules/index.ts (100%) rename src/{plugins => }/commands/fun/modules/meme/index.ts (100%) rename src/{plugins => }/commands/manage/index.ts (100%) rename src/{plugins => }/commands/manage/modules/counters/index.ts (100%) rename src/{plugins => }/commands/manage/modules/counters/modules/add/index.ts (100%) rename src/{plugins => }/commands/manage/modules/counters/modules/index.ts (100%) rename src/{plugins => }/commands/manage/modules/counters/modules/remove/index.ts (100%) rename src/{plugins => }/commands/manage/modules/credits/index.ts (100%) rename src/{plugins => }/commands/manage/modules/credits/modules/give/index.ts (100%) rename src/{plugins => }/commands/manage/modules/credits/modules/giveaway/index.ts (100%) rename src/{plugins => }/commands/manage/modules/credits/modules/index.ts (100%) rename src/{plugins => }/commands/manage/modules/credits/modules/set/index.ts (100%) rename src/{plugins => }/commands/manage/modules/credits/modules/take/index.ts (100%) rename src/{plugins => }/commands/manage/modules/credits/modules/transfer/index.ts (100%) rename src/{plugins => }/commands/manage/modules/index.ts (100%) rename src/{plugins => }/commands/moderation/index.ts (100%) rename src/{plugins => }/commands/moderation/modules/index.ts (100%) rename src/{plugins => }/commands/moderation/modules/prune/index.ts (100%) rename src/{plugins => }/commands/profile/index.ts (100%) rename src/{plugins => }/commands/profile/modules/index.ts (100%) rename src/{plugins => }/commands/profile/modules/view/index.ts (100%) rename src/{plugins => }/commands/reputation/index.ts (100%) rename src/{plugins => }/commands/reputation/modules/give/components/noSelfReputation.ts (100%) rename src/{plugins => }/commands/reputation/modules/give/index.ts (100%) rename src/{plugins => }/commands/reputation/modules/index.ts (100%) rename src/{plugins => }/commands/shop/index.ts (100%) rename src/{plugins => }/commands/shop/modules/cpgg/index.ts (100%) rename src/{plugins => }/commands/shop/modules/index.ts (100%) rename src/{plugins => }/commands/shop/modules/roles/index.ts (100%) rename src/{plugins => }/commands/shop/modules/roles/modules/buy/index.ts (100%) rename src/{plugins => }/commands/shop/modules/roles/modules/cancel/index.ts (100%) rename src/{plugins => }/commands/shop/modules/roles/modules/index.ts (100%) rename src/{plugins => }/commands/utility/index.ts (100%) rename src/{plugins => }/commands/utility/modules/about/index.ts (100%) rename src/{plugins => }/commands/utility/modules/avatar/index.ts (100%) rename src/{plugins => }/commands/utility/modules/index.ts (100%) rename src/{plugins => }/commands/utility/modules/ping/index.ts (100%) rename src/{plugins => }/commands/utility/modules/stats/index.ts (100%) rename src/{plugins => }/events/guildCreate/index.ts (100%) rename src/{plugins => }/events/guildDelete/index.ts (100%) rename src/{plugins => }/events/guildMemberAdd/audits.ts (100%) rename src/{plugins => }/events/guildMemberAdd/index.ts (100%) rename src/{plugins => }/events/guildMemberAdd/joinMessage.ts (100%) rename src/{plugins => }/events/guildMemberRemove/audits.ts (100%) rename src/{plugins => }/events/guildMemberRemove/index.ts (100%) rename src/{plugins => }/events/guildMemberRemove/leaveMessage.ts (100%) rename src/{plugins => }/events/interactionCreate/audits.ts (100%) rename src/{plugins => }/events/interactionCreate/handlers/button/index.ts (100%) rename src/{plugins => }/events/interactionCreate/handlers/command/index.ts (100%) rename src/{plugins => }/events/interactionCreate/handlers/index.ts (100%) rename src/{plugins => }/events/interactionCreate/index.ts (100%) rename src/{plugins => }/events/messageCreate/index.ts (100%) rename src/{plugins => }/events/messageCreate/modules/counters/index.ts (100%) rename src/{plugins => }/events/messageCreate/modules/credits/index.ts (100%) rename src/{plugins => }/events/messageCreate/modules/index.ts (100%) rename src/{plugins => }/events/messageCreate/modules/points/index.ts (100%) rename src/{plugins => }/events/messageDelete/audits.ts (100%) rename src/{plugins => }/events/messageDelete/index.ts (100%) rename src/{plugins => }/events/messageDelete/modules/counter.ts (100%) rename src/{plugins => }/events/messageUpdate/audits.ts (100%) rename src/{plugins => }/events/messageUpdate/index.ts (100%) rename src/{plugins => }/events/messageUpdate/modules/counter.ts (100%) rename src/{plugins => }/events/rateLimit/index.ts (100%) rename src/{plugins => }/events/ready/index.ts (100%) diff --git a/src/plugins/buttons/primary/index.ts b/src/buttons/primary/index.ts similarity index 100% rename from src/plugins/buttons/primary/index.ts rename to src/buttons/primary/index.ts diff --git a/src/plugins/commands/config/index.ts b/src/commands/config/index.ts similarity index 100% rename from src/plugins/commands/config/index.ts rename to src/commands/config/index.ts diff --git a/src/plugins/commands/config/modules/audits/index.ts b/src/commands/config/modules/audits/index.ts similarity index 100% rename from src/plugins/commands/config/modules/audits/index.ts rename to src/commands/config/modules/audits/index.ts diff --git a/src/plugins/commands/config/modules/cpgg/index.ts b/src/commands/config/modules/cpgg/index.ts similarity index 100% rename from src/plugins/commands/config/modules/cpgg/index.ts rename to src/commands/config/modules/cpgg/index.ts diff --git a/src/plugins/commands/config/modules/credits/index.ts b/src/commands/config/modules/credits/index.ts similarity index 100% rename from src/plugins/commands/config/modules/credits/index.ts rename to src/commands/config/modules/credits/index.ts diff --git a/src/plugins/commands/config/modules/embeds/components/getValues/index.ts b/src/commands/config/modules/embeds/components/getValues/index.ts similarity index 100% rename from src/plugins/commands/config/modules/embeds/components/getValues/index.ts rename to src/commands/config/modules/embeds/components/getValues/index.ts diff --git a/src/plugins/commands/config/modules/embeds/index.ts b/src/commands/config/modules/embeds/index.ts similarity index 100% rename from src/plugins/commands/config/modules/embeds/index.ts rename to src/commands/config/modules/embeds/index.ts diff --git a/src/plugins/commands/config/modules/index.ts b/src/commands/config/modules/index.ts similarity index 100% rename from src/plugins/commands/config/modules/index.ts rename to src/commands/config/modules/index.ts diff --git a/src/plugins/commands/config/modules/points/index.ts b/src/commands/config/modules/points/index.ts similarity index 100% rename from src/plugins/commands/config/modules/points/index.ts rename to src/commands/config/modules/points/index.ts diff --git a/src/plugins/commands/config/modules/shop/index.ts b/src/commands/config/modules/shop/index.ts similarity index 100% rename from src/plugins/commands/config/modules/shop/index.ts rename to src/commands/config/modules/shop/index.ts diff --git a/src/plugins/commands/config/modules/welcome/index.ts b/src/commands/config/modules/welcome/index.ts similarity index 100% rename from src/plugins/commands/config/modules/welcome/index.ts rename to src/commands/config/modules/welcome/index.ts diff --git a/src/plugins/commands/counters/index.ts b/src/commands/counters/index.ts similarity index 100% rename from src/plugins/commands/counters/index.ts rename to src/commands/counters/index.ts diff --git a/src/plugins/commands/counters/modules/index.ts b/src/commands/counters/modules/index.ts similarity index 100% rename from src/plugins/commands/counters/modules/index.ts rename to src/commands/counters/modules/index.ts diff --git a/src/plugins/commands/counters/modules/view/index.ts b/src/commands/counters/modules/view/index.ts similarity index 100% rename from src/plugins/commands/counters/modules/view/index.ts rename to src/commands/counters/modules/view/index.ts diff --git a/src/plugins/commands/credits/index.ts b/src/commands/credits/index.ts similarity index 100% rename from src/plugins/commands/credits/index.ts rename to src/commands/credits/index.ts diff --git a/src/plugins/commands/credits/modules/balance/index.ts b/src/commands/credits/modules/balance/index.ts similarity index 100% rename from src/plugins/commands/credits/modules/balance/index.ts rename to src/commands/credits/modules/balance/index.ts diff --git a/src/plugins/commands/credits/modules/gift/index.ts b/src/commands/credits/modules/gift/index.ts similarity index 100% rename from src/plugins/commands/credits/modules/gift/index.ts rename to src/commands/credits/modules/gift/index.ts diff --git a/src/plugins/commands/credits/modules/index.ts b/src/commands/credits/modules/index.ts similarity index 100% rename from src/plugins/commands/credits/modules/index.ts rename to src/commands/credits/modules/index.ts diff --git a/src/plugins/commands/credits/modules/top/index.ts b/src/commands/credits/modules/top/index.ts similarity index 100% rename from src/plugins/commands/credits/modules/top/index.ts rename to src/commands/credits/modules/top/index.ts diff --git a/src/plugins/commands/credits/modules/work/index.ts b/src/commands/credits/modules/work/index.ts similarity index 100% rename from src/plugins/commands/credits/modules/work/index.ts rename to src/commands/credits/modules/work/index.ts diff --git a/src/plugins/commands/dns/index.ts b/src/commands/dns/index.ts similarity index 100% rename from src/plugins/commands/dns/index.ts rename to src/commands/dns/index.ts diff --git a/src/plugins/commands/dns/modules/index.ts b/src/commands/dns/modules/index.ts similarity index 100% rename from src/plugins/commands/dns/modules/index.ts rename to src/commands/dns/modules/index.ts diff --git a/src/plugins/commands/dns/modules/lookup/index.ts b/src/commands/dns/modules/lookup/index.ts similarity index 100% rename from src/plugins/commands/dns/modules/lookup/index.ts rename to src/commands/dns/modules/lookup/index.ts diff --git a/src/plugins/commands/fun/index.ts b/src/commands/fun/index.ts similarity index 100% rename from src/plugins/commands/fun/index.ts rename to src/commands/fun/index.ts diff --git a/src/plugins/commands/fun/modules/index.ts b/src/commands/fun/modules/index.ts similarity index 100% rename from src/plugins/commands/fun/modules/index.ts rename to src/commands/fun/modules/index.ts diff --git a/src/plugins/commands/fun/modules/meme/index.ts b/src/commands/fun/modules/meme/index.ts similarity index 100% rename from src/plugins/commands/fun/modules/meme/index.ts rename to src/commands/fun/modules/meme/index.ts diff --git a/src/plugins/commands/manage/index.ts b/src/commands/manage/index.ts similarity index 100% rename from src/plugins/commands/manage/index.ts rename to src/commands/manage/index.ts diff --git a/src/plugins/commands/manage/modules/counters/index.ts b/src/commands/manage/modules/counters/index.ts similarity index 100% rename from src/plugins/commands/manage/modules/counters/index.ts rename to src/commands/manage/modules/counters/index.ts diff --git a/src/plugins/commands/manage/modules/counters/modules/add/index.ts b/src/commands/manage/modules/counters/modules/add/index.ts similarity index 100% rename from src/plugins/commands/manage/modules/counters/modules/add/index.ts rename to src/commands/manage/modules/counters/modules/add/index.ts diff --git a/src/plugins/commands/manage/modules/counters/modules/index.ts b/src/commands/manage/modules/counters/modules/index.ts similarity index 100% rename from src/plugins/commands/manage/modules/counters/modules/index.ts rename to src/commands/manage/modules/counters/modules/index.ts diff --git a/src/plugins/commands/manage/modules/counters/modules/remove/index.ts b/src/commands/manage/modules/counters/modules/remove/index.ts similarity index 100% rename from src/plugins/commands/manage/modules/counters/modules/remove/index.ts rename to src/commands/manage/modules/counters/modules/remove/index.ts diff --git a/src/plugins/commands/manage/modules/credits/index.ts b/src/commands/manage/modules/credits/index.ts similarity index 100% rename from src/plugins/commands/manage/modules/credits/index.ts rename to src/commands/manage/modules/credits/index.ts diff --git a/src/plugins/commands/manage/modules/credits/modules/give/index.ts b/src/commands/manage/modules/credits/modules/give/index.ts similarity index 100% rename from src/plugins/commands/manage/modules/credits/modules/give/index.ts rename to src/commands/manage/modules/credits/modules/give/index.ts diff --git a/src/plugins/commands/manage/modules/credits/modules/giveaway/index.ts b/src/commands/manage/modules/credits/modules/giveaway/index.ts similarity index 100% rename from src/plugins/commands/manage/modules/credits/modules/giveaway/index.ts rename to src/commands/manage/modules/credits/modules/giveaway/index.ts diff --git a/src/plugins/commands/manage/modules/credits/modules/index.ts b/src/commands/manage/modules/credits/modules/index.ts similarity index 100% rename from src/plugins/commands/manage/modules/credits/modules/index.ts rename to src/commands/manage/modules/credits/modules/index.ts diff --git a/src/plugins/commands/manage/modules/credits/modules/set/index.ts b/src/commands/manage/modules/credits/modules/set/index.ts similarity index 100% rename from src/plugins/commands/manage/modules/credits/modules/set/index.ts rename to src/commands/manage/modules/credits/modules/set/index.ts diff --git a/src/plugins/commands/manage/modules/credits/modules/take/index.ts b/src/commands/manage/modules/credits/modules/take/index.ts similarity index 100% rename from src/plugins/commands/manage/modules/credits/modules/take/index.ts rename to src/commands/manage/modules/credits/modules/take/index.ts diff --git a/src/plugins/commands/manage/modules/credits/modules/transfer/index.ts b/src/commands/manage/modules/credits/modules/transfer/index.ts similarity index 100% rename from src/plugins/commands/manage/modules/credits/modules/transfer/index.ts rename to src/commands/manage/modules/credits/modules/transfer/index.ts diff --git a/src/plugins/commands/manage/modules/index.ts b/src/commands/manage/modules/index.ts similarity index 100% rename from src/plugins/commands/manage/modules/index.ts rename to src/commands/manage/modules/index.ts diff --git a/src/plugins/commands/moderation/index.ts b/src/commands/moderation/index.ts similarity index 100% rename from src/plugins/commands/moderation/index.ts rename to src/commands/moderation/index.ts diff --git a/src/plugins/commands/moderation/modules/index.ts b/src/commands/moderation/modules/index.ts similarity index 100% rename from src/plugins/commands/moderation/modules/index.ts rename to src/commands/moderation/modules/index.ts diff --git a/src/plugins/commands/moderation/modules/prune/index.ts b/src/commands/moderation/modules/prune/index.ts similarity index 100% rename from src/plugins/commands/moderation/modules/prune/index.ts rename to src/commands/moderation/modules/prune/index.ts diff --git a/src/plugins/commands/profile/index.ts b/src/commands/profile/index.ts similarity index 100% rename from src/plugins/commands/profile/index.ts rename to src/commands/profile/index.ts diff --git a/src/plugins/commands/profile/modules/index.ts b/src/commands/profile/modules/index.ts similarity index 100% rename from src/plugins/commands/profile/modules/index.ts rename to src/commands/profile/modules/index.ts diff --git a/src/plugins/commands/profile/modules/view/index.ts b/src/commands/profile/modules/view/index.ts similarity index 100% rename from src/plugins/commands/profile/modules/view/index.ts rename to src/commands/profile/modules/view/index.ts diff --git a/src/plugins/commands/reputation/index.ts b/src/commands/reputation/index.ts similarity index 100% rename from src/plugins/commands/reputation/index.ts rename to src/commands/reputation/index.ts diff --git a/src/plugins/commands/reputation/modules/give/components/noSelfReputation.ts b/src/commands/reputation/modules/give/components/noSelfReputation.ts similarity index 100% rename from src/plugins/commands/reputation/modules/give/components/noSelfReputation.ts rename to src/commands/reputation/modules/give/components/noSelfReputation.ts diff --git a/src/plugins/commands/reputation/modules/give/index.ts b/src/commands/reputation/modules/give/index.ts similarity index 100% rename from src/plugins/commands/reputation/modules/give/index.ts rename to src/commands/reputation/modules/give/index.ts diff --git a/src/plugins/commands/reputation/modules/index.ts b/src/commands/reputation/modules/index.ts similarity index 100% rename from src/plugins/commands/reputation/modules/index.ts rename to src/commands/reputation/modules/index.ts diff --git a/src/plugins/commands/shop/index.ts b/src/commands/shop/index.ts similarity index 100% rename from src/plugins/commands/shop/index.ts rename to src/commands/shop/index.ts diff --git a/src/plugins/commands/shop/modules/cpgg/index.ts b/src/commands/shop/modules/cpgg/index.ts similarity index 100% rename from src/plugins/commands/shop/modules/cpgg/index.ts rename to src/commands/shop/modules/cpgg/index.ts diff --git a/src/plugins/commands/shop/modules/index.ts b/src/commands/shop/modules/index.ts similarity index 100% rename from src/plugins/commands/shop/modules/index.ts rename to src/commands/shop/modules/index.ts diff --git a/src/plugins/commands/shop/modules/roles/index.ts b/src/commands/shop/modules/roles/index.ts similarity index 100% rename from src/plugins/commands/shop/modules/roles/index.ts rename to src/commands/shop/modules/roles/index.ts diff --git a/src/plugins/commands/shop/modules/roles/modules/buy/index.ts b/src/commands/shop/modules/roles/modules/buy/index.ts similarity index 100% rename from src/plugins/commands/shop/modules/roles/modules/buy/index.ts rename to src/commands/shop/modules/roles/modules/buy/index.ts diff --git a/src/plugins/commands/shop/modules/roles/modules/cancel/index.ts b/src/commands/shop/modules/roles/modules/cancel/index.ts similarity index 100% rename from src/plugins/commands/shop/modules/roles/modules/cancel/index.ts rename to src/commands/shop/modules/roles/modules/cancel/index.ts diff --git a/src/plugins/commands/shop/modules/roles/modules/index.ts b/src/commands/shop/modules/roles/modules/index.ts similarity index 100% rename from src/plugins/commands/shop/modules/roles/modules/index.ts rename to src/commands/shop/modules/roles/modules/index.ts diff --git a/src/plugins/commands/utility/index.ts b/src/commands/utility/index.ts similarity index 100% rename from src/plugins/commands/utility/index.ts rename to src/commands/utility/index.ts diff --git a/src/plugins/commands/utility/modules/about/index.ts b/src/commands/utility/modules/about/index.ts similarity index 100% rename from src/plugins/commands/utility/modules/about/index.ts rename to src/commands/utility/modules/about/index.ts diff --git a/src/plugins/commands/utility/modules/avatar/index.ts b/src/commands/utility/modules/avatar/index.ts similarity index 100% rename from src/plugins/commands/utility/modules/avatar/index.ts rename to src/commands/utility/modules/avatar/index.ts diff --git a/src/plugins/commands/utility/modules/index.ts b/src/commands/utility/modules/index.ts similarity index 100% rename from src/plugins/commands/utility/modules/index.ts rename to src/commands/utility/modules/index.ts diff --git a/src/plugins/commands/utility/modules/ping/index.ts b/src/commands/utility/modules/ping/index.ts similarity index 100% rename from src/plugins/commands/utility/modules/ping/index.ts rename to src/commands/utility/modules/ping/index.ts diff --git a/src/plugins/commands/utility/modules/stats/index.ts b/src/commands/utility/modules/stats/index.ts similarity index 100% rename from src/plugins/commands/utility/modules/stats/index.ts rename to src/commands/utility/modules/stats/index.ts diff --git a/src/plugins/events/guildCreate/index.ts b/src/events/guildCreate/index.ts similarity index 100% rename from src/plugins/events/guildCreate/index.ts rename to src/events/guildCreate/index.ts diff --git a/src/plugins/events/guildDelete/index.ts b/src/events/guildDelete/index.ts similarity index 100% rename from src/plugins/events/guildDelete/index.ts rename to src/events/guildDelete/index.ts diff --git a/src/plugins/events/guildMemberAdd/audits.ts b/src/events/guildMemberAdd/audits.ts similarity index 100% rename from src/plugins/events/guildMemberAdd/audits.ts rename to src/events/guildMemberAdd/audits.ts diff --git a/src/plugins/events/guildMemberAdd/index.ts b/src/events/guildMemberAdd/index.ts similarity index 100% rename from src/plugins/events/guildMemberAdd/index.ts rename to src/events/guildMemberAdd/index.ts diff --git a/src/plugins/events/guildMemberAdd/joinMessage.ts b/src/events/guildMemberAdd/joinMessage.ts similarity index 100% rename from src/plugins/events/guildMemberAdd/joinMessage.ts rename to src/events/guildMemberAdd/joinMessage.ts diff --git a/src/plugins/events/guildMemberRemove/audits.ts b/src/events/guildMemberRemove/audits.ts similarity index 100% rename from src/plugins/events/guildMemberRemove/audits.ts rename to src/events/guildMemberRemove/audits.ts diff --git a/src/plugins/events/guildMemberRemove/index.ts b/src/events/guildMemberRemove/index.ts similarity index 100% rename from src/plugins/events/guildMemberRemove/index.ts rename to src/events/guildMemberRemove/index.ts diff --git a/src/plugins/events/guildMemberRemove/leaveMessage.ts b/src/events/guildMemberRemove/leaveMessage.ts similarity index 100% rename from src/plugins/events/guildMemberRemove/leaveMessage.ts rename to src/events/guildMemberRemove/leaveMessage.ts diff --git a/src/plugins/events/interactionCreate/audits.ts b/src/events/interactionCreate/audits.ts similarity index 100% rename from src/plugins/events/interactionCreate/audits.ts rename to src/events/interactionCreate/audits.ts diff --git a/src/plugins/events/interactionCreate/handlers/button/index.ts b/src/events/interactionCreate/handlers/button/index.ts similarity index 100% rename from src/plugins/events/interactionCreate/handlers/button/index.ts rename to src/events/interactionCreate/handlers/button/index.ts diff --git a/src/plugins/events/interactionCreate/handlers/command/index.ts b/src/events/interactionCreate/handlers/command/index.ts similarity index 100% rename from src/plugins/events/interactionCreate/handlers/command/index.ts rename to src/events/interactionCreate/handlers/command/index.ts diff --git a/src/plugins/events/interactionCreate/handlers/index.ts b/src/events/interactionCreate/handlers/index.ts similarity index 100% rename from src/plugins/events/interactionCreate/handlers/index.ts rename to src/events/interactionCreate/handlers/index.ts diff --git a/src/plugins/events/interactionCreate/index.ts b/src/events/interactionCreate/index.ts similarity index 100% rename from src/plugins/events/interactionCreate/index.ts rename to src/events/interactionCreate/index.ts diff --git a/src/plugins/events/messageCreate/index.ts b/src/events/messageCreate/index.ts similarity index 100% rename from src/plugins/events/messageCreate/index.ts rename to src/events/messageCreate/index.ts diff --git a/src/plugins/events/messageCreate/modules/counters/index.ts b/src/events/messageCreate/modules/counters/index.ts similarity index 100% rename from src/plugins/events/messageCreate/modules/counters/index.ts rename to src/events/messageCreate/modules/counters/index.ts diff --git a/src/plugins/events/messageCreate/modules/credits/index.ts b/src/events/messageCreate/modules/credits/index.ts similarity index 100% rename from src/plugins/events/messageCreate/modules/credits/index.ts rename to src/events/messageCreate/modules/credits/index.ts diff --git a/src/plugins/events/messageCreate/modules/index.ts b/src/events/messageCreate/modules/index.ts similarity index 100% rename from src/plugins/events/messageCreate/modules/index.ts rename to src/events/messageCreate/modules/index.ts diff --git a/src/plugins/events/messageCreate/modules/points/index.ts b/src/events/messageCreate/modules/points/index.ts similarity index 100% rename from src/plugins/events/messageCreate/modules/points/index.ts rename to src/events/messageCreate/modules/points/index.ts diff --git a/src/plugins/events/messageDelete/audits.ts b/src/events/messageDelete/audits.ts similarity index 100% rename from src/plugins/events/messageDelete/audits.ts rename to src/events/messageDelete/audits.ts diff --git a/src/plugins/events/messageDelete/index.ts b/src/events/messageDelete/index.ts similarity index 100% rename from src/plugins/events/messageDelete/index.ts rename to src/events/messageDelete/index.ts diff --git a/src/plugins/events/messageDelete/modules/counter.ts b/src/events/messageDelete/modules/counter.ts similarity index 100% rename from src/plugins/events/messageDelete/modules/counter.ts rename to src/events/messageDelete/modules/counter.ts diff --git a/src/plugins/events/messageUpdate/audits.ts b/src/events/messageUpdate/audits.ts similarity index 100% rename from src/plugins/events/messageUpdate/audits.ts rename to src/events/messageUpdate/audits.ts diff --git a/src/plugins/events/messageUpdate/index.ts b/src/events/messageUpdate/index.ts similarity index 100% rename from src/plugins/events/messageUpdate/index.ts rename to src/events/messageUpdate/index.ts diff --git a/src/plugins/events/messageUpdate/modules/counter.ts b/src/events/messageUpdate/modules/counter.ts similarity index 100% rename from src/plugins/events/messageUpdate/modules/counter.ts rename to src/events/messageUpdate/modules/counter.ts diff --git a/src/plugins/events/rateLimit/index.ts b/src/events/rateLimit/index.ts similarity index 100% rename from src/plugins/events/rateLimit/index.ts rename to src/events/rateLimit/index.ts diff --git a/src/plugins/events/ready/index.ts b/src/events/ready/index.ts similarity index 100% rename from src/plugins/events/ready/index.ts rename to src/events/ready/index.ts From 527d32ae2ea8422f3cf8d8890a0da37920d83cef Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Thu, 20 Oct 2022 10:09:43 +0200 Subject: [PATCH 160/215] =?UTF-8?q?=F0=9F=9A=9A=20fixed=20correct=20paths?= =?UTF-8?q?=20for=20events=20commands=20buttons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/buttons/primary/index.ts | 2 +- src/commands/config/modules/audits/index.ts | 6 +++--- src/commands/config/modules/cpgg/index.ts | 8 ++++---- src/commands/config/modules/credits/index.ts | 6 +++--- .../modules/embeds/components/getValues/index.ts | 6 +++--- src/commands/config/modules/points/index.ts | 6 +++--- src/commands/config/modules/shop/index.ts | 6 +++--- src/commands/config/modules/welcome/index.ts | 6 +++--- src/commands/counters/index.ts | 2 +- src/commands/counters/modules/view/index.ts | 4 ++-- src/commands/credits/index.ts | 2 +- src/commands/credits/modules/balance/index.ts | 6 +++--- src/commands/credits/modules/gift/index.ts | 4 ++-- src/commands/credits/modules/top/index.ts | 6 +++--- src/commands/credits/modules/work/index.ts | 8 ++++---- src/commands/dns/modules/lookup/index.ts | 2 +- src/commands/fun/index.ts | 4 ++-- src/commands/fun/modules/meme/index.ts | 2 +- src/commands/manage/index.ts | 2 +- .../manage/modules/counters/modules/add/index.ts | 6 +++--- .../modules/counters/modules/remove/index.ts | 4 ++-- .../manage/modules/credits/modules/give/index.ts | 8 ++++---- .../modules/credits/modules/giveaway/index.ts | 6 +++--- .../manage/modules/credits/modules/set/index.ts | 6 +++--- .../manage/modules/credits/modules/take/index.ts | 8 ++++---- .../modules/credits/modules/transfer/index.ts | 4 ++-- src/commands/moderation/modules/prune/index.ts | 2 +- src/commands/profile/index.ts | 2 +- src/commands/profile/modules/view/index.ts | 6 +++--- src/commands/reputation/modules/give/index.ts | 8 ++++---- src/commands/shop/modules/cpgg/index.ts | 12 ++++++------ src/commands/shop/modules/roles/index.ts | 2 +- .../shop/modules/roles/modules/buy/index.ts | 16 ++++++++-------- .../shop/modules/roles/modules/cancel/index.ts | 10 +++++----- src/commands/utility/modules/about/index.ts | 2 +- src/commands/utility/modules/avatar/index.ts | 2 +- src/commands/utility/modules/ping/index.ts | 2 +- src/commands/utility/modules/stats/index.ts | 2 +- src/events/guildCreate/index.ts | 8 ++++---- src/events/guildDelete/index.ts | 8 ++++---- src/events/guildMemberAdd/audits.ts | 6 +++--- src/events/guildMemberAdd/index.ts | 8 ++++---- src/events/guildMemberAdd/joinMessage.ts | 4 ++-- src/events/guildMemberRemove/audits.ts | 6 +++--- src/events/guildMemberRemove/index.ts | 8 ++++---- src/events/guildMemberRemove/leaveMessage.ts | 4 ++-- src/events/interactionCreate/audits.ts | 6 +++--- .../interactionCreate/handlers/button/index.ts | 4 ++-- .../interactionCreate/handlers/command/index.ts | 6 +++--- src/events/interactionCreate/handlers/index.ts | 4 ++-- src/events/interactionCreate/index.ts | 4 ++-- src/events/messageCreate/index.ts | 4 ++-- .../messageCreate/modules/counters/index.ts | 4 ++-- .../messageCreate/modules/credits/index.ts | 6 +++--- src/events/messageCreate/modules/points/index.ts | 6 +++--- src/events/messageDelete/audits.ts | 6 +++--- src/events/messageDelete/index.ts | 4 ++-- src/events/messageDelete/modules/counter.ts | 4 ++-- src/events/messageUpdate/audits.ts | 6 +++--- src/events/messageUpdate/index.ts | 4 ++-- src/events/messageUpdate/modules/counter.ts | 4 ++-- src/events/rateLimit/index.ts | 4 ++-- src/events/ready/index.ts | 10 +++++----- 63 files changed, 167 insertions(+), 167 deletions(-) diff --git a/src/buttons/primary/index.ts b/src/buttons/primary/index.ts index c889d64..d80ddb3 100644 --- a/src/buttons/primary/index.ts +++ b/src/buttons/primary/index.ts @@ -1,5 +1,5 @@ import { ButtonInteraction } from "discord.js"; -import logger from "../../../middlewares/logger"; +import logger from "../../middlewares/logger"; export const metadata = { guildOnly: false, ephemeral: false }; diff --git a/src/commands/config/modules/audits/index.ts b/src/commands/config/modules/audits/index.ts index 1605ed9..46e2bfb 100644 --- a/src/commands/config/modules/audits/index.ts +++ b/src/commands/config/modules/audits/index.ts @@ -5,9 +5,9 @@ import { EmbedBuilder, PermissionsBitField, } from "discord.js"; -import getEmbedConfig from "../../../../../helpers/getEmbedData"; -import logger from "../../../../../middlewares/logger"; -import guildSchema from "../../../../../models/guild"; +import getEmbedConfig from "../../../../helpers/getEmbedData"; +import logger from "../../../../middlewares/logger"; +import guildSchema from "../../../../models/guild"; export default { metadata: { diff --git a/src/commands/config/modules/cpgg/index.ts b/src/commands/config/modules/cpgg/index.ts index 1f640ab..4dd1bef 100644 --- a/src/commands/config/modules/cpgg/index.ts +++ b/src/commands/config/modules/cpgg/index.ts @@ -4,10 +4,10 @@ import { EmbedBuilder, PermissionsBitField, } from "discord.js"; -import encryption from "../../../../../helpers/encryption"; -import getEmbedConfig from "../../../../../helpers/getEmbedData"; -import logger from "../../../../../middlewares/logger"; -import apiSchema from "../../../../../models/api"; +import encryption from "../../../../helpers/encryption"; +import getEmbedConfig from "../../../../helpers/getEmbedData"; +import logger from "../../../../middlewares/logger"; +import apiSchema from "../../../../models/api"; export default { metadata: { diff --git a/src/commands/config/modules/credits/index.ts b/src/commands/config/modules/credits/index.ts index 1f65b88..f140faf 100644 --- a/src/commands/config/modules/credits/index.ts +++ b/src/commands/config/modules/credits/index.ts @@ -4,9 +4,9 @@ import { EmbedBuilder, PermissionsBitField, } from "discord.js"; -import getEmbedConfig from "../../../../../helpers/getEmbedData"; -import logger from "../../../../../middlewares/logger"; -import guildSchema from "../../../../../models/guild"; +import getEmbedConfig from "../../../../helpers/getEmbedData"; +import logger from "../../../../middlewares/logger"; +import guildSchema from "../../../../models/guild"; export default { metadata: { diff --git a/src/commands/config/modules/embeds/components/getValues/index.ts b/src/commands/config/modules/embeds/components/getValues/index.ts index f772cbc..ae35157 100644 --- a/src/commands/config/modules/embeds/components/getValues/index.ts +++ b/src/commands/config/modules/embeds/components/getValues/index.ts @@ -1,7 +1,7 @@ import { ChatInputCommandInteraction, ColorResolvable } from "discord.js"; -import prisma from "../../../../../../../handlers/database"; -import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; -import logger from "../../../../../../../middlewares/logger"; +import prisma from "../../../../../../handlers/database"; +import getEmbedConfig from "../../../../../../helpers/getEmbedData"; +import logger from "../../../../../../middlewares/logger"; export default async (interaction: ChatInputCommandInteraction) => { const { options, guild } = interaction; diff --git a/src/commands/config/modules/points/index.ts b/src/commands/config/modules/points/index.ts index 03f30ec..9cda9a3 100644 --- a/src/commands/config/modules/points/index.ts +++ b/src/commands/config/modules/points/index.ts @@ -4,9 +4,9 @@ import { EmbedBuilder, PermissionsBitField, } from "discord.js"; -import getEmbedConfig from "../../../../../helpers/getEmbedData"; -import logger from "../../../../../middlewares/logger"; -import guildSchema from "../../../../../models/guild"; +import getEmbedConfig from "../../../../helpers/getEmbedData"; +import logger from "../../../../middlewares/logger"; +import guildSchema from "../../../../models/guild"; export default { metadata: { diff --git a/src/commands/config/modules/shop/index.ts b/src/commands/config/modules/shop/index.ts index 0b0b9e7..9093fa0 100644 --- a/src/commands/config/modules/shop/index.ts +++ b/src/commands/config/modules/shop/index.ts @@ -4,9 +4,9 @@ import { EmbedBuilder, PermissionsBitField, } from "discord.js"; -import getEmbedConfig from "../../../../../helpers/getEmbedData"; -import logger from "../../../../../middlewares/logger"; -import guildSchema from "../../../../../models/guild"; +import getEmbedConfig from "../../../../helpers/getEmbedData"; +import logger from "../../../../middlewares/logger"; +import guildSchema from "../../../../models/guild"; export default { metadata: { diff --git a/src/commands/config/modules/welcome/index.ts b/src/commands/config/modules/welcome/index.ts index 585c861..7cd463e 100644 --- a/src/commands/config/modules/welcome/index.ts +++ b/src/commands/config/modules/welcome/index.ts @@ -5,9 +5,9 @@ import { EmbedBuilder, PermissionsBitField, } from "discord.js"; -import getEmbedConfig from "../../../../../helpers/getEmbedData"; -import logger from "../../../../../middlewares/logger"; -import guildSchema from "../../../../../models/guild"; +import getEmbedConfig from "../../../../helpers/getEmbedData"; +import logger from "../../../../middlewares/logger"; +import guildSchema from "../../../../models/guild"; export default { metadata: { diff --git a/src/commands/counters/index.ts b/src/commands/counters/index.ts index eb1e4f3..b9c9fb3 100644 --- a/src/commands/counters/index.ts +++ b/src/commands/counters/index.ts @@ -1,7 +1,7 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction } from "discord.js"; -import modules from "../../commands/counters/modules"; +import modules from "../commands/counters/modules"; export const builder = new SlashCommandBuilder() .setName("counters") diff --git a/src/commands/counters/modules/view/index.ts b/src/commands/counters/modules/view/index.ts index 858658e..dd8e510 100644 --- a/src/commands/counters/modules/view/index.ts +++ b/src/commands/counters/modules/view/index.ts @@ -1,8 +1,8 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChannelType } from "discord-api-types/v10"; import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js"; -import prisma from "../../../../../handlers/database"; -import getEmbedConfig from "../../../../../helpers/getEmbedData"; +import prisma from "../../../../handlers/database"; +import getEmbedConfig from "../../../../helpers/getEmbedData"; export default { metadata: { guildOnly: true, ephemeral: false }, diff --git a/src/commands/credits/index.ts b/src/commands/credits/index.ts index 4e30065..ad0f771 100644 --- a/src/commands/credits/index.ts +++ b/src/commands/credits/index.ts @@ -1,6 +1,6 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction } from "discord.js"; -import logger from "../../../middlewares/logger"; +import logger from "../../middlewares/logger"; import modules from "./modules"; diff --git a/src/commands/credits/modules/balance/index.ts b/src/commands/credits/modules/balance/index.ts index da8f1d3..a360c8e 100644 --- a/src/commands/credits/modules/balance/index.ts +++ b/src/commands/credits/modules/balance/index.ts @@ -1,8 +1,8 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { CommandInteraction, EmbedBuilder } from "discord.js"; -import prisma from "../../../../../handlers/database"; -import getEmbedConfig from "../../../../../helpers/getEmbedData"; -import logger from "../../../../../middlewares/logger"; +import prisma from "../../../../handlers/database"; +import getEmbedConfig from "../../../../helpers/getEmbedData"; +import logger from "../../../../middlewares/logger"; export default { metadata: { guildOnly: true, ephemeral: true }, diff --git a/src/commands/credits/modules/gift/index.ts b/src/commands/credits/modules/gift/index.ts index 64d12be..4c2e541 100644 --- a/src/commands/credits/modules/gift/index.ts +++ b/src/commands/credits/modules/gift/index.ts @@ -5,9 +5,9 @@ import { EmbedBuilder, SlashCommandSubcommandBuilder, } from "discord.js"; -import transferCredits from "../../../../../helpers/transferCredits"; +import transferCredits from "../../../../helpers/transferCredits"; // Configurations -import getEmbedConfig from "../../../../../helpers/getEmbedData"; +import getEmbedConfig from "../../../../helpers/getEmbedData"; // Handlers // Function diff --git a/src/commands/credits/modules/top/index.ts b/src/commands/credits/modules/top/index.ts index c045d95..7162744 100644 --- a/src/commands/credits/modules/top/index.ts +++ b/src/commands/credits/modules/top/index.ts @@ -1,9 +1,9 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { GuildMember } from "@prisma/client"; import { CommandInteraction, EmbedBuilder } from "discord.js"; -import prisma from "../../../../../handlers/database"; -import getEmbedConfig from "../../../../../helpers/getEmbedData"; -import logger from "../../../../../middlewares/logger"; +import prisma from "../../../../handlers/database"; +import getEmbedConfig from "../../../../helpers/getEmbedData"; +import logger from "../../../../middlewares/logger"; export default { metadata: { guildOnly: true, ephemeral: false }, diff --git a/src/commands/credits/modules/work/index.ts b/src/commands/credits/modules/work/index.ts index 8b88d81..1a5407b 100644 --- a/src/commands/credits/modules/work/index.ts +++ b/src/commands/credits/modules/work/index.ts @@ -3,13 +3,13 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import Chance from "chance"; import { CommandInteraction, EmbedBuilder } from "discord.js"; // Models -import * as cooldown from "../../../../../handlers/cooldown"; +import * as cooldown from "../../../../handlers/cooldown"; // Configurations -import getEmbedConfig from "../../../../../helpers/getEmbedData"; +import getEmbedConfig from "../../../../helpers/getEmbedData"; // Helpers // Handlers -import prisma from "../../../../../handlers/database"; -import logger from "../../../../../middlewares/logger"; +import prisma from "../../../../handlers/database"; +import logger from "../../../../middlewares/logger"; export default { metadata: { guildOnly: true, ephemeral: true }, diff --git a/src/commands/dns/modules/lookup/index.ts b/src/commands/dns/modules/lookup/index.ts index 47f0785..afa51a6 100644 --- a/src/commands/dns/modules/lookup/index.ts +++ b/src/commands/dns/modules/lookup/index.ts @@ -1,7 +1,7 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import axios from "axios"; import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js"; -import getEmbedConfig from "../../../../../helpers/getEmbedData"; +import getEmbedConfig from "../../../../helpers/getEmbedData"; export default { metadata: { guildOnly: false, ephemeral: false }, diff --git a/src/commands/fun/index.ts b/src/commands/fun/index.ts index 7b0d4ba..ccd275a 100644 --- a/src/commands/fun/index.ts +++ b/src/commands/fun/index.ts @@ -1,8 +1,8 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction } from "discord.js"; -import logger from "../../../middlewares/logger"; +import logger from "../../middlewares/logger"; -import modules from "../../commands/fun/modules"; +import modules from "../commands/fun/modules"; export const builder = new SlashCommandBuilder() .setName("fun") diff --git a/src/commands/fun/modules/meme/index.ts b/src/commands/fun/modules/meme/index.ts index 452f900..b5c3db3 100644 --- a/src/commands/fun/modules/meme/index.ts +++ b/src/commands/fun/modules/meme/index.ts @@ -1,7 +1,7 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import axios from "axios"; import { CommandInteraction, EmbedBuilder } from "discord.js"; -import getEmbedConfig from "../../../../../helpers/getEmbedData"; +import getEmbedConfig from "../../../../helpers/getEmbedData"; export default { metadata: { guildOnly: false, ephemeral: false, cooldown: 15 }, diff --git a/src/commands/manage/index.ts b/src/commands/manage/index.ts index 9de5997..e09f024 100644 --- a/src/commands/manage/index.ts +++ b/src/commands/manage/index.ts @@ -3,7 +3,7 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction } from "discord.js"; // Groups -import modules from "../../commands/manage/modules"; +import modules from "../commands/manage/modules"; export const moduleData = modules; diff --git a/src/commands/manage/modules/counters/modules/add/index.ts b/src/commands/manage/modules/counters/modules/add/index.ts index 38f6f51..403a234 100644 --- a/src/commands/manage/modules/counters/modules/add/index.ts +++ b/src/commands/manage/modules/counters/modules/add/index.ts @@ -7,9 +7,9 @@ import { PermissionsBitField, } from "discord.js"; // Configurations -import prisma from "../../../../../../../handlers/database"; -import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; -import logger from "../../../../../../../middlewares/logger"; +import prisma from "../../../../../../handlers/database"; +import getEmbedConfig from "../../../../../../helpers/getEmbedData"; +import logger from "../../../../../../middlewares/logger"; // Function export default { diff --git a/src/commands/manage/modules/counters/modules/remove/index.ts b/src/commands/manage/modules/counters/modules/remove/index.ts index 7b35ec4..74caae3 100644 --- a/src/commands/manage/modules/counters/modules/remove/index.ts +++ b/src/commands/manage/modules/counters/modules/remove/index.ts @@ -8,8 +8,8 @@ import { PermissionsBitField, } from "discord.js"; // Configurations -import prisma from "../../../../../../../handlers/database"; -import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; +import prisma from "../../../../../../handlers/database"; +import getEmbedConfig from "../../../../../../helpers/getEmbedData"; // Function export default { diff --git a/src/commands/manage/modules/credits/modules/give/index.ts b/src/commands/manage/modules/credits/modules/give/index.ts index aaf018a..3235c7e 100644 --- a/src/commands/manage/modules/credits/modules/give/index.ts +++ b/src/commands/manage/modules/credits/modules/give/index.ts @@ -5,14 +5,14 @@ import { EmbedBuilder, PermissionsBitField, } from "discord.js"; -import logger from "../../../../../../../middlewares/logger"; +import logger from "../../../../../../middlewares/logger"; // Configurations -import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; +import getEmbedConfig from "../../../../../../helpers/getEmbedData"; // Helpers../../../../../../../helpers/userData -import pluralize from "../../../../../../../helpers/pluralize"; +import pluralize from "../../../../../../helpers/pluralize"; // Models // Handlers -import prisma from "../../../../../../../handlers/database"; +import prisma from "../../../../../../handlers/database"; // Function export default { metadata: { diff --git a/src/commands/manage/modules/credits/modules/giveaway/index.ts b/src/commands/manage/modules/credits/modules/giveaway/index.ts index 93ac561..e32a2ba 100644 --- a/src/commands/manage/modules/credits/modules/giveaway/index.ts +++ b/src/commands/manage/modules/credits/modules/giveaway/index.ts @@ -10,10 +10,10 @@ import { PermissionsBitField, } from "discord.js"; import { v4 as uuidv4 } from "uuid"; -import encryption from "../../../../../../../helpers/encryption"; +import encryption from "../../../../../../helpers/encryption"; // Configurations -import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; -import apiSchema from "../../../../../../../models/api"; +import getEmbedConfig from "../../../../../../helpers/getEmbedData"; +import apiSchema from "../../../../../../models/api"; // Function export default { diff --git a/src/commands/manage/modules/credits/modules/set/index.ts b/src/commands/manage/modules/credits/modules/set/index.ts index 794d7ca..efb700e 100644 --- a/src/commands/manage/modules/credits/modules/set/index.ts +++ b/src/commands/manage/modules/credits/modules/set/index.ts @@ -8,10 +8,10 @@ import { PermissionsBitField, } from "discord.js"; // Configurations -import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; +import getEmbedConfig from "../../../../../../helpers/getEmbedData"; // Handlers -import prisma from "../../../../../../../handlers/database"; -import logger from "../../../../../../../middlewares/logger"; +import prisma from "../../../../../../handlers/database"; +import logger from "../../../../../../middlewares/logger"; // Function export default { diff --git a/src/commands/manage/modules/credits/modules/take/index.ts b/src/commands/manage/modules/credits/modules/take/index.ts index 42516af..9f70b1e 100644 --- a/src/commands/manage/modules/credits/modules/take/index.ts +++ b/src/commands/manage/modules/credits/modules/take/index.ts @@ -7,12 +7,12 @@ import { PermissionsBitField, } from "discord.js"; // Configurations -import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; +import getEmbedConfig from "../../../../../../helpers/getEmbedData"; // Helpers../../../../../../../helpers/userData -import pluralize from "../../../../../../../helpers/pluralize"; +import pluralize from "../../../../../../helpers/pluralize"; // Handlers -import prisma from "../../../../../../../handlers/database"; -import logger from "../../../../../../../middlewares/logger"; +import prisma from "../../../../../../handlers/database"; +import logger from "../../../../../../middlewares/logger"; // Function export default { diff --git a/src/commands/manage/modules/credits/modules/transfer/index.ts b/src/commands/manage/modules/credits/modules/transfer/index.ts index cfe959e..4a8bd40 100644 --- a/src/commands/manage/modules/credits/modules/transfer/index.ts +++ b/src/commands/manage/modules/credits/modules/transfer/index.ts @@ -6,9 +6,9 @@ import { EmbedBuilder, PermissionsBitField, } from "discord.js"; -import transferCredits from "../../../../../../../helpers/transferCredits"; +import transferCredits from "../../../../../../helpers/transferCredits"; // Configurations -import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; +import getEmbedConfig from "../../../../../../helpers/getEmbedData"; // Handlers../../../../../../../helpers/userData // Function diff --git a/src/commands/moderation/modules/prune/index.ts b/src/commands/moderation/modules/prune/index.ts index b5e909e..80251b9 100644 --- a/src/commands/moderation/modules/prune/index.ts +++ b/src/commands/moderation/modules/prune/index.ts @@ -7,7 +7,7 @@ import { PermissionsBitField, } from "discord.js"; // Configurations -import getEmbedConfig from "../../../../../helpers/getEmbedData"; +import getEmbedConfig from "../../../../helpers/getEmbedData"; // Function export default { diff --git a/src/commands/profile/index.ts b/src/commands/profile/index.ts index fb3f287..08e3048 100644 --- a/src/commands/profile/index.ts +++ b/src/commands/profile/index.ts @@ -3,7 +3,7 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction } from "discord.js"; // Modules -import modules from "../../commands/profile/modules"; +import modules from "../commands/profile/modules"; // Handlers diff --git a/src/commands/profile/modules/view/index.ts b/src/commands/profile/modules/view/index.ts index a17ac18..cf4f9b2 100644 --- a/src/commands/profile/modules/view/index.ts +++ b/src/commands/profile/modules/view/index.ts @@ -2,10 +2,10 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { CommandInteraction, EmbedBuilder } from "discord.js"; // Configurations -import getEmbedConfig from "../../../../../helpers/getEmbedData"; +import getEmbedConfig from "../../../../helpers/getEmbedData"; // Models -import fetchUser from "../../../../../helpers/userData"; -import logger from "../../../../../middlewares/logger"; +import fetchUser from "../../../../helpers/userData"; +import logger from "../../../../middlewares/logger"; // Function export default { diff --git a/src/commands/reputation/modules/give/index.ts b/src/commands/reputation/modules/give/index.ts index 33c550a..6229317 100644 --- a/src/commands/reputation/modules/give/index.ts +++ b/src/commands/reputation/modules/give/index.ts @@ -1,11 +1,11 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js"; -import { command as CooldownCommand } from "../../../../../handlers/cooldown"; -import getEmbedConfig from "../../../../../helpers/getEmbedData"; -import logger from "../../../../../middlewares/logger"; +import { command as CooldownCommand } from "../../../../handlers/cooldown"; +import getEmbedConfig from "../../../../helpers/getEmbedData"; +import logger from "../../../../middlewares/logger"; import noSelfReputation from "./components/noSelfReputation"; -import prisma from "../../../../../handlers/database"; +import prisma from "../../../../handlers/database"; export default { metadata: { guildOnly: true, ephemeral: true }, diff --git a/src/commands/shop/modules/cpgg/index.ts b/src/commands/shop/modules/cpgg/index.ts index abe6467..00ec83b 100644 --- a/src/commands/shop/modules/cpgg/index.ts +++ b/src/commands/shop/modules/cpgg/index.ts @@ -9,12 +9,12 @@ import { Message, } from "discord.js"; import { v4 as uuidv4 } from "uuid"; -import encryption from "../../../../../helpers/encryption"; -import getEmbedConfig from "../../../../../helpers/getEmbedData"; -import pluralize from "../../../../../helpers/pluralize"; -import fetchUser from "../../../../../helpers/userData"; -import logger from "../../../../../middlewares/logger"; -import apiSchema from "../../../../../models/api"; +import encryption from "../../../../helpers/encryption"; +import getEmbedConfig from "../../../../helpers/getEmbedData"; +import pluralize from "../../../../helpers/pluralize"; +import fetchUser from "../../../../helpers/userData"; +import logger from "../../../../middlewares/logger"; +import apiSchema from "../../../../models/api"; export default { metadata: { guildOnly: true, ephemeral: true }, diff --git a/src/commands/shop/modules/roles/index.ts b/src/commands/shop/modules/roles/index.ts index fe78d0c..ae87e29 100644 --- a/src/commands/shop/modules/roles/index.ts +++ b/src/commands/shop/modules/roles/index.ts @@ -7,7 +7,7 @@ import { ChatInputCommandInteraction } from "discord.js"; // Modules import modules from "./modules"; -import guildSchema from "../../../../../models/guild"; +import guildSchema from "../../../../models/guild"; export const moduleData = modules; diff --git a/src/commands/shop/modules/roles/modules/buy/index.ts b/src/commands/shop/modules/roles/modules/buy/index.ts index 22ac40f..57c7fbf 100644 --- a/src/commands/shop/modules/roles/modules/buy/index.ts +++ b/src/commands/shop/modules/roles/modules/buy/index.ts @@ -5,16 +5,16 @@ import { ChatInputCommandInteraction, ColorResolvable, EmbedBuilder, - GuildMemberRoleManager + GuildMemberRoleManager, } from "discord.js"; // Configurations -import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; -import pluralize from "../../../../../../../helpers/pluralize"; -import fetchUser from "../../../../../../../helpers/userData"; -import logger from "../../../../../../../middlewares/logger"; +import getEmbedConfig from "../../../../../../helpers/getEmbedData"; +import pluralize from "../../../../../../helpers/pluralize"; +import fetchUser from "../../../../../../helpers/userData"; +import logger from "../../../../../../middlewares/logger"; // Models -import guildSchema from "../../../../../../../models/guild"; -import shopRolesSchema from "../../../../../../../models/shopRole"; +import guildSchema from "../../../../../../models/guild"; +import shopRolesSchema from "../../../../../../models/shopRole"; // Function export default { @@ -111,7 +111,7 @@ export default { }); }) .catch(() => { - throw new Error("Failed creating role.") + throw new Error("Failed creating role."); }); }, }; diff --git a/src/commands/shop/modules/roles/modules/cancel/index.ts b/src/commands/shop/modules/roles/modules/cancel/index.ts index f3064cd..bd2584a 100644 --- a/src/commands/shop/modules/roles/modules/cancel/index.ts +++ b/src/commands/shop/modules/roles/modules/cancel/index.ts @@ -7,12 +7,12 @@ import { GuildMemberRoleManager, } from "discord.js"; // Configurations -import getEmbedConfig from "../../../../../../../helpers/getEmbedData"; -import pluralize from "../../../../../../../helpers/pluralize"; -import fetchUser from "../../../../../../../helpers/userData"; -import logger from "../../../../../../../middlewares/logger"; +import getEmbedConfig from "../../../../../../helpers/getEmbedData"; +import pluralize from "../../../../../../helpers/pluralize"; +import fetchUser from "../../../../../../helpers/userData"; +import logger from "../../../../../../middlewares/logger"; // Models -import shopRolesSchema from "../../../../../../../models/shopRole"; +import shopRolesSchema from "../../../../../../models/shopRole"; // Function export default { diff --git a/src/commands/utility/modules/about/index.ts b/src/commands/utility/modules/about/index.ts index 5dfc051..7265dad 100644 --- a/src/commands/utility/modules/about/index.ts +++ b/src/commands/utility/modules/about/index.ts @@ -8,7 +8,7 @@ import { EmbedBuilder, } from "discord.js"; // Configurations -import getEmbedConfig from "../../../../../helpers/getEmbedData"; +import getEmbedConfig from "../../../../helpers/getEmbedData"; // Function export default { diff --git a/src/commands/utility/modules/avatar/index.ts b/src/commands/utility/modules/avatar/index.ts index 5a935a0..1b87931 100644 --- a/src/commands/utility/modules/avatar/index.ts +++ b/src/commands/utility/modules/avatar/index.ts @@ -1,6 +1,6 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { CommandInteraction, EmbedBuilder } from "discord.js"; -import getEmbedConfig from "../../../../../helpers/getEmbedData"; +import getEmbedConfig from "../../../../helpers/getEmbedData"; export default { metadata: { guildOnly: false, ephemeral: false }, diff --git a/src/commands/utility/modules/ping/index.ts b/src/commands/utility/modules/ping/index.ts index 60b5d3f..1442e03 100644 --- a/src/commands/utility/modules/ping/index.ts +++ b/src/commands/utility/modules/ping/index.ts @@ -2,7 +2,7 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { CommandInteraction, EmbedBuilder } from "discord.js"; // Configurations -import getEmbedConfig from "../../../../../helpers/getEmbedData"; +import getEmbedConfig from "../../../../helpers/getEmbedData"; // Function export default { diff --git a/src/commands/utility/modules/stats/index.ts b/src/commands/utility/modules/stats/index.ts index d552c86..eae22f3 100644 --- a/src/commands/utility/modules/stats/index.ts +++ b/src/commands/utility/modules/stats/index.ts @@ -1,6 +1,6 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { CommandInteraction, EmbedBuilder } from "discord.js"; -import getEmbedConfig from "../../../../../helpers/getEmbedData"; +import getEmbedConfig from "../../../../helpers/getEmbedData"; export default { metadata: { guildOnly: false, ephemeral: false }, diff --git a/src/events/guildCreate/index.ts b/src/events/guildCreate/index.ts index 72eb3c7..7250535 100644 --- a/src/events/guildCreate/index.ts +++ b/src/events/guildCreate/index.ts @@ -1,8 +1,8 @@ import { Guild } from "discord.js"; -import prisma from "../../../handlers/database"; -import updatePresence from "../../../handlers/updatePresence"; -import { IEventOptions } from "../../../interfaces/EventOptions"; -import logger from "../../../middlewares/logger"; +import prisma from "../../handlers/database"; +import updatePresence from "../../handlers/updatePresence"; +import { IEventOptions } from "../../interfaces/EventOptions"; +import logger from "../../middlewares/logger"; export const options: IEventOptions = { type: "on", diff --git a/src/events/guildDelete/index.ts b/src/events/guildDelete/index.ts index 99dff25..3258d70 100644 --- a/src/events/guildDelete/index.ts +++ b/src/events/guildDelete/index.ts @@ -1,9 +1,9 @@ // 3rd party dependencies import { Guild } from "discord.js"; -import prisma from "../../../handlers/database"; -import updatePresence from "../../../handlers/updatePresence"; -import { IEventOptions } from "../../../interfaces/EventOptions"; -import logger from "../../../middlewares/logger"; +import prisma from "../../handlers/database"; +import updatePresence from "../../handlers/updatePresence"; +import { IEventOptions } from "../../interfaces/EventOptions"; +import logger from "../../middlewares/logger"; export const options: IEventOptions = { type: "on", diff --git a/src/events/guildMemberAdd/audits.ts b/src/events/guildMemberAdd/audits.ts index af6290a..697408d 100644 --- a/src/events/guildMemberAdd/audits.ts +++ b/src/events/guildMemberAdd/audits.ts @@ -1,7 +1,7 @@ import { ChannelType, EmbedBuilder, GuildMember } from "discord.js"; -import getEmbedConfig from "../../../helpers/getEmbedData"; -import logger from "../../../middlewares/logger"; -import guildSchema from "../../../models/guild"; +import getEmbedConfig from "../../helpers/getEmbedData"; +import logger from "../../middlewares/logger"; +import guildSchema from "../../models/guild"; export default { execute: async (member: GuildMember) => { diff --git a/src/events/guildMemberAdd/index.ts b/src/events/guildMemberAdd/index.ts index 27a6192..2777b78 100644 --- a/src/events/guildMemberAdd/index.ts +++ b/src/events/guildMemberAdd/index.ts @@ -1,9 +1,9 @@ // 3rd party dependencies import { GuildMember } from "discord.js"; -import prisma from "../../../handlers/database"; -import updatePresence from "../../../handlers/updatePresence"; -import { IEventOptions } from "../../../interfaces/EventOptions"; -import logger from "../../../middlewares/logger"; +import prisma from "../../handlers/database"; +import updatePresence from "../../handlers/updatePresence"; +import { IEventOptions } from "../../interfaces/EventOptions"; +import logger from "../../middlewares/logger"; import audits from "./audits"; import joinMessage from "./joinMessage"; diff --git a/src/events/guildMemberAdd/joinMessage.ts b/src/events/guildMemberAdd/joinMessage.ts index a50dca6..bf97b12 100644 --- a/src/events/guildMemberAdd/joinMessage.ts +++ b/src/events/guildMemberAdd/joinMessage.ts @@ -1,6 +1,6 @@ import { EmbedBuilder, GuildMember, TextChannel } from "discord.js"; -import getEmbedConfig from "../../../helpers/getEmbedData"; -import guildSchema from "../../../models/guild"; +import getEmbedConfig from "../../helpers/getEmbedData"; +import guildSchema from "../../models/guild"; export default { execute: async (member: GuildMember) => { diff --git a/src/events/guildMemberRemove/audits.ts b/src/events/guildMemberRemove/audits.ts index 9f8b3e9..d3967cd 100644 --- a/src/events/guildMemberRemove/audits.ts +++ b/src/events/guildMemberRemove/audits.ts @@ -1,7 +1,7 @@ import { ChannelType, EmbedBuilder, GuildMember } from "discord.js"; -import getEmbedConfig from "../../../helpers/getEmbedData"; -import logger from "../../../middlewares/logger"; -import guildSchema from "../../../models/guild"; +import getEmbedConfig from "../../helpers/getEmbedData"; +import logger from "../../middlewares/logger"; +import guildSchema from "../../models/guild"; export default { execute: async (member: GuildMember) => { diff --git a/src/events/guildMemberRemove/index.ts b/src/events/guildMemberRemove/index.ts index d1a662f..7306b25 100644 --- a/src/events/guildMemberRemove/index.ts +++ b/src/events/guildMemberRemove/index.ts @@ -1,9 +1,9 @@ // 3rd party dependencies import { GuildMember } from "discord.js"; -import prisma from "../../../handlers/database"; -import updatePresence from "../../../handlers/updatePresence"; -import { IEventOptions } from "../../../interfaces/EventOptions"; -import logger from "../../../middlewares/logger"; +import prisma from "../../handlers/database"; +import updatePresence from "../../handlers/updatePresence"; +import { IEventOptions } from "../../interfaces/EventOptions"; +import logger from "../../middlewares/logger"; import audits from "./audits"; import leaveMessage from "./leaveMessage"; diff --git a/src/events/guildMemberRemove/leaveMessage.ts b/src/events/guildMemberRemove/leaveMessage.ts index 7e0cc09..79a2460 100644 --- a/src/events/guildMemberRemove/leaveMessage.ts +++ b/src/events/guildMemberRemove/leaveMessage.ts @@ -1,6 +1,6 @@ import { EmbedBuilder, GuildMember, TextChannel } from "discord.js"; -import getEmbedConfig from "../../../helpers/getEmbedData"; -import guildSchema from "../../../models/guild"; +import getEmbedConfig from "../../helpers/getEmbedData"; +import guildSchema from "../../models/guild"; export default { execute: async (member: GuildMember) => { diff --git a/src/events/interactionCreate/audits.ts b/src/events/interactionCreate/audits.ts index 62ca398..3fc22f3 100644 --- a/src/events/interactionCreate/audits.ts +++ b/src/events/interactionCreate/audits.ts @@ -1,7 +1,7 @@ import { BaseInteraction, ChannelType, EmbedBuilder } from "discord.js"; -import getEmbedConfig from "../../../helpers/getEmbedData"; -import logger from "../../../middlewares/logger"; -import guildSchema from "../../../models/guild"; +import getEmbedConfig from "../../helpers/getEmbedData"; +import logger from "../../middlewares/logger"; +import guildSchema from "../../models/guild"; export default { execute: async (interaction: BaseInteraction) => { diff --git a/src/events/interactionCreate/handlers/button/index.ts b/src/events/interactionCreate/handlers/button/index.ts index 9f5b5b1..e00365e 100644 --- a/src/events/interactionCreate/handlers/button/index.ts +++ b/src/events/interactionCreate/handlers/button/index.ts @@ -1,7 +1,7 @@ // Dependencies import { BaseInteraction } from "discord.js"; -import { button as CooldownButton } from "../../../../../handlers/cooldown"; -import deferReply from "../../../../../handlers/deferReply"; +import { button as CooldownButton } from "../../../../handlers/cooldown"; +import deferReply from "../../../../handlers/deferReply"; export default async (interaction: BaseInteraction) => { if (!interaction.isButton()) return; diff --git a/src/events/interactionCreate/handlers/command/index.ts b/src/events/interactionCreate/handlers/command/index.ts index 9f5169c..db90796 100644 --- a/src/events/interactionCreate/handlers/command/index.ts +++ b/src/events/interactionCreate/handlers/command/index.ts @@ -1,8 +1,8 @@ // Dependencies import { ChatInputCommandInteraction } from "discord.js"; -import { command as CooldownCommand } from "../../../../../handlers/cooldown"; -import deferReply from "../../../../../handlers/deferReply"; -import getCommandMetadata from "../../../../../helpers/getCommandMetadata"; +import { command as CooldownCommand } from "../../../../handlers/cooldown"; +import deferReply from "../../../../handlers/deferReply"; +import getCommandMetadata from "../../../../helpers/getCommandMetadata"; export default async (interaction: ChatInputCommandInteraction) => { if (!interaction.isCommand()) return; diff --git a/src/events/interactionCreate/handlers/index.ts b/src/events/interactionCreate/handlers/index.ts index e12e56a..3adb884 100644 --- a/src/events/interactionCreate/handlers/index.ts +++ b/src/events/interactionCreate/handlers/index.ts @@ -5,8 +5,8 @@ import { CommandInteraction, EmbedBuilder, } from "discord.js"; -import capitalizeFirstLetter from "../../../../helpers/capitalizeFirstLetter"; -import getEmbedConfig from "../../../../helpers/getEmbedData"; +import capitalizeFirstLetter from "../../../helpers/capitalizeFirstLetter"; +import getEmbedConfig from "../../../helpers/getEmbedData"; import button from "./button"; import command from "./command"; diff --git a/src/events/interactionCreate/index.ts b/src/events/interactionCreate/index.ts index 639feed..21fa2ff 100644 --- a/src/events/interactionCreate/index.ts +++ b/src/events/interactionCreate/index.ts @@ -4,8 +4,8 @@ import { CommandInteraction, InteractionType, } from "discord.js"; -import { IEventOptions } from "../../../interfaces/EventOptions"; -import logger from "../../../middlewares/logger"; +import { IEventOptions } from "../../interfaces/EventOptions"; +import logger from "../../middlewares/logger"; // Dependencies import { handleCommandInteraction as HandlersHandleCommandInteraction } from "./handlers"; diff --git a/src/events/messageCreate/index.ts b/src/events/messageCreate/index.ts index 85f9c04..0cacfc8 100644 --- a/src/events/messageCreate/index.ts +++ b/src/events/messageCreate/index.ts @@ -1,6 +1,6 @@ import { Message } from "discord.js"; -import { IEventOptions } from "../../../interfaces/EventOptions"; -import modules from "../../events/messageCreate/modules"; +import { IEventOptions } from "../../interfaces/EventOptions"; +import modules from "./modules"; export const options: IEventOptions = { type: "on", diff --git a/src/events/messageCreate/modules/counters/index.ts b/src/events/messageCreate/modules/counters/index.ts index 98decfe..2fceb28 100644 --- a/src/events/messageCreate/modules/counters/index.ts +++ b/src/events/messageCreate/modules/counters/index.ts @@ -1,6 +1,6 @@ import { ChannelType, Message } from "discord.js"; -import prisma from "../../../../../handlers/database"; -import logger from "../../../../../middlewares/logger"; +import prisma from "../../../../handlers/database"; +import logger from "../../../../middlewares/logger"; export default { execute: async (message: Message) => { diff --git a/src/events/messageCreate/modules/credits/index.ts b/src/events/messageCreate/modules/credits/index.ts index 7037438..2ae1ac8 100644 --- a/src/events/messageCreate/modules/credits/index.ts +++ b/src/events/messageCreate/modules/credits/index.ts @@ -1,7 +1,7 @@ import { ChannelType, Message } from "discord.js"; -import { message as CooldownMessage } from "../../../../../handlers/cooldown"; -import prisma from "../../../../../handlers/database"; -import logger from "../../../../../middlewares/logger"; +import { message as CooldownMessage } from "../../../../handlers/cooldown"; +import prisma from "../../../../handlers/database"; +import logger from "../../../../middlewares/logger"; export default { execute: async (message: Message) => { diff --git a/src/events/messageCreate/modules/points/index.ts b/src/events/messageCreate/modules/points/index.ts index dde559e..583b6fa 100644 --- a/src/events/messageCreate/modules/points/index.ts +++ b/src/events/messageCreate/modules/points/index.ts @@ -1,7 +1,7 @@ import { ChannelType, Message } from "discord.js"; -import { message as CooldownMessage } from "../../../../../handlers/cooldown"; -import prisma from "../../../../../handlers/database"; -import logger from "../../../../../middlewares/logger"; +import { message as CooldownMessage } from "../../../../handlers/cooldown"; +import prisma from "../../../../handlers/database"; +import logger from "../../../../middlewares/logger"; export default { execute: async (message: Message) => { diff --git a/src/events/messageDelete/audits.ts b/src/events/messageDelete/audits.ts index dd4bedc..9bf3ae9 100644 --- a/src/events/messageDelete/audits.ts +++ b/src/events/messageDelete/audits.ts @@ -1,7 +1,7 @@ import { ChannelType, EmbedBuilder, Message } from "discord.js"; -import getEmbedConfig from "../../../helpers/getEmbedData"; -import logger from "../../../middlewares/logger"; -import guildSchema from "../../../models/guild"; +import getEmbedConfig from "../../helpers/getEmbedData"; +import logger from "../../middlewares/logger"; +import guildSchema from "../../models/guild"; export default { execute: async (message: Message) => { diff --git a/src/events/messageDelete/index.ts b/src/events/messageDelete/index.ts index 4b3db23..9e3b973 100644 --- a/src/events/messageDelete/index.ts +++ b/src/events/messageDelete/index.ts @@ -1,6 +1,6 @@ import { Message } from "discord.js"; -import { IEventOptions } from "../../../interfaces/EventOptions"; -import audits from "../../events/messageDelete/audits"; +import { IEventOptions } from "../../interfaces/EventOptions"; +import audits from "./audits"; import counter from "./modules/counter"; export const options: IEventOptions = { diff --git a/src/events/messageDelete/modules/counter.ts b/src/events/messageDelete/modules/counter.ts index ac12127..bbb058c 100644 --- a/src/events/messageDelete/modules/counter.ts +++ b/src/events/messageDelete/modules/counter.ts @@ -1,8 +1,8 @@ // Dependencies import { Message } from "discord.js"; // Models -import prisma from "../../../../handlers/database"; -import logger from "../../../../middlewares/logger"; +import prisma from "../../../handlers/database"; +import logger from "../../../middlewares/logger"; export default async (message: Message) => { const { guild, channel, author, content } = message; diff --git a/src/events/messageUpdate/audits.ts b/src/events/messageUpdate/audits.ts index 263bf5e..ba35962 100644 --- a/src/events/messageUpdate/audits.ts +++ b/src/events/messageUpdate/audits.ts @@ -1,8 +1,8 @@ /* eslint-disable no-loops/no-loops */ import { ChannelType, EmbedBuilder, Message } from "discord.js"; -import getEmbedConfig from "../../../helpers/getEmbedData"; -import logger from "../../../middlewares/logger"; -import guildSchema from "../../../models/guild"; +import getEmbedConfig from "../../helpers/getEmbedData"; +import logger from "../../middlewares/logger"; +import guildSchema from "../../models/guild"; export default { execute: async (oldMessage: Message, newMessage: Message) => { diff --git a/src/events/messageUpdate/index.ts b/src/events/messageUpdate/index.ts index 812a0ba..07f5297 100644 --- a/src/events/messageUpdate/index.ts +++ b/src/events/messageUpdate/index.ts @@ -1,11 +1,11 @@ // Dependencies import { Message } from "discord.js"; -import logger from "../../../middlewares/logger"; +import logger from "../../middlewares/logger"; // Modules import counter from "./modules/counter"; -import { IEventOptions } from "../../../interfaces/EventOptions"; +import { IEventOptions } from "../../interfaces/EventOptions"; import audits from "./audits"; export const options: IEventOptions = { diff --git a/src/events/messageUpdate/modules/counter.ts b/src/events/messageUpdate/modules/counter.ts index f630024..d1586be 100644 --- a/src/events/messageUpdate/modules/counter.ts +++ b/src/events/messageUpdate/modules/counter.ts @@ -1,8 +1,8 @@ // Dependencies import { Message } from "discord.js"; // Models -import prisma from "../../../../handlers/database"; -import logger from "../../../../middlewares/logger"; +import prisma from "../../../handlers/database"; +import logger from "../../../middlewares/logger"; export default async (message: Message) => { const { guild, channel, author, content } = message; diff --git a/src/events/rateLimit/index.ts b/src/events/rateLimit/index.ts index d645ab2..059b855 100644 --- a/src/events/rateLimit/index.ts +++ b/src/events/rateLimit/index.ts @@ -1,8 +1,8 @@ // Dependencies import { Client } from "discord.js"; // Helpers -import { IEventOptions } from "../../../interfaces/EventOptions"; -import logger from "../../../middlewares/logger"; +import { IEventOptions } from "../../interfaces/EventOptions"; +import logger from "../../middlewares/logger"; export const options: IEventOptions = { type: "on", diff --git a/src/events/ready/index.ts b/src/events/ready/index.ts index cf043c1..d292d43 100644 --- a/src/events/ready/index.ts +++ b/src/events/ready/index.ts @@ -1,11 +1,11 @@ // Dependencies import { Client } from "discord.js"; // Helpers -import deployCommands from "../../../handlers/deployCommands"; -import devMode from "../../../handlers/devMode"; -import updatePresence from "../../../handlers/updatePresence"; -import { IEventOptions } from "../../../interfaces/EventOptions"; -import logger from "../../../middlewares/logger"; +import deployCommands from "../../handlers/deployCommands"; +import devMode from "../../handlers/devMode"; +import updatePresence from "../../handlers/updatePresence"; +import { IEventOptions } from "../../interfaces/EventOptions"; +import logger from "../../middlewares/logger"; export const options: IEventOptions = { type: "once", From ea8e3bb1dced16f3f477464b9ba6d839f49bd4b3 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Thu, 20 Oct 2022 10:13:32 +0200 Subject: [PATCH 161/215] =?UTF-8?q?=F0=9F=97=83=EF=B8=8F=20added=20support?= =?UTF-8?q?=20for=20cpgg=20in=20Prisma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20221020081238_cpgg_api/migration.sql | 5 +++ prisma/schema.prisma | 34 +++---------------- 2 files changed, 9 insertions(+), 30 deletions(-) create mode 100644 prisma/migrations/20221020081238_cpgg_api/migration.sql diff --git a/prisma/migrations/20221020081238_cpgg_api/migration.sql b/prisma/migrations/20221020081238_cpgg_api/migration.sql new file mode 100644 index 0000000..cf7293f --- /dev/null +++ b/prisma/migrations/20221020081238_cpgg_api/migration.sql @@ -0,0 +1,5 @@ +-- AlterTable +ALTER TABLE "Guild" ADD COLUMN "apiCpggTokenContent" TEXT; +ALTER TABLE "Guild" ADD COLUMN "apiCpggTokenIv" TEXT; +ALTER TABLE "Guild" ADD COLUMN "apiCpggUrlContent" TEXT; +ALTER TABLE "Guild" ADD COLUMN "apiCpggUrlIv" TEXT; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 0c19c74..16b1622 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -23,36 +23,10 @@ model Guild { embedFooterText String @default("https://github.com/ZynerOrg/xyter") embedFooterIcon String @default("https://github.com/ZynerOrg.png") - // { - // url: { - // iv: { - // type: String, - // required: true, - // unique: false, - // index: true, - // } - // , - // content: { - // type: String, - // required: true, - // unique: false, - // index: true, - // }, - // }, - // token: { - // iv: { - // type: String, - // required: true, - // unique: false, - // index: true, - // }, - // content: { - // type: String, - // required: true, - // unique: false, - // index: true, - // }, - // }, + apiCpggUrlIv String? + apiCpggUrlContent String? + apiCpggTokenIv String? + apiCpggTokenContent String? // Modules creditsEnabled Boolean @default(false) From 98acf7ce573db8595c6e54a193f75e14acf6cd96 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Thu, 20 Oct 2022 10:53:13 +0200 Subject: [PATCH 162/215] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=20fixed=20"wrong"?= =?UTF-8?q?=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migration.sql | 18 ++++++++++++++ .../20221020084922_cooldown_int/migration.sql | 24 +++++++++++++++++++ src/commands/reputation/modules/give/index.ts | 5 +++- src/types/common/environment.d.ts | 4 ++-- 4 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 prisma/migrations/20221020084750_cooldown_string/migration.sql create mode 100644 prisma/migrations/20221020084922_cooldown_int/migration.sql diff --git a/prisma/migrations/20221020084750_cooldown_string/migration.sql b/prisma/migrations/20221020084750_cooldown_string/migration.sql new file mode 100644 index 0000000..24aefc0 --- /dev/null +++ b/prisma/migrations/20221020084750_cooldown_string/migration.sql @@ -0,0 +1,18 @@ +-- RedefineTables +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_Cooldown" ( + "guildId" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "cooldown" TEXT NOT NULL, + "timeoutId" TEXT NOT NULL, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + CONSTRAINT "Cooldown_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, + CONSTRAINT "Cooldown_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE +); +INSERT INTO "new_Cooldown" ("cooldown", "createdAt", "guildId", "timeoutId", "updatedAt", "userId") SELECT "cooldown", "createdAt", "guildId", "timeoutId", "updatedAt", "userId" FROM "Cooldown"; +DROP TABLE "Cooldown"; +ALTER TABLE "new_Cooldown" RENAME TO "Cooldown"; +CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown"("guildId", "userId", "timeoutId"); +PRAGMA foreign_key_check; +PRAGMA foreign_keys=ON; diff --git a/prisma/migrations/20221020084922_cooldown_int/migration.sql b/prisma/migrations/20221020084922_cooldown_int/migration.sql new file mode 100644 index 0000000..51c6d0b --- /dev/null +++ b/prisma/migrations/20221020084922_cooldown_int/migration.sql @@ -0,0 +1,24 @@ +/* + Warnings: + + - You are about to alter the column `cooldown` on the `Cooldown` table. The data in that column could be lost. The data in that column will be cast from `String` to `Int`. + +*/ +-- RedefineTables +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_Cooldown" ( + "guildId" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "cooldown" INTEGER NOT NULL, + "timeoutId" TEXT NOT NULL, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + CONSTRAINT "Cooldown_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, + CONSTRAINT "Cooldown_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE +); +INSERT INTO "new_Cooldown" ("cooldown", "createdAt", "guildId", "timeoutId", "updatedAt", "userId") SELECT "cooldown", "createdAt", "guildId", "timeoutId", "updatedAt", "userId" FROM "Cooldown"; +DROP TABLE "Cooldown"; +ALTER TABLE "new_Cooldown" RENAME TO "Cooldown"; +CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown"("guildId", "userId", "timeoutId"); +PRAGMA foreign_key_check; +PRAGMA foreign_keys=ON; diff --git a/src/commands/reputation/modules/give/index.ts b/src/commands/reputation/modules/give/index.ts index 6229317..6f8c438 100644 --- a/src/commands/reputation/modules/give/index.ts +++ b/src/commands/reputation/modules/give/index.ts @@ -51,7 +51,10 @@ export default { noSelfReputation(optionTarget, user); // Check if user is on cooldown otherwise create one - await CooldownCommand(interaction, process.env.REPUTATION_TIMEOUT); + await CooldownCommand( + interaction, + parseInt(process.env.REPUTATION_TIMEOUT) + ); switch (optionType) { case "positive": { diff --git a/src/types/common/environment.d.ts b/src/types/common/environment.d.ts index bc18671..c4f32e4 100644 --- a/src/types/common/environment.d.ts +++ b/src/types/common/environment.d.ts @@ -7,7 +7,7 @@ declare global { DISCORD_TOKEN: string; DISCORD_CLIENT_ID: Snowflake; DISCORD_GUILD_ID: Snowflake; - DEVELOPMENT_MODE: boolean; + DEVELOPMENT_MODE: string; ENCRYPTION_ALGORITHM: string; ENCRYPTION_SECRET: string; EMBED_COLOR_SUCCESS: ColorResolvable; @@ -16,7 +16,7 @@ declare global { EMBED_FOOTER_TEXT: string; EMBED_FOOTER_ICON: string; LOG_LEVEL: string; - REPUTATION_TIMEOUT: number; + REPUTATION_TIMEOUT: string; BOT_HOSTER_NAME: string; BOT_HOSTER_URL: string; } From b5d20088f1bad7f31d6275bf5937bcf09ff8a2fd Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Thu, 20 Oct 2022 10:54:24 +0200 Subject: [PATCH 163/215] =?UTF-8?q?=E2=9C=A8=20added=20a=20reputation=20vi?= =?UTF-8?q?ew=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/reputation/index.ts | 8 +- src/commands/reputation/modules/index.ts | 3 +- src/commands/reputation/modules/view/index.ts | 84 +++++++++++++++++++ 3 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 src/commands/reputation/modules/view/index.ts diff --git a/src/commands/reputation/index.ts b/src/commands/reputation/index.ts index 3a4fd77..1f1511a 100644 --- a/src/commands/reputation/index.ts +++ b/src/commands/reputation/index.ts @@ -13,10 +13,16 @@ export const moduleData = modules; export const builder = new SlashCommandBuilder() .setName("reputation") .setDescription("Manage reputation.") - .addSubcommand(modules.give.builder); + .addSubcommand(modules.give.builder) + .addSubcommand(modules.view.builder); export const execute = async (interaction: ChatInputCommandInteraction) => { if (interaction.options.getSubcommand() === "give") { await modules.give.execute(interaction); + return; + } + if (interaction.options.getSubcommand() === "view") { + await modules.view.execute(interaction); + return; } }; diff --git a/src/commands/reputation/modules/index.ts b/src/commands/reputation/modules/index.ts index e891cf0..9e1c2a8 100644 --- a/src/commands/reputation/modules/index.ts +++ b/src/commands/reputation/modules/index.ts @@ -1,3 +1,4 @@ import give from "./give"; +import view from "./view"; -export default { give }; +export default { give, view }; diff --git a/src/commands/reputation/modules/view/index.ts b/src/commands/reputation/modules/view/index.ts new file mode 100644 index 0000000..c4ccc41 --- /dev/null +++ b/src/commands/reputation/modules/view/index.ts @@ -0,0 +1,84 @@ +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js"; +import prisma from "../../../../handlers/database"; +import getEmbedConfig from "../../../../helpers/getEmbedData"; +import logger from "../../../../middlewares/logger"; + +export default { + metadata: { guildOnly: true, ephemeral: true }, + + builder: (command: SlashCommandSubcommandBuilder) => { + return command + .setName("view") + .setDescription("View a user's reputation value") + .addUserOption((option) => + option + .setName("target") + .setDescription("The user you want to check.") + .setRequired(true) + ); + }, + execute: async (interaction: ChatInputCommandInteraction) => { + const { options, user, guild } = interaction; + + const { successColor, footerText, footerIcon } = await getEmbedConfig( + guild + ); + + const optionTarget = options?.getUser("target"); + + if (!guild) throw new Error("Guild is undefined"); + if (!optionTarget) throw new Error("Target is not defined"); + + const createGuildMember = await prisma.guildMember.upsert({ + where: { + userId_guildId: { + userId: optionTarget.id, + guildId: guild.id, + }, + }, + update: {}, + create: { + user: { + connectOrCreate: { + create: { + id: optionTarget.id, + }, + where: { + id: optionTarget.id, + }, + }, + }, + guild: { + connectOrCreate: { + create: { + id: guild.id, + }, + where: { + id: guild.id, + }, + }, + }, + }, + include: { + user: true, + guild: true, + }, + }); + + logger.silly(createGuildMember); + + const interactionEmbed = new EmbedBuilder() + .setTitle("[:loudspeaker:] View") + .setDescription( + `${optionTarget} has ${createGuildMember.user.reputationsEarned}.` + ) + .setTimestamp() + .setColor(successColor) + .setFooter({ text: footerText, iconURL: footerIcon }); + + await interaction.editReply({ + embeds: [interactionEmbed], + }); + }, +}; From 051d122729f6eaad5e73a35181db9cdd7825d5a2 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Thu, 20 Oct 2022 11:00:36 +0200 Subject: [PATCH 164/215] =?UTF-8?q?=F0=9F=9A=9A=20correct=20path=20for=20r?= =?UTF-8?q?egisters?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/handlers/command/index.ts | 8 +++----- src/handlers/event/index.ts | 8 ++++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/handlers/command/index.ts b/src/handlers/command/index.ts index 1816c8f..865c349 100644 --- a/src/handlers/command/index.ts +++ b/src/handlers/command/index.ts @@ -5,7 +5,7 @@ import logger from "../../middlewares/logger"; export const register = async (client: Client) => { // Get name of directories containing commands - const commandNames = await listDir("plugins/commands"); + const commandNames = await listDir("commands"); if (!commandNames) throw new Error("📦 No commands available"); const amountOfCommands = commandNames.length; @@ -13,10 +13,8 @@ export const register = async (client: Client) => { logger.info(`📦 Trying to load ${amountOfCommands} commands`); const importCommand = async (commandName: string) => { - // Import command from plugins/commands - const command: ICommand = await import( - `../../plugins/commands/${commandName}` - ); + // Import command from commands + const command: ICommand = await import(`../../commands/${commandName}`); if (!command) throw new Error(`📦 No command found while importing "${commandName}"`); if (!command.builder) diff --git a/src/handlers/event/index.ts b/src/handlers/event/index.ts index cf44860..4d0fabc 100644 --- a/src/handlers/event/index.ts +++ b/src/handlers/event/index.ts @@ -6,7 +6,7 @@ import logger from "../../middlewares/logger"; // Registers all available events export const register = async (client: Client) => { - const eventNames = await listDir("plugins/events"); + const eventNames = await listDir("events"); if (!eventNames) throw new Error("📦 No events available"); const amountOfEvents = eventNames.length; @@ -14,8 +14,8 @@ export const register = async (client: Client) => { logger.info(`📦 Trying to load ${amountOfEvents} events`); const importEvent = async (eventName: string) => { - // Import event from plugins/events - const event: IEvent = await import(`../../plugins/events/${eventName}`); + // Import event from events + const event: IEvent = await import(`../../events/${eventName}`); if (!event) throw new Error(`📦 No event found while importing "${eventName}"`); if (!event.options) @@ -76,7 +76,7 @@ export const register = async (client: Client) => { }); // for await (const eventName of eventNames) { - // const event: IEvent = await import(`../../plugins/events/${eventName}`); + // const event: IEvent = await import(`../../events/${eventName}`); // const eventExecutor = async (...args: Promise[]) => // event.execute(...args).catch(async (err) => { // logger.error(`${err}`); From 4c92867bcf494bad18dc7f6da13a84810d0e0339 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Thu, 20 Oct 2022 11:01:01 +0200 Subject: [PATCH 165/215] =?UTF-8?q?=F0=9F=9A=9A=20correct=20more=20paths?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/counters/index.ts | 2 +- src/commands/fun/index.ts | 2 +- src/commands/manage/index.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/commands/counters/index.ts b/src/commands/counters/index.ts index b9c9fb3..e70e460 100644 --- a/src/commands/counters/index.ts +++ b/src/commands/counters/index.ts @@ -1,7 +1,7 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction } from "discord.js"; -import modules from "../commands/counters/modules"; +import modules from "./modules"; export const builder = new SlashCommandBuilder() .setName("counters") diff --git a/src/commands/fun/index.ts b/src/commands/fun/index.ts index ccd275a..8c166f0 100644 --- a/src/commands/fun/index.ts +++ b/src/commands/fun/index.ts @@ -2,7 +2,7 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction } from "discord.js"; import logger from "../../middlewares/logger"; -import modules from "../commands/fun/modules"; +import modules from "./modules"; export const builder = new SlashCommandBuilder() .setName("fun") diff --git a/src/commands/manage/index.ts b/src/commands/manage/index.ts index e09f024..d488bd1 100644 --- a/src/commands/manage/index.ts +++ b/src/commands/manage/index.ts @@ -3,7 +3,7 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction } from "discord.js"; // Groups -import modules from "../commands/manage/modules"; +import modules from "./modules"; export const moduleData = modules; From 63da5b165c5291f69fc4252db2bb9c1c9aacfb20 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Thu, 20 Oct 2022 11:01:12 +0200 Subject: [PATCH 166/215] =?UTF-8?q?=F0=9F=9A=A7=20comment=20out=20profile?= =?UTF-8?q?=20during=20migration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/profile/index.ts | 2 +- src/commands/profile/modules/view/index.ts | 115 ++++++++++----------- 2 files changed, 54 insertions(+), 63 deletions(-) diff --git a/src/commands/profile/index.ts b/src/commands/profile/index.ts index 08e3048..dc24a42 100644 --- a/src/commands/profile/index.ts +++ b/src/commands/profile/index.ts @@ -3,7 +3,7 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction } from "discord.js"; // Modules -import modules from "../commands/profile/modules"; +import modules from "./modules"; // Handlers diff --git a/src/commands/profile/modules/view/index.ts b/src/commands/profile/modules/view/index.ts index cf4f9b2..e0abb27 100644 --- a/src/commands/profile/modules/view/index.ts +++ b/src/commands/profile/modules/view/index.ts @@ -1,11 +1,8 @@ // Dependencies import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import { CommandInteraction, EmbedBuilder } from "discord.js"; +import { CommandInteraction } from "discord.js"; // Configurations -import getEmbedConfig from "../../../../helpers/getEmbedData"; // Models -import fetchUser from "../../../../helpers/userData"; -import logger from "../../../../middlewares/logger"; // Function export default { @@ -21,63 +18,57 @@ export default { }, execute: async (interaction: CommandInteraction) => { - const { errorColor, footerText, footerIcon } = await getEmbedConfig( - interaction.guild - ); // Destructure - const { client, options, user, guild } = interaction; - - // Target information - const target = options?.getUser("target"); - - // Discord User Information - const discordUser = await client?.users?.fetch( - `${target ? target?.id : user?.id}` - ); - - if (guild === null) { - return logger?.silly(`Guild is null`); - } - - // User Information - const userObj = await fetchUser(discordUser, guild); - - const embed = new EmbedBuilder() - .setAuthor({ - name: `${discordUser?.username}#${discordUser?.discriminator}`, - iconURL: discordUser?.displayAvatarURL(), - }) - .addFields( - { - name: `:dollar: Credits`, - value: `${userObj?.credits || "Not found"}`, - inline: true, - }, - { - name: `:squeeze_bottle: Level`, - value: `${userObj?.level || "Not found"}`, - inline: true, - }, - { - name: `:squeeze_bottle: Points`, - value: `${userObj?.points || "Not found"}`, - inline: true, - }, - { - name: `:loudspeaker: Reputation`, - value: `${userObj?.reputation || "Not found"}`, - inline: true, - }, - { - name: `:rainbow_flag: Language`, - value: `${userObj?.language || "Not found"}`, - inline: true, - } - ) - .setTimestamp() - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }); - - // Return interaction reply - return interaction?.editReply({ embeds: [embed] }); + // const { errorColor, footerText, footerIcon } = await getEmbedConfig( + // interaction.guild + // ); // Destructure + // const { client, options, user, guild } = interaction; + // // Target information + // const target = options?.getUser("target"); + // // Discord User Information + // const discordUser = await client?.users?.fetch( + // `${target ? target?.id : user?.id}` + // ); + // if (guild === null) { + // return logger?.silly(`Guild is null`); + // } + // // User Information + // const userObj = await fetchUser(discordUser, guild); + // const embed = new EmbedBuilder() + // .setAuthor({ + // name: `${discordUser?.username}#${discordUser?.discriminator}`, + // iconURL: discordUser?.displayAvatarURL(), + // }) + // .addFields( + // { + // name: `:dollar: Credits`, + // value: `${userObj?.credits || "Not found"}`, + // inline: true, + // }, + // { + // name: `:squeeze_bottle: Level`, + // value: `${userObj?.level || "Not found"}`, + // inline: true, + // }, + // { + // name: `:squeeze_bottle: Points`, + // value: `${userObj?.points || "Not found"}`, + // inline: true, + // }, + // { + // name: `:loudspeaker: Reputation`, + // value: `${userObj?.reputation || "Not found"}`, + // inline: true, + // }, + // { + // name: `:rainbow_flag: Language`, + // value: `${userObj?.language || "Not found"}`, + // inline: true, + // } + // ) + // .setTimestamp() + // .setColor(errorColor) + // .setFooter({ text: footerText, iconURL: footerIcon }); + // // Return interaction reply + // return interaction?.editReply({ embeds: [embed] }); }, }; From a94850f782d7f87054aad6694f61bc8f4ec4b0fd Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Thu, 20 Oct 2022 11:01:25 +0200 Subject: [PATCH 167/215] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20migrate=20/config?= =?UTF-8?q?=20cpgg=20to=20Prisma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/config/modules/cpgg/index.ts | 67 ++++++++++++++--------- 1 file changed, 42 insertions(+), 25 deletions(-) diff --git a/src/commands/config/modules/cpgg/index.ts b/src/commands/config/modules/cpgg/index.ts index 4dd1bef..01d13ed 100644 --- a/src/commands/config/modules/cpgg/index.ts +++ b/src/commands/config/modules/cpgg/index.ts @@ -4,10 +4,10 @@ import { EmbedBuilder, PermissionsBitField, } from "discord.js"; +import prisma from "../../../../handlers/database"; import encryption from "../../../../helpers/encryption"; import getEmbedConfig from "../../../../helpers/getEmbedData"; import logger from "../../../../middlewares/logger"; -import apiSchema from "../../../../models/api"; export default { metadata: { @@ -55,35 +55,52 @@ export default { const token = tokenData && encryption.encrypt(tokenData); const url = scheme && domain && encryption.encrypt(`${scheme}://${domain}`); - await apiSchema - ?.findOneAndUpdate( - { guildId: guild?.id }, - { url, token }, - { new: true, upsert: true } - ) - .then(async () => { - logger?.silly(`Updated API credentials.`); + if (!guild) throw new Error("No guild found"); + if (!token) throw new Error("Token not found"); + if (!url) throw new Error("URL not found"); - const interactionEmbed = new EmbedBuilder() - .setTitle("[:tools:] CPGG") - .setDescription( - `The following configuration will be used. + const createGuild = await prisma.guild.upsert({ + where: { + id: guild.id, + }, + update: { + apiCpggTokenIv: token.iv, + apiCpggTokenContent: token.content, + apiCpggUrlIv: url.iv, + apiCpggUrlContent: url.content, + }, + create: { + id: guild.id, + apiCpggTokenIv: token.iv, + apiCpggTokenContent: token.content, + apiCpggUrlIv: url.iv, + apiCpggUrlContent: url.content, + }, + }); + + logger.silly(createGuild); + + logger?.silly(`Updated API credentials.`); + + const interactionEmbed = new EmbedBuilder() + .setTitle("[:tools:] CPGG") + .setDescription( + `The following configuration will be used. **Scheme**: ${scheme} **Domain**: ${domain} **Token**: ends with ${tokenData?.slice(-4)}` - ) - .setColor(successColor) - .setTimestamp() - .setFooter({ - iconURL: footerIcon, - text: footerText, - }); - - await interaction?.editReply({ - embeds: [interactionEmbed], - }); - return; + ) + .setColor(successColor) + .setTimestamp() + .setFooter({ + iconURL: footerIcon, + text: footerText, }); + + await interaction?.editReply({ + embeds: [interactionEmbed], + }); + return; }, }; From 094d40104a1a0673ad2e777de8bc6ef4c60d46cf Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Thu, 20 Oct 2022 11:01:46 +0200 Subject: [PATCH 168/215] =?UTF-8?q?=F0=9F=9A=A7=20Comment=20out=20shop=20m?= =?UTF-8?q?odule=20during=20migration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/shop/modules/cpgg/index.ts | 351 ++++++++---------- .../shop/modules/roles/modules/buy/index.ts | 149 ++++---- .../modules/roles/modules/cancel/index.ts | 102 +++-- 3 files changed, 255 insertions(+), 347 deletions(-) diff --git a/src/commands/shop/modules/cpgg/index.ts b/src/commands/shop/modules/cpgg/index.ts index 00ec83b..e7cdef5 100644 --- a/src/commands/shop/modules/cpgg/index.ts +++ b/src/commands/shop/modules/cpgg/index.ts @@ -1,20 +1,6 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import axios from "axios"; -import { - ActionRowBuilder, - ButtonBuilder, - ButtonStyle, - ChatInputCommandInteraction, - EmbedBuilder, - Message, -} from "discord.js"; -import { v4 as uuidv4 } from "uuid"; -import encryption from "../../../../helpers/encryption"; -import getEmbedConfig from "../../../../helpers/getEmbedData"; -import pluralize from "../../../../helpers/pluralize"; -import fetchUser from "../../../../helpers/userData"; -import logger from "../../../../middlewares/logger"; -import apiSchema from "../../../../models/api"; +import { ChatInputCommandInteraction } from "discord.js"; +// import fetchUser from "../../../../helpers/userData"; export default { metadata: { guildOnly: true, ephemeral: true }, @@ -31,189 +17,154 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { - const { errorColor, successColor, footerText, footerIcon } = - await getEmbedConfig(interaction.guild); - const { options, guild, user, client } = interaction; - - const optionAmount = options?.getInteger("amount"); - - if (optionAmount === null) { - logger?.silly(`Amount is null.`); - - const interactionEmbed = new EmbedBuilder() - .setTitle("[:dollar:] Gift") - .setDescription("We could not read your requested amount.") - .setTimestamp() - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }); - - return interaction?.editReply({ - embeds: [interactionEmbed], - }); - } - - if (guild === null) { - return logger?.silly(`Guild is null`); - } - - const userDB = await fetchUser(user, guild); - - if (userDB === null) { - return logger?.silly(`User is null`); - } - - const dmUser = client?.users?.cache?.get(user?.id); - - if ((optionAmount || userDB?.credits) < 100) { - logger?.silly(`Amount or user credits is below 100.`); - - const interactionEmbed = new EmbedBuilder() - .setTitle("[:shopping_cart:] CPGG") - .setDescription("You **can't** withdraw for __CPGG__ below **100**.") - .setTimestamp() - .addFields({ - name: "Your balance", - value: `${pluralize(userDB?.credits, "credit")}`, - }) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }); - - return interaction?.editReply({ - embeds: [interactionEmbed], - }); - } - - if ((optionAmount || userDB?.credits) > 1000000) { - logger?.silly(`Amount or user credits is above 1.000.000.`); - - const interactionEmbed = new EmbedBuilder() - .setTitle("[:shopping_cart:] CPGG") - .setDescription( - "You **can't** withdraw for __CPGG__ above **1.000.000**." - ) - .setTimestamp() - .addFields({ - name: "Your balance", - value: `${pluralize(userDB?.credits, "credit")}`, - }) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }); - - return interaction?.editReply({ - embeds: [interactionEmbed], - }); - } - - if (userDB?.credits < optionAmount) { - logger?.silly(`User credits is below amount.`); - - const interactionEmbed = new EmbedBuilder() - .setTitle("[:shopping_cart:] CPGG") - .setDescription("You have **insufficient** credits.") - .setTimestamp() - .addFields({ - name: "Your balance", - value: `${pluralize(userDB?.credits, "credit")}`, - }) - .setColor(errorColor) - .setFooter({ text: footerText, iconURL: footerIcon }); - - return interaction?.editReply({ - embeds: [interactionEmbed], - }); - } - - const code = uuidv4(); - - const apiCredentials = await apiSchema?.findOne({ - guildId: guild?.id, - }); - - if (!apiCredentials) return; - const url = encryption.decrypt(apiCredentials?.url); - - const api = axios?.create({ - baseURL: `${url}/api/`, - headers: { - Authorization: `Bearer ${encryption.decrypt(apiCredentials.token)}`, - }, - }); - - const shopUrl = `${url}/store`; - - const buttons = new ActionRowBuilder().addComponents( - new ButtonBuilder() - .setLabel("Redeem it here") - .setStyle(ButtonStyle.Link) - .setEmoji("🏦") - .setURL(`${shopUrl}?voucher=${code}`) - ); - - await api - - ?.post("vouchers", { - uses: 1, - code, - credits: optionAmount || userDB?.credits, - memo: `${interaction?.createdTimestamp} - ${interaction?.user?.id}`, - }) - - ?.then(async () => { - logger?.silly(`Successfully created voucher.`); - - userDB.credits -= optionAmount || userDB?.credits; - - await userDB - ?.save() - - ?.then(async () => { - logger?.silly(`Successfully saved new credits.`); - - if (!interaction.guild) throw new Error("Guild is undefined"); - - const dmEmbed = new EmbedBuilder() - .setTitle("[:shopping_cart:] CPGG") - .setDescription( - `This voucher comes from **${interaction.guild.name}**.` - ) - .setTimestamp() - .addFields({ - name: "💶 Credits", - value: `${optionAmount || userDB?.credits}`, - inline: true, - }) - .setColor(successColor) - .setFooter({ text: footerText, iconURL: footerIcon }); - - await dmUser - ?.send({ - embeds: [dmEmbed], - components: [buttons], - }) - .then(async (msg: Message) => { - const interactionEmbed = new EmbedBuilder() - .setTitle("[:shopping_cart:] CPGG") - .setDescription( - `I have sent you the code in [DM](${msg.url})!` - ) - .setTimestamp() - .setColor(successColor) - .setFooter({ text: footerText, iconURL: footerIcon }); - - await interaction?.editReply({ - embeds: [interactionEmbed], - }); - return; - }); - }) - - .catch(() => { - throw new Error("Failed to update credits for user."); - }); - }) - - .catch(() => { - throw new Error("Failed generating an voucher."); - }); + // const { errorColor, successColor, footerText, footerIcon } = + // await getEmbedConfig(interaction.guild); + // const { options, guild, user, client } = interaction; + // const optionAmount = options?.getInteger("amount"); + // if (optionAmount === null) { + // logger?.silly(`Amount is null.`); + // const interactionEmbed = new EmbedBuilder() + // .setTitle("[:dollar:] Gift") + // .setDescription("We could not read your requested amount.") + // .setTimestamp() + // .setColor(errorColor) + // .setFooter({ text: footerText, iconURL: footerIcon }); + // return interaction?.editReply({ + // embeds: [interactionEmbed], + // }); + // } + // if (guild === null) { + // return logger?.silly(`Guild is null`); + // } + // const userDB = await fetchUser(user, guild); + // if (userDB === null) { + // return logger?.silly(`User is null`); + // } + // const dmUser = client?.users?.cache?.get(user?.id); + // if ((optionAmount || userDB?.credits) < 100) { + // logger?.silly(`Amount or user credits is below 100.`); + // const interactionEmbed = new EmbedBuilder() + // .setTitle("[:shopping_cart:] CPGG") + // .setDescription("You **can't** withdraw for __CPGG__ below **100**.") + // .setTimestamp() + // .addFields({ + // name: "Your balance", + // value: `${pluralize(userDB?.credits, "credit")}`, + // }) + // .setColor(errorColor) + // .setFooter({ text: footerText, iconURL: footerIcon }); + // return interaction?.editReply({ + // embeds: [interactionEmbed], + // }); + // } + // if ((optionAmount || userDB?.credits) > 1000000) { + // logger?.silly(`Amount or user credits is above 1.000.000.`); + // const interactionEmbed = new EmbedBuilder() + // .setTitle("[:shopping_cart:] CPGG") + // .setDescription( + // "You **can't** withdraw for __CPGG__ above **1.000.000**." + // ) + // .setTimestamp() + // .addFields({ + // name: "Your balance", + // value: `${pluralize(userDB?.credits, "credit")}`, + // }) + // .setColor(errorColor) + // .setFooter({ text: footerText, iconURL: footerIcon }); + // return interaction?.editReply({ + // embeds: [interactionEmbed], + // }); + // } + // if (userDB?.credits < optionAmount) { + // logger?.silly(`User credits is below amount.`); + // const interactionEmbed = new EmbedBuilder() + // .setTitle("[:shopping_cart:] CPGG") + // .setDescription("You have **insufficient** credits.") + // .setTimestamp() + // .addFields({ + // name: "Your balance", + // value: `${pluralize(userDB?.credits, "credit")}`, + // }) + // .setColor(errorColor) + // .setFooter({ text: footerText, iconURL: footerIcon }); + // return interaction?.editReply({ + // embeds: [interactionEmbed], + // }); + // } + // const code = uuidv4(); + // const apiCredentials = await apiSchema?.findOne({ + // guildId: guild?.id, + // }); + // if (!apiCredentials) return; + // const url = encryption.decrypt(apiCredentials?.url); + // const api = axios?.create({ + // baseURL: `${url}/api/`, + // headers: { + // Authorization: `Bearer ${encryption.decrypt(apiCredentials.token)}`, + // }, + // }); + // const shopUrl = `${url}/store`; + // const buttons = new ActionRowBuilder().addComponents( + // new ButtonBuilder() + // .setLabel("Redeem it here") + // .setStyle(ButtonStyle.Link) + // .setEmoji("🏦") + // .setURL(`${shopUrl}?voucher=${code}`) + // ); + // await api + // ?.post("vouchers", { + // uses: 1, + // code, + // credits: optionAmount || userDB?.credits, + // memo: `${interaction?.createdTimestamp} - ${interaction?.user?.id}`, + // }) + // ?.then(async () => { + // logger?.silly(`Successfully created voucher.`); + // userDB.credits -= optionAmount || userDB?.credits; + // await userDB + // ?.save() + // ?.then(async () => { + // logger?.silly(`Successfully saved new credits.`); + // if (!interaction.guild) throw new Error("Guild is undefined"); + // const dmEmbed = new EmbedBuilder() + // .setTitle("[:shopping_cart:] CPGG") + // .setDescription( + // `This voucher comes from **${interaction.guild.name}**.` + // ) + // .setTimestamp() + // .addFields({ + // name: "💶 Credits", + // value: `${optionAmount || userDB?.credits}`, + // inline: true, + // }) + // .setColor(successColor) + // .setFooter({ text: footerText, iconURL: footerIcon }); + // await dmUser + // ?.send({ + // embeds: [dmEmbed], + // components: [buttons], + // }) + // .then(async (msg: Message) => { + // const interactionEmbed = new EmbedBuilder() + // .setTitle("[:shopping_cart:] CPGG") + // .setDescription( + // `I have sent you the code in [DM](${msg.url})!` + // ) + // .setTimestamp() + // .setColor(successColor) + // .setFooter({ text: footerText, iconURL: footerIcon }); + // await interaction?.editReply({ + // embeds: [interactionEmbed], + // }); + // return; + // }); + // }) + // .catch(() => { + // throw new Error("Failed to update credits for user."); + // }); + // }) + // .catch(() => { + // throw new Error("Failed generating an voucher."); + // }); }, }; diff --git a/src/commands/shop/modules/roles/modules/buy/index.ts b/src/commands/shop/modules/roles/modules/buy/index.ts index 57c7fbf..f776e2c 100644 --- a/src/commands/shop/modules/roles/modules/buy/index.ts +++ b/src/commands/shop/modules/roles/modules/buy/index.ts @@ -1,20 +1,10 @@ // Dependencies // Helpers import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import { - ChatInputCommandInteraction, - ColorResolvable, - EmbedBuilder, - GuildMemberRoleManager, -} from "discord.js"; +import { ChatInputCommandInteraction } from "discord.js"; // Configurations -import getEmbedConfig from "../../../../../../helpers/getEmbedData"; -import pluralize from "../../../../../../helpers/pluralize"; -import fetchUser from "../../../../../../helpers/userData"; -import logger from "../../../../../../middlewares/logger"; +// import fetchUser from "../../../../../../helpers/userData"; // Models -import guildSchema from "../../../../../../models/guild"; -import shopRolesSchema from "../../../../../../models/shopRole"; // Function export default { @@ -38,80 +28,65 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { - const { successColor, footerText, footerIcon } = await getEmbedConfig( - interaction.guild - ); - const { options, guild, user, member } = interaction; - - const optionName = options?.getString("name"); - const optionColor = options?.getString("color"); - - // If amount is null - if (optionName === null) - throw new Error("We could not read your requested name"); - - await guild?.roles - .create({ - name: optionName, - color: optionColor as ColorResolvable, - reason: `${user?.id} bought from shop`, - }) - .then(async (role) => { - // Get guild object - const guildDB = await guildSchema?.findOne({ - guildId: guild?.id, - }); - - const userDB = await fetchUser(user, guild); - - if (userDB === null) { - return logger?.silly(`User is null`); - } - - if (guildDB === null) { - return logger?.silly(`Guild is null`); - } - - if (guildDB.shop === null) { - return logger?.silly(`Shop is null`); - } - - const { pricePerHour } = guildDB.shop.roles; - - userDB.credits -= pricePerHour; - - await userDB?.save(); - - await shopRolesSchema?.create({ - roleId: role?.id, - userId: user?.id, - guildId: guild?.id, - pricePerHour, - lastPayed: new Date(), - }); - - await (member?.roles as GuildMemberRoleManager)?.add(role?.id); - - logger?.silly(`Role ${role?.name} was bought by ${user?.tag}`); - - const interactionEmbed = new EmbedBuilder() - .setTitle("[:shopping_cart:] Buy") - .setDescription( - `You bought **${optionName}** for **${pluralize( - pricePerHour, - "credit" - )}**.` - ) - .setTimestamp() - .setColor(successColor) - .setFooter({ text: footerText, iconURL: footerIcon }); - - return interaction?.editReply({ - embeds: [interactionEmbed], - }); - }) - .catch(() => { - throw new Error("Failed creating role."); - }); + // const { successColor, footerText, footerIcon } = await getEmbedConfig( + // interaction.guild + // ); + // const { options, guild, user, member } = interaction; + // const optionName = options?.getString("name"); + // const optionColor = options?.getString("color"); + // // If amount is null + // if (optionName === null) + // throw new Error("We could not read your requested name"); + // await guild?.roles + // .create({ + // name: optionName, + // color: optionColor as ColorResolvable, + // reason: `${user?.id} bought from shop`, + // }) + // .then(async (role) => { + // // Get guild object + // const guildDB = await guildSchema?.findOne({ + // guildId: guild?.id, + // }); + // const userDB = await fetchUser(user, guild); + // if (userDB === null) { + // return logger?.silly(`User is null`); + // } + // if (guildDB === null) { + // return logger?.silly(`Guild is null`); + // } + // if (guildDB.shop === null) { + // return logger?.silly(`Shop is null`); + // } + // const { pricePerHour } = guildDB.shop.roles; + // userDB.credits -= pricePerHour; + // await userDB?.save(); + // await shopRolesSchema?.create({ + // roleId: role?.id, + // userId: user?.id, + // guildId: guild?.id, + // pricePerHour, + // lastPayed: new Date(), + // }); + // await (member?.roles as GuildMemberRoleManager)?.add(role?.id); + // logger?.silly(`Role ${role?.name} was bought by ${user?.tag}`); + // const interactionEmbed = new EmbedBuilder() + // .setTitle("[:shopping_cart:] Buy") + // .setDescription( + // `You bought **${optionName}** for **${pluralize( + // pricePerHour, + // "credit" + // )}**.` + // ) + // .setTimestamp() + // .setColor(successColor) + // .setFooter({ text: footerText, iconURL: footerIcon }); + // return interaction?.editReply({ + // embeds: [interactionEmbed], + // }); + // }) + // .catch(() => { + // throw new Error("Failed creating role."); + // }); }, }; diff --git a/src/commands/shop/modules/roles/modules/cancel/index.ts b/src/commands/shop/modules/roles/modules/cancel/index.ts index bd2584a..4d0cfc9 100644 --- a/src/commands/shop/modules/roles/modules/cancel/index.ts +++ b/src/commands/shop/modules/roles/modules/cancel/index.ts @@ -1,18 +1,10 @@ // Dependencies // Helpers import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import { - ChatInputCommandInteraction, - EmbedBuilder, - GuildMemberRoleManager, -} from "discord.js"; +import { ChatInputCommandInteraction } from "discord.js"; // Configurations -import getEmbedConfig from "../../../../../../helpers/getEmbedData"; -import pluralize from "../../../../../../helpers/pluralize"; -import fetchUser from "../../../../../../helpers/userData"; -import logger from "../../../../../../middlewares/logger"; +// import fetchUser from "../../../../../../helpers/userData"; // Models -import shopRolesSchema from "../../../../../../models/shopRole"; // Function export default { @@ -30,55 +22,45 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { - const { successColor, footerText, footerIcon } = await getEmbedConfig( - interaction.guild - ); - const { options, guild, user, member } = interaction; - - const optionRole = options.getRole("role"); - - if (optionRole === null) - throw new Error("We could not read your requested role."); - - const roleExist = await shopRolesSchema?.findOne({ - guildId: guild?.id, - userId: user?.id, - roleId: optionRole?.id, - }); - - if (roleExist === null) return; - - await (member?.roles as GuildMemberRoleManager)?.remove(optionRole?.id); - - await guild?.roles - .delete(optionRole?.id, `${user?.id} canceled from shop`) - .then(async () => { - const userDB = await fetchUser(user, guild); - - if (userDB === null) { - return logger?.silly(`User is null`); - } - - await shopRolesSchema?.deleteOne({ - roleId: optionRole?.id, - userId: user?.id, - guildId: guild?.id, - }); - - const interactionEmbed = new EmbedBuilder() - .setTitle("[:shopping_cart:] Cancel") - .setDescription(`You have canceled ${optionRole.name}.`) - .setTimestamp() - .setColor(successColor) - .addFields({ - name: "Your balance", - value: `${pluralize(userDB?.credits, "credit")}`, - }) - .setFooter({ text: footerText, iconURL: footerIcon }); - - return interaction?.editReply({ - embeds: [interactionEmbed], - }); - }); + // const { successColor, footerText, footerIcon } = await getEmbedConfig( + // interaction.guild + // ); + // const { options, guild, user, member } = interaction; + // const optionRole = options.getRole("role"); + // if (optionRole === null) + // throw new Error("We could not read your requested role."); + // const roleExist = await shopRolesSchema?.findOne({ + // guildId: guild?.id, + // userId: user?.id, + // roleId: optionRole?.id, + // }); + // if (roleExist === null) return; + // await (member?.roles as GuildMemberRoleManager)?.remove(optionRole?.id); + // await guild?.roles + // .delete(optionRole?.id, `${user?.id} canceled from shop`) + // .then(async () => { + // const userDB = await fetchUser(user, guild); + // if (userDB === null) { + // return logger?.silly(`User is null`); + // } + // await shopRolesSchema?.deleteOne({ + // roleId: optionRole?.id, + // userId: user?.id, + // guildId: guild?.id, + // }); + // const interactionEmbed = new EmbedBuilder() + // .setTitle("[:shopping_cart:] Cancel") + // .setDescription(`You have canceled ${optionRole.name}.`) + // .setTimestamp() + // .setColor(successColor) + // .addFields({ + // name: "Your balance", + // value: `${pluralize(userDB?.credits, "credit")}`, + // }) + // .setFooter({ text: footerText, iconURL: footerIcon }); + // return interaction?.editReply({ + // embeds: [interactionEmbed], + // }); + // }); }, }; From f412ad6fae1212a4ac5b13ce570108cb31b0cc48 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Thu, 20 Oct 2022 12:48:40 +0200 Subject: [PATCH 169/215] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Fixed=20/shop=20cp?= =?UTF-8?q?gg=20to=20Prisma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/shop/modules/cpgg/index.ts | 326 +++++++++++++----------- 1 file changed, 175 insertions(+), 151 deletions(-) diff --git a/src/commands/shop/modules/cpgg/index.ts b/src/commands/shop/modules/cpgg/index.ts index e7cdef5..f7df0a4 100644 --- a/src/commands/shop/modules/cpgg/index.ts +++ b/src/commands/shop/modules/cpgg/index.ts @@ -1,6 +1,18 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import { ChatInputCommandInteraction } from "discord.js"; -// import fetchUser from "../../../../helpers/userData"; +import axios from "axios"; +import { + ActionRowBuilder, + ButtonBuilder, + ButtonStyle, + ChatInputCommandInteraction, + EmbedBuilder, + Message, +} from "discord.js"; +import { v4 as uuidv4 } from "uuid"; +import prisma from "../../../../handlers/database"; +import encryption from "../../../../helpers/encryption"; +import getEmbedData from "../../../../helpers/getEmbedData"; +import logger from "../../../../middlewares/logger"; export default { metadata: { guildOnly: true, ephemeral: true }, @@ -17,154 +29,166 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { - // const { errorColor, successColor, footerText, footerIcon } = - // await getEmbedConfig(interaction.guild); - // const { options, guild, user, client } = interaction; - // const optionAmount = options?.getInteger("amount"); - // if (optionAmount === null) { - // logger?.silly(`Amount is null.`); - // const interactionEmbed = new EmbedBuilder() - // .setTitle("[:dollar:] Gift") - // .setDescription("We could not read your requested amount.") - // .setTimestamp() - // .setColor(errorColor) - // .setFooter({ text: footerText, iconURL: footerIcon }); - // return interaction?.editReply({ - // embeds: [interactionEmbed], - // }); - // } - // if (guild === null) { - // return logger?.silly(`Guild is null`); - // } - // const userDB = await fetchUser(user, guild); - // if (userDB === null) { - // return logger?.silly(`User is null`); - // } - // const dmUser = client?.users?.cache?.get(user?.id); - // if ((optionAmount || userDB?.credits) < 100) { - // logger?.silly(`Amount or user credits is below 100.`); - // const interactionEmbed = new EmbedBuilder() - // .setTitle("[:shopping_cart:] CPGG") - // .setDescription("You **can't** withdraw for __CPGG__ below **100**.") - // .setTimestamp() - // .addFields({ - // name: "Your balance", - // value: `${pluralize(userDB?.credits, "credit")}`, - // }) - // .setColor(errorColor) - // .setFooter({ text: footerText, iconURL: footerIcon }); - // return interaction?.editReply({ - // embeds: [interactionEmbed], - // }); - // } - // if ((optionAmount || userDB?.credits) > 1000000) { - // logger?.silly(`Amount or user credits is above 1.000.000.`); - // const interactionEmbed = new EmbedBuilder() - // .setTitle("[:shopping_cart:] CPGG") - // .setDescription( - // "You **can't** withdraw for __CPGG__ above **1.000.000**." - // ) - // .setTimestamp() - // .addFields({ - // name: "Your balance", - // value: `${pluralize(userDB?.credits, "credit")}`, - // }) - // .setColor(errorColor) - // .setFooter({ text: footerText, iconURL: footerIcon }); - // return interaction?.editReply({ - // embeds: [interactionEmbed], - // }); - // } - // if (userDB?.credits < optionAmount) { - // logger?.silly(`User credits is below amount.`); - // const interactionEmbed = new EmbedBuilder() - // .setTitle("[:shopping_cart:] CPGG") - // .setDescription("You have **insufficient** credits.") - // .setTimestamp() - // .addFields({ - // name: "Your balance", - // value: `${pluralize(userDB?.credits, "credit")}`, - // }) - // .setColor(errorColor) - // .setFooter({ text: footerText, iconURL: footerIcon }); - // return interaction?.editReply({ - // embeds: [interactionEmbed], - // }); - // } - // const code = uuidv4(); - // const apiCredentials = await apiSchema?.findOne({ - // guildId: guild?.id, - // }); - // if (!apiCredentials) return; - // const url = encryption.decrypt(apiCredentials?.url); - // const api = axios?.create({ - // baseURL: `${url}/api/`, - // headers: { - // Authorization: `Bearer ${encryption.decrypt(apiCredentials.token)}`, - // }, - // }); - // const shopUrl = `${url}/store`; - // const buttons = new ActionRowBuilder().addComponents( - // new ButtonBuilder() - // .setLabel("Redeem it here") - // .setStyle(ButtonStyle.Link) - // .setEmoji("🏦") - // .setURL(`${shopUrl}?voucher=${code}`) - // ); - // await api - // ?.post("vouchers", { - // uses: 1, - // code, - // credits: optionAmount || userDB?.credits, - // memo: `${interaction?.createdTimestamp} - ${interaction?.user?.id}`, - // }) - // ?.then(async () => { - // logger?.silly(`Successfully created voucher.`); - // userDB.credits -= optionAmount || userDB?.credits; - // await userDB - // ?.save() - // ?.then(async () => { - // logger?.silly(`Successfully saved new credits.`); - // if (!interaction.guild) throw new Error("Guild is undefined"); - // const dmEmbed = new EmbedBuilder() - // .setTitle("[:shopping_cart:] CPGG") - // .setDescription( - // `This voucher comes from **${interaction.guild.name}**.` - // ) - // .setTimestamp() - // .addFields({ - // name: "💶 Credits", - // value: `${optionAmount || userDB?.credits}`, - // inline: true, - // }) - // .setColor(successColor) - // .setFooter({ text: footerText, iconURL: footerIcon }); - // await dmUser - // ?.send({ - // embeds: [dmEmbed], - // components: [buttons], - // }) - // .then(async (msg: Message) => { - // const interactionEmbed = new EmbedBuilder() - // .setTitle("[:shopping_cart:] CPGG") - // .setDescription( - // `I have sent you the code in [DM](${msg.url})!` - // ) - // .setTimestamp() - // .setColor(successColor) - // .setFooter({ text: footerText, iconURL: footerIcon }); - // await interaction?.editReply({ - // embeds: [interactionEmbed], - // }); - // return; - // }); - // }) - // .catch(() => { - // throw new Error("Failed to update credits for user."); - // }); - // }) - // .catch(() => { - // throw new Error("Failed generating an voucher."); - // }); + const { errorColor, successColor, footerText, footerIcon } = + await getEmbedData(interaction.guild); + const { options, guild, user, client } = interaction; + const optionAmount = options?.getInteger("amount"); + if (optionAmount === null) { + logger?.silly(`Amount is null.`); + const interactionEmbed = new EmbedBuilder() + .setTitle("[:dollar:] Gift") + .setDescription("We could not read your requested amount.") + .setTimestamp() + .setColor(errorColor) + .setFooter({ text: footerText, iconURL: footerIcon }); + return interaction?.editReply({ + embeds: [interactionEmbed], + }); + } + if (!guild) throw new Error("Guild not found"); + + const createGuildMember = await prisma.guildMember.upsert({ + where: { + userId_guildId: { + userId: user.id, + guildId: guild.id, + }, + }, + update: {}, + create: { + user: { + connectOrCreate: { + create: { + id: user.id, + }, + where: { + id: user.id, + }, + }, + }, + guild: { + connectOrCreate: { + create: { + id: guild.id, + }, + where: { + id: guild.id, + }, + }, + }, + }, + include: { + user: true, + guild: true, + }, + }); + + logger.silly(createGuildMember); + + const dmUser = client?.users?.cache?.get(user?.id); + + if ((optionAmount || createGuildMember.creditsEarned) < 100) + throw new Error("You can't withdraw to CPGG below 100 credits."); + + if ((optionAmount || createGuildMember.creditsEarned) > 1000000) + throw new Error("Amount or user credits is above 1.000.000."); + + if (createGuildMember.creditsEarned < optionAmount) + throw new Error("You can't withdraw more than you have on your account."); + + if ( + !createGuildMember.guild.apiCpggUrlIv || + !createGuildMember.guild.apiCpggUrlContent + ) + throw new Error("No API url available"); + + if ( + !createGuildMember.guild.apiCpggTokenIv || + !createGuildMember.guild.apiCpggTokenContent + ) + throw new Error("No API token available"); + + const code = uuidv4(); + const url = encryption.decrypt({ + iv: createGuildMember.guild.apiCpggUrlIv, + content: createGuildMember.guild.apiCpggUrlContent, + }); + const api = axios?.create({ + baseURL: `${url}/api/`, + headers: { + Authorization: `Bearer ${encryption.decrypt({ + iv: createGuildMember.guild.apiCpggTokenIv, + content: createGuildMember.guild.apiCpggTokenContent, + })}`, + }, + }); + const shopUrl = `${url}/store`; + const buttons = new ActionRowBuilder().addComponents( + new ButtonBuilder() + .setLabel("Redeem it here") + .setStyle(ButtonStyle.Link) + .setEmoji("🏦") + .setURL(`${shopUrl}?voucher=${code}`) + ); + await api + ?.post("vouchers", { + uses: 1, + code, + credits: optionAmount || createGuildMember.creditsEarned, + memo: `${interaction?.createdTimestamp} - ${interaction?.user?.id}`, + }) + ?.then(async () => { + logger?.silly(`Successfully created voucher.`); + createGuildMember.creditsEarned -= + optionAmount || createGuildMember.creditsEarned; + + const updateGuildMember = await prisma.guildMember.update({ + where: { + userId_guildId: { + userId: user.id, + guildId: guild.id, + }, + }, + data: { + creditsEarned: { + decrement: optionAmount || createGuildMember.creditsEarned, + }, + }, + }); + + logger.silly(updateGuildMember); + + if (!interaction.guild) throw new Error("Guild is undefined"); + const dmEmbed = new EmbedBuilder() + .setTitle("[:shopping_cart:] CPGG") + .setDescription( + `This voucher comes from **${interaction.guild.name}**.` + ) + .setTimestamp() + .addFields({ + name: "💶 Credits", + value: `${optionAmount || createGuildMember.creditsEarned}`, + inline: true, + }) + .setColor(successColor) + .setFooter({ text: footerText, iconURL: footerIcon }); + await dmUser + ?.send({ + embeds: [dmEmbed], + components: [buttons], + }) + .then(async (msg: Message) => { + const interactionEmbed = new EmbedBuilder() + .setTitle("[:shopping_cart:] CPGG") + .setDescription(`I have sent you the code in [DM](${msg.url})!`) + .setTimestamp() + .setColor(successColor) + .setFooter({ text: footerText, iconURL: footerIcon }); + await interaction?.editReply({ + embeds: [interactionEmbed], + }); + return; + }); + }); }, }; From 9b23b6c12eb61dd5d634650cb7af28cfc972754a Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Thu, 20 Oct 2022 13:09:14 +0200 Subject: [PATCH 170/215] =?UTF-8?q?=E2=9A=B0=EF=B8=8F=20removed=20unused?= =?UTF-8?q?=20objects?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/handlers/cooldown/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/handlers/cooldown/index.ts b/src/handlers/cooldown/index.ts index c2753b1..cf443cb 100644 --- a/src/handlers/cooldown/index.ts +++ b/src/handlers/cooldown/index.ts @@ -24,7 +24,7 @@ export const command = async (i: CommandInteraction, cooldown: number) => { // If user is not on timeout if (hasTimeout) { - const { guildId, userId, timeoutId, createdAt } = hasTimeout; + const { userId, timeoutId, createdAt } = hasTimeout; const overDue = (await addSeconds(cooldown, createdAt)) < new Date(); if (!overDue) { @@ -114,7 +114,7 @@ export const button = async (i: ButtonInteraction, cooldown: number) => { // If user is not on timeout if (hasTimeout) { - const { guildId, userId, timeoutId, createdAt } = hasTimeout; + const { userId, timeoutId, createdAt } = hasTimeout; const overDue = (await addSeconds(cooldown, createdAt)) < new Date(); if (!overDue) { @@ -205,7 +205,7 @@ export const message = async (msg: Message, cooldown: number, id: string) => { // If user is not on timeout if (hasTimeout) { - const { guildId, userId, timeoutId, createdAt } = hasTimeout; + const { userId, timeoutId, createdAt } = hasTimeout; const overDue = (await addSeconds(cooldown, createdAt)) < new Date(); if (!overDue) { From a43750080acb1e9f76c4acfe9407cd256287056b Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Thu, 20 Oct 2022 13:12:53 +0200 Subject: [PATCH 171/215] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20API=20is=20now=20f?= =?UTF-8?q?ully=20on=20Prisma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/credits/modules/giveaway/index.ts | 65 +++++++++++++++++-- src/models/api.ts | 51 --------------- 2 files changed, 58 insertions(+), 58 deletions(-) delete mode 100644 src/models/api.ts diff --git a/src/commands/manage/modules/credits/modules/giveaway/index.ts b/src/commands/manage/modules/credits/modules/giveaway/index.ts index e32a2ba..db3beb5 100644 --- a/src/commands/manage/modules/credits/modules/giveaway/index.ts +++ b/src/commands/manage/modules/credits/modules/giveaway/index.ts @@ -12,8 +12,9 @@ import { import { v4 as uuidv4 } from "uuid"; import encryption from "../../../../../../helpers/encryption"; // Configurations +import prisma from "../../../../../../handlers/database"; import getEmbedConfig from "../../../../../../helpers/getEmbedData"; -import apiSchema from "../../../../../../models/api"; +import logger from "../../../../../../middlewares/logger"; // Function export default { @@ -51,7 +52,7 @@ export default { const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild ); // Destructure - const { guild, options } = interaction; + const { guild, user, options } = interaction; const uses = options?.getInteger("uses"); const creditAmount = options?.getInteger("credit"); @@ -60,6 +61,7 @@ export default { if (!uses) throw new Error("Amount of uses is required."); if (!creditAmount) throw new Error("Amount of credits is required."); if (!channel) throw new Error("Channel is required."); + if (!guild) throw new Error("Guild is required."); const embed = new EmbedBuilder() .setTitle("[:toolbox:] Giveaway") @@ -67,18 +69,67 @@ export default { const code = uuidv4(); - const apiCredentials = await apiSchema?.findOne({ - guildId: guild?.id, + const createGuildMember = await prisma.guildMember.upsert({ + where: { + userId_guildId: { + userId: user.id, + guildId: guild.id, + }, + }, + update: {}, + create: { + user: { + connectOrCreate: { + create: { + id: user.id, + }, + where: { + id: user.id, + }, + }, + }, + guild: { + connectOrCreate: { + create: { + id: guild.id, + }, + where: { + id: guild.id, + }, + }, + }, + }, + include: { + user: true, + guild: true, + }, }); - if (!apiCredentials) return; + logger.silly(createGuildMember); - const url = encryption.decrypt(apiCredentials?.url); + if ( + !createGuildMember.guild.apiCpggUrlIv || + !createGuildMember.guild.apiCpggUrlContent + ) + throw new Error("No API url available"); + if ( + !createGuildMember.guild.apiCpggTokenIv || + !createGuildMember.guild.apiCpggTokenContent + ) + throw new Error("No API token available"); + + const url = encryption.decrypt({ + iv: createGuildMember.guild.apiCpggUrlIv, + content: createGuildMember.guild.apiCpggUrlContent, + }); const api = axios?.create({ baseURL: `${url}/api/`, headers: { - Authorization: `Bearer ${encryption.decrypt(apiCredentials.token)}`, + Authorization: `Bearer ${encryption.decrypt({ + iv: createGuildMember.guild.apiCpggTokenIv, + content: createGuildMember.guild.apiCpggTokenContent, + })}`, }, }); diff --git a/src/models/api.ts b/src/models/api.ts deleted file mode 100644 index fd5cbd7..0000000 --- a/src/models/api.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { Snowflake } from "discord.js"; -import { model, Schema } from "mongoose"; -import { IEncryptionData } from "../interfaces/EncryptionData"; - -export interface IApi { - guildId: Snowflake; - url: IEncryptionData; - token: IEncryptionData; -} - -const apiSchema = new Schema( - { - guildId: { - type: String, - required: true, - unique: false, - index: true, - }, - url: { - iv: { - type: String, - required: true, - unique: false, - index: true, - }, - content: { - type: String, - required: true, - unique: false, - index: true, - }, - }, - token: { - iv: { - type: String, - required: true, - unique: false, - index: true, - }, - content: { - type: String, - required: true, - unique: false, - index: true, - }, - }, - }, - { timestamps: true } -); - -export default model("api", apiSchema); From 3b6d0a7f5475d480ffb0984b9865fe7710b768d0 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Thu, 20 Oct 2022 13:21:33 +0200 Subject: [PATCH 172/215] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Audit=20Config=20n?= =?UTF-8?q?ow=20on=20Prisma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migration.sql | 36 ++++++++ prisma/schema.prisma | 13 ++- src/commands/config/modules/audits/index.ts | 92 ++++++++++--------- 3 files changed, 95 insertions(+), 46 deletions(-) create mode 100644 prisma/migrations/20221020111948_audits_module/migration.sql diff --git a/prisma/migrations/20221020111948_audits_module/migration.sql b/prisma/migrations/20221020111948_audits_module/migration.sql new file mode 100644 index 0000000..46db9e6 --- /dev/null +++ b/prisma/migrations/20221020111948_audits_module/migration.sql @@ -0,0 +1,36 @@ +-- RedefineTables +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_Guild" ( + "id" TEXT NOT NULL, + "embedColorSuccess" TEXT NOT NULL DEFAULT '#22bb33', + "embedColorWait" TEXT NOT NULL DEFAULT '#f0ad4e', + "embedColorError" TEXT NOT NULL DEFAULT '#bb2124', + "embedFooterText" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg/xyter', + "embedFooterIcon" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg.png', + "creditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "creditsRate" INTEGER NOT NULL DEFAULT 1, + "creditsTimeout" INTEGER NOT NULL DEFAULT 5, + "creditsWorkRate" INTEGER NOT NULL DEFAULT 25, + "creditsWorkTimeout" INTEGER NOT NULL DEFAULT 86400, + "creditsMinimumLength" INTEGER NOT NULL DEFAULT 5, + "pointsEnabled" BOOLEAN NOT NULL DEFAULT false, + "pointsRate" INTEGER NOT NULL DEFAULT 1, + "pointsTimeout" INTEGER NOT NULL DEFAULT 5, + "pointsMinimumLength" INTEGER NOT NULL DEFAULT 5, + "reputationsEnabled" BOOLEAN NOT NULL DEFAULT false, + "countersEnabled" BOOLEAN NOT NULL DEFAULT false, + "apiCpggUrlIv" TEXT, + "apiCpggUrlContent" TEXT, + "apiCpggTokenIv" TEXT, + "apiCpggTokenContent" TEXT, + "auditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "auditsChannelId" TEXT, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL +); +INSERT INTO "new_Guild" ("apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "updatedAt") SELECT "apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "updatedAt" FROM "Guild"; +DROP TABLE "Guild"; +ALTER TABLE "new_Guild" RENAME TO "Guild"; +CREATE UNIQUE INDEX "Guild_id_key" ON "Guild"("id"); +PRAGMA foreign_key_check; +PRAGMA foreign_keys=ON; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 16b1622..9a0a715 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -23,11 +23,6 @@ model Guild { embedFooterText String @default("https://github.com/ZynerOrg/xyter") embedFooterIcon String @default("https://github.com/ZynerOrg.png") - apiCpggUrlIv String? - apiCpggUrlContent String? - apiCpggTokenIv String? - apiCpggTokenContent String? - // Modules creditsEnabled Boolean @default(false) creditsRate Int @default(1) @@ -46,6 +41,14 @@ model Guild { countersEnabled Boolean @default(false) counters GuildCounter[] + apiCpggUrlIv String? + apiCpggUrlContent String? + apiCpggTokenIv String? + apiCpggTokenContent String? + + auditsEnabled Boolean @default(false) + auditsChannelId String? + createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } diff --git a/src/commands/config/modules/audits/index.ts b/src/commands/config/modules/audits/index.ts index 46e2bfb..3a6dd1f 100644 --- a/src/commands/config/modules/audits/index.ts +++ b/src/commands/config/modules/audits/index.ts @@ -5,9 +5,9 @@ import { EmbedBuilder, PermissionsBitField, } from "discord.js"; +import prisma from "../../../../handlers/database"; import getEmbedConfig from "../../../../helpers/getEmbedData"; import logger from "../../../../middlewares/logger"; -import guildSchema from "../../../../models/guild"; export default { metadata: { @@ -21,13 +21,17 @@ export default { .setName("audits") .setDescription("Audits") .addBooleanOption((option) => - option.setName("status").setDescription("Should audits be enabled?") + option + .setName("status") + .setDescription("Should audits be enabled?") + .setRequired(true) ) .addChannelOption((option) => option .setName("channel") .setDescription("Channel for audit messages.") .addChannelTypes(ChannelType.GuildText) + .setRequired(true) ); }, execute: async (interaction: ChatInputCommandInteraction) => { @@ -39,49 +43,55 @@ export default { const channel = options.getChannel("channel"); if (!guild) throw new Error("Guild not found."); - const guildDB = await guildSchema.findOne({ - guildId: guild.id, + if (!channel) throw new Error("Channel not found."); + if (status === null) throw new Error("Status not found."); + + const createGuild = await prisma.guild.upsert({ + where: { + id: guild.id, + }, + update: { + auditsEnabled: status, + auditsChannelId: channel.id, + }, + create: { + id: guild.id, + auditsEnabled: status, + auditsChannelId: channel.id, + }, }); - if (!guildDB) throw new Error("Guild configuration not found."); - guildDB.audits.status = status !== null ? status : guildDB.audits.status; - guildDB.audits.channelId = channel ? channel.id : guildDB.audits.channelId; + logger.silly(createGuild); - await guildDB.save().then(async () => { - logger.verbose( - `Guild ${guild.name} updated their configuration for audits.` - ); - - const embedSuccess = new EmbedBuilder() - .setTitle("[:hammer:] Audits") - .setDescription("Guild configuration updated successfully.") - .setColor(successColor) - .addFields( - { - name: "🤖 Status", - value: `${ - guildDB.audits.status - ? ":white_check_mark: Enabled" - : ":x: Disabled" - }`, - inline: true, - }, - { - name: "🌊 Channel", - value: `<#${guildDB.audits.channelId}>`, - inline: true, - } - ) - .setTimestamp() - .setFooter({ - iconURL: footerIcon, - text: footerText, - }); - - await interaction.editReply({ - embeds: [embedSuccess], + const embedSuccess = new EmbedBuilder() + .setTitle("[:hammer:] Audits") + .setDescription("Guild configuration updated successfully.") + .setColor(successColor) + .addFields( + { + name: "🤖 Status", + value: `${ + createGuild.auditsEnabled + ? ":white_check_mark: Enabled" + : ":x: Disabled" + }`, + inline: true, + }, + { + name: "🌊 Channel", + value: `<#${createGuild.auditsChannelId}>`, + inline: true, + } + ) + .setTimestamp() + .setFooter({ + iconURL: footerIcon, + text: footerText, }); - return; + + await interaction.editReply({ + embeds: [embedSuccess], }); + return; }, }; From 69be3ccf053ae29cc823fc2a5c307610fa933026 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Thu, 20 Oct 2022 13:27:26 +0200 Subject: [PATCH 173/215] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Config=20Credits?= =?UTF-8?q?=20now=20on=20Prisma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/config/modules/credits/index.ts | 157 ++++++++++--------- 1 file changed, 87 insertions(+), 70 deletions(-) diff --git a/src/commands/config/modules/credits/index.ts b/src/commands/config/modules/credits/index.ts index f140faf..4d25feb 100644 --- a/src/commands/config/modules/credits/index.ts +++ b/src/commands/config/modules/credits/index.ts @@ -4,9 +4,9 @@ import { EmbedBuilder, PermissionsBitField, } from "discord.js"; +import prisma from "../../../../handlers/database"; import getEmbedConfig from "../../../../helpers/getEmbedData"; import logger from "../../../../middlewares/logger"; -import guildSchema from "../../../../models/guild"; export default { metadata: { @@ -20,30 +20,40 @@ export default { .setName("credits") .setDescription(`Credits`) .addBooleanOption((option) => - option.setName("status").setDescription("Should credits be enabled?") + option + .setName("status") + .setDescription("Should credits be enabled?") + .setRequired(true) ) .addNumberOption((option) => - option.setName("rate").setDescription("Amount of credits per message.") + option + .setName("rate") + .setDescription("Amount of credits per message.") + .setRequired(true) ) .addNumberOption((option) => option .setName("minimum-length") .setDescription("Minimum length of message to earn credits.") + .setRequired(true) ) .addNumberOption((option) => option .setName("work-rate") .setDescription("Maximum amount of credits on work.") + .setRequired(true) ) .addNumberOption((option) => option .setName("work-timeout") .setDescription("Timeout between work schedules (seconds).") + .setRequired(true) ) .addNumberOption((option) => option .setName("timeout") .setDescription("Timeout between earning credits (seconds).") + .setRequired(true) ); }, execute: async (interaction: ChatInputCommandInteraction) => { @@ -52,8 +62,6 @@ export default { ); const { guild, options } = interaction; - if (!guild) return; - const status = options?.getBoolean("status"); const rate = options?.getNumber("rate"); const timeout = options?.getNumber("timeout"); @@ -61,75 +69,84 @@ export default { const workRate = options?.getNumber("work-rate"); const workTimeout = options?.getNumber("work-timeout"); - const guildDB = await guildSchema?.findOne({ - guildId: guild?.id, + if (!guild) throw new Error("Guild is not found"); + if (status === null) throw new Error("Status is null"); + if (!rate) throw new Error("Rate is null"); + if (!workRate) throw new Error("WorkRate is null"); + if (!workTimeout) throw new Error("WorkTimeout is null"); + if (!timeout) throw new Error("Timeout is null"); + if (!minimumLength) throw new Error("Minimum Length is null"); + + const createGuild = await prisma.guild.upsert({ + where: { + id: guild.id, + }, + update: { + creditsEnabled: status, + creditsRate: rate, + creditsTimeout: timeout, + creditsWorkRate: workRate, + creditsWorkTimeout: workTimeout, + creditsMinimumLength: minimumLength, + }, + create: { + id: guild.id, + creditsEnabled: status, + creditsRate: rate, + creditsTimeout: timeout, + creditsWorkRate: workRate, + creditsWorkTimeout: workTimeout, + creditsMinimumLength: minimumLength, + }, }); - if (guildDB === null) { - return logger?.silly(`Guild is null`); - } + logger.silly(createGuild); - guildDB.credits.status = - status !== null ? status : guildDB?.credits?.status; - guildDB.credits.rate = rate !== null ? rate : guildDB?.credits?.rate; - guildDB.credits.timeout = - timeout !== null ? timeout : guildDB?.credits?.timeout; - guildDB.credits.workRate = - workRate !== null ? workRate : guildDB?.credits?.workRate; - guildDB.credits.workTimeout = - workTimeout !== null ? workTimeout : guildDB?.credits?.workTimeout; - guildDB.credits.minimumLength = - minimumLength !== null ? minimumLength : guildDB?.credits?.minimumLength; - - await guildDB?.save()?.then(async () => { - logger?.silly(`Guild saved`); - - const interactionEmbed = new EmbedBuilder() - .setTitle("[:tools:] Credits") - .setDescription("Credits settings updated") - .setColor(successColor) - .addFields( - { - name: "🤖 Status", - value: `${guildDB?.credits?.status}`, - inline: true, - }, - { - name: "📈 Rate", - value: `${guildDB?.credits?.rate}`, - inline: true, - }, - { - name: "📈 Work Rate", - value: `${guildDB?.credits?.workRate}`, - inline: true, - }, - { - name: "🔨 Minimum Length", - value: `${guildDB?.credits?.minimumLength}`, - inline: true, - }, - { - name: "⏰ Timeout", - value: `${guildDB?.credits?.timeout}`, - inline: true, - }, - { - name: "⏰ Work Timeout", - value: `${guildDB?.credits?.workTimeout}`, - inline: true, - } - ) - .setTimestamp() - .setFooter({ - iconURL: footerIcon, - text: footerText, - }); - - await interaction?.editReply({ - embeds: [interactionEmbed], + const interactionEmbed = new EmbedBuilder() + .setTitle("[:tools:] Credits") + .setDescription("Credits settings updated") + .setColor(successColor) + .addFields( + { + name: "🤖 Status", + value: `${createGuild.creditsEnabled}`, + inline: true, + }, + { + name: "📈 Rate", + value: `${createGuild.creditsRate}`, + inline: true, + }, + { + name: "📈 Work Rate", + value: `${createGuild.creditsWorkRate}`, + inline: true, + }, + { + name: "🔨 Minimum Length", + value: `${createGuild.creditsMinimumLength}`, + inline: true, + }, + { + name: "⏰ Timeout", + value: `${createGuild.creditsTimeout}`, + inline: true, + }, + { + name: "⏰ Work Timeout", + value: `${createGuild.creditsWorkTimeout}`, + inline: true, + } + ) + .setTimestamp() + .setFooter({ + iconURL: footerIcon, + text: footerText, }); - return; + + await interaction?.editReply({ + embeds: [interactionEmbed], }); + return; }, }; From 71f764574ddc3102c79477e78da238c588ca913a Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Thu, 20 Oct 2022 13:32:21 +0200 Subject: [PATCH 174/215] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Config=20Points=20?= =?UTF-8?q?is=20now=20on=20Prisma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/config/modules/points/index.ts | 122 +++++++++++--------- 1 file changed, 69 insertions(+), 53 deletions(-) diff --git a/src/commands/config/modules/points/index.ts b/src/commands/config/modules/points/index.ts index 9cda9a3..fc67d3b 100644 --- a/src/commands/config/modules/points/index.ts +++ b/src/commands/config/modules/points/index.ts @@ -4,9 +4,9 @@ import { EmbedBuilder, PermissionsBitField, } from "discord.js"; +import prisma from "../../../../handlers/database"; import getEmbedConfig from "../../../../helpers/getEmbedData"; import logger from "../../../../middlewares/logger"; -import guildSchema from "../../../../models/guild"; export default { metadata: { @@ -20,20 +20,28 @@ export default { .setName("points") .setDescription("Points") .addBooleanOption((option) => - option.setName("status").setDescription("Should credits be enabled?") + option + .setName("status") + .setDescription("Should credits be enabled?") + .setRequired(true) ) .addNumberOption((option) => - option.setName("rate").setDescription("Amount of credits per message.") + option + .setName("rate") + .setDescription("Amount of credits per message.") + .setRequired(true) ) .addNumberOption((option) => option .setName("minimum-length") .setDescription("Minimum length of message to earn credits.") + .setRequired(true) ) .addNumberOption((option) => option .setName("timeout") .setDescription("Timeout between earning credits (milliseconds).") + .setRequired(true) ); }, execute: async (interaction: ChatInputCommandInteraction) => { @@ -48,60 +56,68 @@ export default { const timeout = options?.getNumber("timeout"); const minimumLength = options?.getNumber("minimum-length"); - const guildDB = await guildSchema?.findOne({ - guildId: guild?.id, + if (!guild) throw new Error("Guild is required"); + if (status === null) throw new Error("Status must be specified"); + if (!rate) throw new Error("Rate must be specified"); + if (!timeout) throw new Error("Timeout must be specified"); + if (!minimumLength) throw new Error("Minimum length must be specified"); + + const createGuild = await prisma.guild.upsert({ + where: { + id: guild.id, + }, + update: { + pointsEnabled: status, + pointsRate: rate, + pointsTimeout: timeout, + pointsMinimumLength: minimumLength, + }, + create: { + id: guild.id, + pointsEnabled: status, + pointsRate: rate, + pointsTimeout: timeout, + pointsMinimumLength: minimumLength, + }, }); - if (guildDB === null) { - return logger?.silly(`Guild not found in database.`); - } + logger.silly(createGuild); - guildDB.points.status = status !== null ? status : guildDB?.points?.status; - guildDB.points.rate = rate !== null ? rate : guildDB?.points?.rate; - guildDB.points.timeout = - timeout !== null ? timeout : guildDB?.points?.timeout; - guildDB.points.minimumLength = - minimumLength !== null ? minimumLength : guildDB?.points?.minimumLength; - - await guildDB?.save()?.then(async () => { - logger?.silly(`Guild points updated.`); - - const interactionEmbed = new EmbedBuilder() - .setTitle("[:tools:] Points") - .setDescription("Points settings updated") - .setColor(successColor) - .addFields( - { - name: "🤖 Status", - value: `${guildDB?.points?.status}`, - inline: true, - }, - { - name: "📈 Rate", - value: `${guildDB?.points?.rate}`, - inline: true, - }, - { - name: "🔨 Minimum Length", - value: `${guildDB?.points?.minimumLength}`, - inline: true, - }, - { - name: "⏰ Timeout", - value: `${guildDB?.points?.timeout}`, - inline: true, - } - ) - .setTimestamp() - .setFooter({ - iconURL: footerIcon, - text: footerText, - }); - - await interaction?.editReply({ - embeds: [interactionEmbed], + const interactionEmbed = new EmbedBuilder() + .setTitle("[:tools:] Points") + .setDescription("Points settings updated") + .setColor(successColor) + .addFields( + { + name: "🤖 Status", + value: `${createGuild.pointsEnabled}`, + inline: true, + }, + { + name: "📈 Rate", + value: `${createGuild.pointsRate}`, + inline: true, + }, + { + name: "🔨 Minimum Length", + value: `${createGuild.pointsMinimumLength}`, + inline: true, + }, + { + name: "⏰ Timeout", + value: `${createGuild.pointsTimeout}`, + inline: true, + } + ) + .setTimestamp() + .setFooter({ + iconURL: footerIcon, + text: footerText, }); - return; + + await interaction?.editReply({ + embeds: [interactionEmbed], }); + return; }, }; From 5f5f3dccb8158aa6c2fc79ea97710e5f2d96069b Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Thu, 20 Oct 2022 13:36:04 +0200 Subject: [PATCH 175/215] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Config=20Shop=20is?= =?UTF-8?q?=20now=20on=20Prisma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20221020113312_shop_module/migration.sql | 38 ++++++++ prisma/schema.prisma | 3 + src/commands/config/modules/shop/index.ts | 87 ++++++++++--------- 3 files changed, 87 insertions(+), 41 deletions(-) create mode 100644 prisma/migrations/20221020113312_shop_module/migration.sql diff --git a/prisma/migrations/20221020113312_shop_module/migration.sql b/prisma/migrations/20221020113312_shop_module/migration.sql new file mode 100644 index 0000000..12a71d6 --- /dev/null +++ b/prisma/migrations/20221020113312_shop_module/migration.sql @@ -0,0 +1,38 @@ +-- RedefineTables +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_Guild" ( + "id" TEXT NOT NULL, + "embedColorSuccess" TEXT NOT NULL DEFAULT '#22bb33', + "embedColorWait" TEXT NOT NULL DEFAULT '#f0ad4e', + "embedColorError" TEXT NOT NULL DEFAULT '#bb2124', + "embedFooterText" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg/xyter', + "embedFooterIcon" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg.png', + "creditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "creditsRate" INTEGER NOT NULL DEFAULT 1, + "creditsTimeout" INTEGER NOT NULL DEFAULT 5, + "creditsWorkRate" INTEGER NOT NULL DEFAULT 25, + "creditsWorkTimeout" INTEGER NOT NULL DEFAULT 86400, + "creditsMinimumLength" INTEGER NOT NULL DEFAULT 5, + "pointsEnabled" BOOLEAN NOT NULL DEFAULT false, + "pointsRate" INTEGER NOT NULL DEFAULT 1, + "pointsTimeout" INTEGER NOT NULL DEFAULT 5, + "pointsMinimumLength" INTEGER NOT NULL DEFAULT 5, + "reputationsEnabled" BOOLEAN NOT NULL DEFAULT false, + "countersEnabled" BOOLEAN NOT NULL DEFAULT false, + "apiCpggUrlIv" TEXT, + "apiCpggUrlContent" TEXT, + "apiCpggTokenIv" TEXT, + "apiCpggTokenContent" TEXT, + "auditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "auditsChannelId" TEXT, + "shopRolesEnabled" BOOLEAN NOT NULL DEFAULT false, + "shopRolesPricePerHour" INTEGER NOT NULL DEFAULT 5, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL +); +INSERT INTO "new_Guild" ("apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "updatedAt") SELECT "apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "updatedAt" FROM "Guild"; +DROP TABLE "Guild"; +ALTER TABLE "new_Guild" RENAME TO "Guild"; +CREATE UNIQUE INDEX "Guild_id_key" ON "Guild"("id"); +PRAGMA foreign_key_check; +PRAGMA foreign_keys=ON; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 9a0a715..273e724 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -49,6 +49,9 @@ model Guild { auditsEnabled Boolean @default(false) auditsChannelId String? + shopRolesEnabled Boolean @default(false) + shopRolesPricePerHour Int @default(5) + createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } diff --git a/src/commands/config/modules/shop/index.ts b/src/commands/config/modules/shop/index.ts index 9093fa0..2d605d6 100644 --- a/src/commands/config/modules/shop/index.ts +++ b/src/commands/config/modules/shop/index.ts @@ -4,9 +4,9 @@ import { EmbedBuilder, PermissionsBitField, } from "discord.js"; +import prisma from "../../../../handlers/database"; import getEmbedConfig from "../../../../helpers/getEmbedData"; import logger from "../../../../middlewares/logger"; -import guildSchema from "../../../../models/guild"; export default { metadata: { @@ -23,11 +23,13 @@ export default { option .setName("roles-status") .setDescription("Should roles be enabled?") + .setRequired(true) ) .addNumberOption((option) => option .setName("roles-price-per-hour") .setDescription("Price per hour for roles.") + .setRequired(true) ); }, execute: async (interaction: ChatInputCommandInteraction) => { @@ -39,50 +41,53 @@ export default { const rolesStatus = options?.getBoolean("roles-status"); const rolesPricePerHour = options?.getNumber("roles-price-per-hour"); - const guildDB = await guildSchema?.findOne({ - guildId: guild?.id, + if (!guild) throw new Error("Guild not found"); + if (rolesStatus === null) throw new Error("Status must be provided"); + if (!rolesPricePerHour) + throw new Error("Roles price per hour must be provided"); + + const createGuild = await prisma.guild.upsert({ + where: { + id: guild.id, + }, + update: { + shopRolesEnabled: rolesStatus, + shopRolesPricePerHour: rolesPricePerHour, + }, + create: { + id: guild.id, + shopRolesEnabled: rolesStatus, + shopRolesPricePerHour: rolesPricePerHour, + }, }); - if (guildDB === null) { - return logger?.silly(`Guild not found in database.`); - } + logger.silly(createGuild); - guildDB.shop.roles.status = - rolesStatus !== null ? rolesStatus : guildDB?.shop?.roles?.status; - guildDB.shop.roles.pricePerHour = - rolesPricePerHour !== null - ? rolesPricePerHour - : guildDB?.shop?.roles?.pricePerHour; - - await guildDB?.save()?.then(async () => { - logger?.silly(`Guild shop updated.`); - - const interactionEmbed = new EmbedBuilder() - .setTitle("[:tools:] Shop") - .setDescription("Shop settings updated") - .setColor(successColor) - .addFields( - { - name: "🤖 Roles Status", - value: `${guildDB?.shop?.roles.status}`, - inline: true, - }, - { - name: "🌊 Roles Price Per Hour", - value: `${guildDB?.shop?.roles.pricePerHour}`, - inline: true, - } - ) - .setTimestamp() - .setFooter({ - iconURL: footerIcon, - text: footerText, - }); - - await interaction?.editReply({ - embeds: [interactionEmbed], + const interactionEmbed = new EmbedBuilder() + .setTitle("[:tools:] Shop") + .setDescription("Shop settings updated") + .setColor(successColor) + .addFields( + { + name: "🤖 Roles Status", + value: `${createGuild.shopRolesEnabled}`, + inline: true, + }, + { + name: "🌊 Roles Price Per Hour", + value: `${createGuild.shopRolesPricePerHour}`, + inline: true, + } + ) + .setTimestamp() + .setFooter({ + iconURL: footerIcon, + text: footerText, }); - return; + + await interaction?.editReply({ + embeds: [interactionEmbed], }); + return; }, }; From 5e7a30169b79035c66d672f2c09a376fecb1b2a5 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Thu, 20 Oct 2022 13:42:24 +0200 Subject: [PATCH 176/215] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Config=20Welcome?= =?UTF-8?q?=20now=20on=20Prisma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migration.sql | 41 ++++ .../migration.sql | 49 +++++ .../migration.sql | 49 +++++ prisma/schema.prisma | 6 + src/commands/config/modules/welcome/index.ts | 179 +++++++----------- 5 files changed, 218 insertions(+), 106 deletions(-) create mode 100644 prisma/migrations/20221020113704_welcome_module/migration.sql create mode 100644 prisma/migrations/20221020113756_welcome_module_correction/migration.sql create mode 100644 prisma/migrations/20221020113831_welcome_module_correction/migration.sql diff --git a/prisma/migrations/20221020113704_welcome_module/migration.sql b/prisma/migrations/20221020113704_welcome_module/migration.sql new file mode 100644 index 0000000..c69df84 --- /dev/null +++ b/prisma/migrations/20221020113704_welcome_module/migration.sql @@ -0,0 +1,41 @@ +-- RedefineTables +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_Guild" ( + "id" TEXT NOT NULL, + "embedColorSuccess" TEXT NOT NULL DEFAULT '#22bb33', + "embedColorWait" TEXT NOT NULL DEFAULT '#f0ad4e', + "embedColorError" TEXT NOT NULL DEFAULT '#bb2124', + "embedFooterText" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg/xyter', + "embedFooterIcon" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg.png', + "creditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "creditsRate" INTEGER NOT NULL DEFAULT 1, + "creditsTimeout" INTEGER NOT NULL DEFAULT 5, + "creditsWorkRate" INTEGER NOT NULL DEFAULT 25, + "creditsWorkTimeout" INTEGER NOT NULL DEFAULT 86400, + "creditsMinimumLength" INTEGER NOT NULL DEFAULT 5, + "pointsEnabled" BOOLEAN NOT NULL DEFAULT false, + "pointsRate" INTEGER NOT NULL DEFAULT 1, + "pointsTimeout" INTEGER NOT NULL DEFAULT 5, + "pointsMinimumLength" INTEGER NOT NULL DEFAULT 5, + "reputationsEnabled" BOOLEAN NOT NULL DEFAULT false, + "countersEnabled" BOOLEAN NOT NULL DEFAULT false, + "apiCpggUrlIv" TEXT, + "apiCpggUrlContent" TEXT, + "apiCpggTokenIv" TEXT, + "apiCpggTokenContent" TEXT, + "auditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "auditsChannelId" TEXT, + "shopRolesEnabled" BOOLEAN NOT NULL DEFAULT false, + "shopRolesPricePerHour" INTEGER NOT NULL DEFAULT 5, + "welcomeEnabled" BOOLEAN NOT NULL DEFAULT false, + "welcomeJoinChannelId" TEXT, + "welcomejoinChannelMessahe" TEXT, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL +); +INSERT INTO "new_Guild" ("apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt") SELECT "apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt" FROM "Guild"; +DROP TABLE "Guild"; +ALTER TABLE "new_Guild" RENAME TO "Guild"; +CREATE UNIQUE INDEX "Guild_id_key" ON "Guild"("id"); +PRAGMA foreign_key_check; +PRAGMA foreign_keys=ON; diff --git a/prisma/migrations/20221020113756_welcome_module_correction/migration.sql b/prisma/migrations/20221020113756_welcome_module_correction/migration.sql new file mode 100644 index 0000000..f6817b0 --- /dev/null +++ b/prisma/migrations/20221020113756_welcome_module_correction/migration.sql @@ -0,0 +1,49 @@ +/* + Warnings: + + - You are about to drop the column `welcomejoinChannelMessahe` on the `Guild` table. All the data in the column will be lost. + +*/ +-- RedefineTables +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_Guild" ( + "id" TEXT NOT NULL, + "embedColorSuccess" TEXT NOT NULL DEFAULT '#22bb33', + "embedColorWait" TEXT NOT NULL DEFAULT '#f0ad4e', + "embedColorError" TEXT NOT NULL DEFAULT '#bb2124', + "embedFooterText" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg/xyter', + "embedFooterIcon" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg.png', + "creditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "creditsRate" INTEGER NOT NULL DEFAULT 1, + "creditsTimeout" INTEGER NOT NULL DEFAULT 5, + "creditsWorkRate" INTEGER NOT NULL DEFAULT 25, + "creditsWorkTimeout" INTEGER NOT NULL DEFAULT 86400, + "creditsMinimumLength" INTEGER NOT NULL DEFAULT 5, + "pointsEnabled" BOOLEAN NOT NULL DEFAULT false, + "pointsRate" INTEGER NOT NULL DEFAULT 1, + "pointsTimeout" INTEGER NOT NULL DEFAULT 5, + "pointsMinimumLength" INTEGER NOT NULL DEFAULT 5, + "reputationsEnabled" BOOLEAN NOT NULL DEFAULT false, + "countersEnabled" BOOLEAN NOT NULL DEFAULT false, + "apiCpggUrlIv" TEXT, + "apiCpggUrlContent" TEXT, + "apiCpggTokenIv" TEXT, + "apiCpggTokenContent" TEXT, + "auditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "auditsChannelId" TEXT, + "shopRolesEnabled" BOOLEAN NOT NULL DEFAULT false, + "shopRolesPricePerHour" INTEGER NOT NULL DEFAULT 5, + "welcomeEnabled" BOOLEAN NOT NULL DEFAULT false, + "welcomeJoinChannelId" TEXT, + "welcomeJoinChannelMessahe" TEXT, + "welcomeLeaveChannelId" TEXT, + "welcomeLeaveChannelMessage" TEXT, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL +); +INSERT INTO "new_Guild" ("apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt", "welcomeEnabled", "welcomeJoinChannelId") SELECT "apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt", "welcomeEnabled", "welcomeJoinChannelId" FROM "Guild"; +DROP TABLE "Guild"; +ALTER TABLE "new_Guild" RENAME TO "Guild"; +CREATE UNIQUE INDEX "Guild_id_key" ON "Guild"("id"); +PRAGMA foreign_key_check; +PRAGMA foreign_keys=ON; diff --git a/prisma/migrations/20221020113831_welcome_module_correction/migration.sql b/prisma/migrations/20221020113831_welcome_module_correction/migration.sql new file mode 100644 index 0000000..5ee06ca --- /dev/null +++ b/prisma/migrations/20221020113831_welcome_module_correction/migration.sql @@ -0,0 +1,49 @@ +/* + Warnings: + + - You are about to drop the column `welcomeJoinChannelMessahe` on the `Guild` table. All the data in the column will be lost. + +*/ +-- RedefineTables +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_Guild" ( + "id" TEXT NOT NULL, + "embedColorSuccess" TEXT NOT NULL DEFAULT '#22bb33', + "embedColorWait" TEXT NOT NULL DEFAULT '#f0ad4e', + "embedColorError" TEXT NOT NULL DEFAULT '#bb2124', + "embedFooterText" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg/xyter', + "embedFooterIcon" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg.png', + "creditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "creditsRate" INTEGER NOT NULL DEFAULT 1, + "creditsTimeout" INTEGER NOT NULL DEFAULT 5, + "creditsWorkRate" INTEGER NOT NULL DEFAULT 25, + "creditsWorkTimeout" INTEGER NOT NULL DEFAULT 86400, + "creditsMinimumLength" INTEGER NOT NULL DEFAULT 5, + "pointsEnabled" BOOLEAN NOT NULL DEFAULT false, + "pointsRate" INTEGER NOT NULL DEFAULT 1, + "pointsTimeout" INTEGER NOT NULL DEFAULT 5, + "pointsMinimumLength" INTEGER NOT NULL DEFAULT 5, + "reputationsEnabled" BOOLEAN NOT NULL DEFAULT false, + "countersEnabled" BOOLEAN NOT NULL DEFAULT false, + "apiCpggUrlIv" TEXT, + "apiCpggUrlContent" TEXT, + "apiCpggTokenIv" TEXT, + "apiCpggTokenContent" TEXT, + "auditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "auditsChannelId" TEXT, + "shopRolesEnabled" BOOLEAN NOT NULL DEFAULT false, + "shopRolesPricePerHour" INTEGER NOT NULL DEFAULT 5, + "welcomeEnabled" BOOLEAN NOT NULL DEFAULT false, + "welcomeJoinChannelId" TEXT, + "welcomeJoinChannelMessage" TEXT, + "welcomeLeaveChannelId" TEXT, + "welcomeLeaveChannelMessage" TEXT, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL +); +INSERT INTO "new_Guild" ("apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt", "welcomeEnabled", "welcomeJoinChannelId", "welcomeLeaveChannelId", "welcomeLeaveChannelMessage") SELECT "apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt", "welcomeEnabled", "welcomeJoinChannelId", "welcomeLeaveChannelId", "welcomeLeaveChannelMessage" FROM "Guild"; +DROP TABLE "Guild"; +ALTER TABLE "new_Guild" RENAME TO "Guild"; +CREATE UNIQUE INDEX "Guild_id_key" ON "Guild"("id"); +PRAGMA foreign_key_check; +PRAGMA foreign_keys=ON; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 273e724..5418d5b 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -52,6 +52,12 @@ model Guild { shopRolesEnabled Boolean @default(false) shopRolesPricePerHour Int @default(5) + welcomeEnabled Boolean @default(false) + welcomeJoinChannelId String? + welcomeJoinChannelMessage String? + welcomeLeaveChannelId String? + welcomeLeaveChannelMessage String? + createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } diff --git a/src/commands/config/modules/welcome/index.ts b/src/commands/config/modules/welcome/index.ts index 7cd463e..fd604a1 100644 --- a/src/commands/config/modules/welcome/index.ts +++ b/src/commands/config/modules/welcome/index.ts @@ -5,9 +5,9 @@ import { EmbedBuilder, PermissionsBitField, } from "discord.js"; +import prisma from "../../../../handlers/database"; import getEmbedConfig from "../../../../helpers/getEmbedData"; import logger from "../../../../middlewares/logger"; -import guildSchema from "../../../../models/guild"; export default { metadata: { @@ -21,13 +21,17 @@ export default { .setName("welcome") .setDescription("Welcome") .addBooleanOption((option) => - option.setName("status").setDescription("Should welcome be enabled?") + option + .setName("status") + .setDescription("Should welcome be enabled?") + .setRequired(true) ) .addChannelOption((option) => option .setName("join-channel") .setDescription("Channel for join messages.") .addChannelTypes(ChannelType.GuildText) + .setRequired(true) ) .addChannelOption((option) => @@ -35,17 +39,20 @@ export default { .setName("leave-channel") .setDescription("Channel for leave messages.") .addChannelTypes(ChannelType.GuildText) + .setRequired(true) ) .addStringOption((option) => option .setName("leave-message") .setDescription("Message for leave messages.") + .setRequired(true) ) .addStringOption((option) => option .setName("join-message") .setDescription("Message for join messages.") + .setRequired(true) ); }, execute: async (interaction: ChatInputCommandInteraction) => { @@ -60,121 +67,81 @@ export default { const joinChannelMessage = options?.getString("join-message"); const leaveChannelMessage = options?.getString("leave-message"); - const guildDB = await guildSchema?.findOne({ - guildId: guild?.id, + if (!guild) throw new Error("Guild not found"); + if (status === null) throw new Error("Status not specified"); + if (!joinChannel) throw new Error("Join channel not specified"); + if (!joinChannelMessage) + throw new Error("Join channel message not specified"); + if (!leaveChannel) throw new Error("Leave channel not specified"); + if (!leaveChannelMessage) + throw new Error("Leave channel message not specified"); + + const createGuild = await prisma.guild.upsert({ + where: { + id: guild.id, + }, + update: { + welcomeEnabled: status, + welcomeJoinChannelId: joinChannel.id, + welcomeJoinChannelMessage: joinChannelMessage, + welcomeLeaveChannelId: leaveChannel.id, + welcomeLeaveChannelMessage: leaveChannelMessage, + }, + create: { + id: guild.id, + welcomeEnabled: status, + welcomeJoinChannelId: joinChannel.id, + welcomeJoinChannelMessage: joinChannelMessage, + welcomeLeaveChannelId: leaveChannel.id, + welcomeLeaveChannelMessage: leaveChannelMessage, + }, }); - if (guildDB === null) { - return logger?.silly(`Guild not found in database.`); + logger.silly(createGuild); + + const interactionEmbedDisabled = new EmbedBuilder() + .setTitle("[:tools:] Welcome") + .setDescription( + "This module is currently disabled, please enable it to continue." + ) + .setColor(successColor) + .setTimestamp() + .setFooter({ + iconURL: footerIcon, + text: footerText, + }); + + if (!createGuild.welcomeEnabled) { + return interaction?.editReply({ + embeds: [interactionEmbedDisabled], + }); } - guildDB.welcome.status = - status !== null ? status : guildDB?.welcome?.status; - guildDB.welcome.joinChannel = - joinChannel !== null ? joinChannel.id : guildDB?.welcome?.joinChannel; - guildDB.welcome.leaveChannel = - leaveChannel !== null ? leaveChannel.id : guildDB?.welcome?.leaveChannel; - - guildDB.welcome.joinChannelMessage = - joinChannelMessage !== null - ? joinChannelMessage - : guildDB?.welcome?.joinChannelMessage; - guildDB.welcome.leaveChannelMessage = - leaveChannelMessage !== null - ? leaveChannelMessage - : guildDB?.welcome?.leaveChannelMessage; - - await guildDB?.save()?.then(async () => { - logger?.silly(`Guild welcome updated.`); - - const interactionEmbedDisabled = new EmbedBuilder() - .setTitle("[:tools:] Welcome") - .setDescription( - "This module is currently disabled, please enable it to continue." - ) - .setColor(successColor) - .addFields( - { - name: "🤖 Status", - value: `${guildDB?.points?.status}`, - inline: true, - }, - { - name: "📈 Rate", - value: `${guildDB?.points?.rate}`, - inline: true, - }, - { - name: "🔨 Minimum Length", - value: `${guildDB?.points?.minimumLength}`, - inline: true, - }, - { - name: "⏰ Timeout", - value: `${guildDB?.points?.timeout}`, - inline: true, - } - ) - .setTimestamp() - .setFooter({ - iconURL: footerIcon, - text: footerText, - }); - - if (!guildDB?.welcome?.status) { - return interaction?.editReply({ - embeds: [interactionEmbedDisabled], - }); - } - - const interactionEmbed = new EmbedBuilder() - .setTitle("[:tools:] Welcome") - .setDescription( - `The following configuration will be used. + const interactionEmbed = new EmbedBuilder() + .setTitle("[:tools:] Welcome") + .setDescription( + `The following configuration will be used. [👋] **Welcome** - ㅤ**Channel**: <#${guildDB?.welcome?.joinChannel}> - ㅤ**Message**: ${guildDB?.welcome?.joinChannelMessage} + ㅤ**Channel**: <#${createGuild.welcomeJoinChannelId}> + ㅤ**Message**: ${createGuild.welcomeJoinChannelMessage} [🚪] **Leave** - ㅤ**Channel**: <#${guildDB?.welcome?.leaveChannel}> - ㅤ**Message**: ${guildDB?.welcome?.leaveChannelMessage}` - ) - .setColor(successColor) - .addFields( - { - name: "🤖 Status", - value: `${guildDB?.points?.status}`, - inline: true, - }, - { - name: "📈 Rate", - value: `${guildDB?.points?.rate}`, - inline: true, - }, - { - name: "🔨 Minimum Length", - value: `${guildDB?.points?.minimumLength}`, - inline: true, - }, - { - name: "⏰ Timeout", - value: `${guildDB?.points?.timeout}`, - inline: true, - } - ) - .setTimestamp() - .setFooter({ - iconURL: footerIcon, - text: footerText, - }); - - await interaction?.editReply({ - embeds: [interactionEmbed], + ㅤ**Channel**: <#${createGuild.welcomeLeaveChannelId}> + ㅤ**Message**: ${createGuild.welcomeLeaveChannelMessage}` + ) + .setColor(successColor) + .setTimestamp() + .setFooter({ + iconURL: footerIcon, + text: footerText, }); - return; + + await interaction?.editReply({ + embeds: [interactionEmbed], }); + return; }, }; From 9a513dd8606dbee6f8d80bd9ec2b9cfe55c41463 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Thu, 20 Oct 2022 13:45:11 +0200 Subject: [PATCH 177/215] =?UTF-8?q?=F0=9F=94=A5=20deprecated=20profile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/profile/index.ts | 31 --------- src/commands/profile/modules/index.ts | 3 - src/commands/profile/modules/view/index.ts | 74 ---------------------- 3 files changed, 108 deletions(-) delete mode 100644 src/commands/profile/index.ts delete mode 100644 src/commands/profile/modules/index.ts delete mode 100644 src/commands/profile/modules/view/index.ts diff --git a/src/commands/profile/index.ts b/src/commands/profile/index.ts deleted file mode 100644 index dc24a42..0000000 --- a/src/commands/profile/index.ts +++ /dev/null @@ -1,31 +0,0 @@ -// Dependencies -import { SlashCommandBuilder } from "@discordjs/builders"; -import { ChatInputCommandInteraction } from "discord.js"; - -// Modules -import modules from "./modules"; - -// Handlers - -export const moduleData = modules; - -// Function -export const builder = new SlashCommandBuilder() - .setName("profile") - .setDescription("Check a profile.") - .addSubcommand(modules.view.builder); - -// Execute the command -export const execute = async (interaction: ChatInputCommandInteraction) => { - const { options } = interaction; - - switch (options.getSubcommand()) { - case "view": { - await modules.view.execute(interaction); - break; - } - default: { - throw new Error("Could not find module for that command"); - } - } -}; diff --git a/src/commands/profile/modules/index.ts b/src/commands/profile/modules/index.ts deleted file mode 100644 index dc539f8..0000000 --- a/src/commands/profile/modules/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import view from "./view"; - -export default { view }; diff --git a/src/commands/profile/modules/view/index.ts b/src/commands/profile/modules/view/index.ts deleted file mode 100644 index e0abb27..0000000 --- a/src/commands/profile/modules/view/index.ts +++ /dev/null @@ -1,74 +0,0 @@ -// Dependencies -import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import { CommandInteraction } from "discord.js"; -// Configurations -// Models - -// Function -export default { - metadata: { guildOnly: true, ephemeral: false }, - - builder: (command: SlashCommandSubcommandBuilder) => { - return command - .setName("view") - .setDescription("View a profile.") - .addUserOption((option) => - option.setName("target").setDescription("The profile you wish to view") - ); - }, - - execute: async (interaction: CommandInteraction) => { - // const { errorColor, footerText, footerIcon } = await getEmbedConfig( - // interaction.guild - // ); // Destructure - // const { client, options, user, guild } = interaction; - // // Target information - // const target = options?.getUser("target"); - // // Discord User Information - // const discordUser = await client?.users?.fetch( - // `${target ? target?.id : user?.id}` - // ); - // if (guild === null) { - // return logger?.silly(`Guild is null`); - // } - // // User Information - // const userObj = await fetchUser(discordUser, guild); - // const embed = new EmbedBuilder() - // .setAuthor({ - // name: `${discordUser?.username}#${discordUser?.discriminator}`, - // iconURL: discordUser?.displayAvatarURL(), - // }) - // .addFields( - // { - // name: `:dollar: Credits`, - // value: `${userObj?.credits || "Not found"}`, - // inline: true, - // }, - // { - // name: `:squeeze_bottle: Level`, - // value: `${userObj?.level || "Not found"}`, - // inline: true, - // }, - // { - // name: `:squeeze_bottle: Points`, - // value: `${userObj?.points || "Not found"}`, - // inline: true, - // }, - // { - // name: `:loudspeaker: Reputation`, - // value: `${userObj?.reputation || "Not found"}`, - // inline: true, - // }, - // { - // name: `:rainbow_flag: Language`, - // value: `${userObj?.language || "Not found"}`, - // inline: true, - // } - // ) - // .setTimestamp() - // .setColor(errorColor) - // .setFooter({ text: footerText, iconURL: footerIcon }); - // // Return interaction reply - // return interaction?.editReply({ embeds: [embed] }); - }, -}; From b500921611fb655f23e9a69031c2ed6a7888628f Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 21 Oct 2022 10:19:50 +0000 Subject: [PATCH 178/215] Restyled by pg_format --- .../20221019063840_init/migration.sql | 12 +- .../20221019064232_init/migration.sql | 21 +++- .../20221019081114_modules/migration.sql | 53 ++++++-- .../20221019081816_modules/migration.sql | 33 +++-- .../20221019113258_modules/migration.sql | 38 ++++-- .../20221019114543_modules/migration.sql | 39 ++++-- .../20221019142757_modules/migration.sql | 23 +++- .../20221019153247_cooldowns/migration.sql | 4 +- .../20221019153652_audit_dates/migration.sql | 118 ++++++++++++++---- .../20221019172846_embedconfig/migration.sql | 42 +++++-- .../20221020081238_cpgg_api/migration.sql | 16 ++- .../migration.sql | 25 +++- .../20221020084922_cooldown_int/migration.sql | 33 +++-- .../migration.sql | 53 ++++++-- .../20221020113312_shop_module/migration.sql | 57 +++++++-- .../migration.sql | 61 +++++++-- .../migration.sql | 71 ++++++++--- .../migration.sql | 73 ++++++++--- 18 files changed, 613 insertions(+), 159 deletions(-) diff --git a/prisma/migrations/20221019063840_init/migration.sql b/prisma/migrations/20221019063840_init/migration.sql index 56ad967..d69499d 100644 --- a/prisma/migrations/20221019063840_init/migration.sql +++ b/prisma/migrations/20221019063840_init/migration.sql @@ -4,21 +4,27 @@ CREATE TABLE "Guild" ( ); -- CreateTable + CREATE TABLE "User" ( "id" TEXT NOT NULL ); -- CreateTable + CREATE TABLE "GuildMember" ( "userId" TEXT NOT NULL, "guildId" TEXT NOT NULL ); -- CreateIndex -CREATE UNIQUE INDEX "Guild_id_key" ON "Guild"("id"); + +CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); -- CreateIndex -CREATE UNIQUE INDEX "User_id_key" ON "User"("id"); + +CREATE UNIQUE INDEX "User_id_key" ON "User" ("id"); -- CreateIndex -CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember"("userId", "guildId"); + +CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember" ("userId", "guildId"); + diff --git a/prisma/migrations/20221019064232_init/migration.sql b/prisma/migrations/20221019064232_init/migration.sql index c1ab212..27ed6aa 100644 --- a/prisma/migrations/20221019064232_init/migration.sql +++ b/prisma/migrations/20221019064232_init/migration.sql @@ -1,14 +1,27 @@ -- RedefineTables -PRAGMA foreign_keys=OFF; +PRAGMA foreign_keys = OFF; + CREATE TABLE "new_GuildMember" ( "userId" TEXT NOT NULL, "guildId" TEXT NOT NULL, CONSTRAINT "GuildMember_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "GuildMember_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_GuildMember" ("guildId", "userId") SELECT "guildId", "userId" FROM "GuildMember"; + +INSERT INTO "new_GuildMember" ("guildId", "userId") +SELECT + "guildId", + "userId" +FROM + "GuildMember"; + DROP TABLE "GuildMember"; + ALTER TABLE "new_GuildMember" RENAME TO "GuildMember"; -CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember"("userId", "guildId"); + +CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember" ("userId", "guildId"); + PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; + +PRAGMA foreign_keys = ON; + diff --git a/prisma/migrations/20221019081114_modules/migration.sql b/prisma/migrations/20221019081114_modules/migration.sql index 2ada6f6..9ebd925 100644 --- a/prisma/migrations/20221019081114_modules/migration.sql +++ b/prisma/migrations/20221019081114_modules/migration.sql @@ -1,8 +1,12 @@ -- AlterTable -ALTER TABLE "GuildMember" ADD COLUMN "creditsEarned" INTEGER; -ALTER TABLE "GuildMember" ADD COLUMN "pointsEarned" INTEGER; +ALTER TABLE "GuildMember" + ADD COLUMN "creditsEarned" INTEGER; + +ALTER TABLE "GuildMember" + ADD COLUMN "pointsEarned" INTEGER; -- CreateTable + CREATE TABLE "GuildCounter" ( "guildId" TEXT NOT NULL, "channelId" TEXT NOT NULL, @@ -12,34 +16,57 @@ CREATE TABLE "GuildCounter" ( ); -- RedefineTables -PRAGMA foreign_keys=OFF; + +PRAGMA foreign_keys = OFF; + CREATE TABLE "new_Guild" ( "id" TEXT NOT NULL, - "creditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "creditsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "creditsRate" INTEGER NOT NULL DEFAULT 1, "creditsTimeout" INTEGER NOT NULL DEFAULT 5, "creditsWorkRate" INTEGER NOT NULL DEFAULT 25, "creditsWorkTimeout" INTEGER NOT NULL DEFAULT 86400, - "pointsEnabled" BOOLEAN NOT NULL DEFAULT false, + "pointsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "pointsRate" INTEGER NOT NULL DEFAULT 1, "pointsTimeout" INTEGER NOT NULL DEFAULT 5, - "reputationsEnabled" BOOLEAN NOT NULL DEFAULT false, - "countersEnabled" BOOLEAN NOT NULL DEFAULT false + "reputationsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, + "countersEnabled" BOOLEAN NOT NULL DEFAULT FALSE ); -INSERT INTO "new_Guild" ("id") SELECT "id" FROM "Guild"; + +INSERT INTO "new_Guild" ("id") +SELECT + "id" +FROM + "Guild"; + DROP TABLE "Guild"; + ALTER TABLE "new_Guild" RENAME TO "Guild"; -CREATE UNIQUE INDEX "Guild_id_key" ON "Guild"("id"); + +CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); + CREATE TABLE "new_User" ( "id" TEXT NOT NULL, "reputationsEarned" INTEGER NOT NULL DEFAULT 0 ); -INSERT INTO "new_User" ("id") SELECT "id" FROM "User"; + +INSERT INTO "new_User" ("id") +SELECT + "id" +FROM + "User"; + DROP TABLE "User"; + ALTER TABLE "new_User" RENAME TO "User"; -CREATE UNIQUE INDEX "User_id_key" ON "User"("id"); + +CREATE UNIQUE INDEX "User_id_key" ON "User" ("id"); + PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; + +PRAGMA foreign_keys = ON; -- CreateIndex -CREATE UNIQUE INDEX "GuildCounter_guildId_channelId_key" ON "GuildCounter"("guildId", "channelId"); + +CREATE UNIQUE INDEX "GuildCounter_guildId_channelId_key" ON "GuildCounter" ("guildId", "channelId"); + diff --git a/prisma/migrations/20221019081816_modules/migration.sql b/prisma/migrations/20221019081816_modules/migration.sql index 4e87e61..4cba8c4 100644 --- a/prisma/migrations/20221019081816_modules/migration.sql +++ b/prisma/migrations/20221019081816_modules/migration.sql @@ -1,13 +1,14 @@ /* - Warnings: + Warnings: - - You are about to drop the column `counter` on the `GuildCounter` table. All the data in the column will be lost. - - You are about to drop the column `word` on the `GuildCounter` table. All the data in the column will be lost. - - Added the required column `triggerWord` to the `GuildCounter` table without a default value. This is not possible if the table is not empty. - -*/ + - You are about to drop the column `counter` on the `GuildCounter` table. All the data in the column will be lost. + - You are about to drop the column `word` on the `GuildCounter` table. All the data in the column will be lost. + - Added the required column `triggerWord` to the `GuildCounter` table without a default value. This is not possible if the table is not empty. + */ -- RedefineTables -PRAGMA foreign_keys=OFF; + +PRAGMA foreign_keys = OFF; + CREATE TABLE "new_GuildCounter" ( "guildId" TEXT NOT NULL, "channelId" TEXT NOT NULL, @@ -15,9 +16,21 @@ CREATE TABLE "new_GuildCounter" ( "count" INTEGER NOT NULL DEFAULT 0, CONSTRAINT "GuildCounter_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_GuildCounter" ("channelId", "guildId") SELECT "channelId", "guildId" FROM "GuildCounter"; + +INSERT INTO "new_GuildCounter" ("channelId", "guildId") +SELECT + "channelId", + "guildId" +FROM + "GuildCounter"; + DROP TABLE "GuildCounter"; + ALTER TABLE "new_GuildCounter" RENAME TO "GuildCounter"; -CREATE UNIQUE INDEX "GuildCounter_guildId_channelId_key" ON "GuildCounter"("guildId", "channelId"); + +CREATE UNIQUE INDEX "GuildCounter_guildId_channelId_key" ON "GuildCounter" ("guildId", "channelId"); + PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; + +PRAGMA foreign_keys = ON; + diff --git a/prisma/migrations/20221019113258_modules/migration.sql b/prisma/migrations/20221019113258_modules/migration.sql index c28690d..d88a0fb 100644 --- a/prisma/migrations/20221019113258_modules/migration.sql +++ b/prisma/migrations/20221019113258_modules/migration.sql @@ -1,22 +1,44 @@ -- RedefineTables -PRAGMA foreign_keys=OFF; +PRAGMA foreign_keys = OFF; + CREATE TABLE "new_Guild" ( "id" TEXT NOT NULL, - "creditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "creditsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "creditsRate" INTEGER NOT NULL DEFAULT 1, "creditsTimeout" INTEGER NOT NULL DEFAULT 5, "creditsWorkRate" INTEGER NOT NULL DEFAULT 25, "creditsWorkTimeout" INTEGER NOT NULL DEFAULT 86400, "creditsMinimumLength" INTEGER NOT NULL DEFAULT 5, - "pointsEnabled" BOOLEAN NOT NULL DEFAULT false, + "pointsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "pointsRate" INTEGER NOT NULL DEFAULT 1, "pointsTimeout" INTEGER NOT NULL DEFAULT 5, - "reputationsEnabled" BOOLEAN NOT NULL DEFAULT false, - "countersEnabled" BOOLEAN NOT NULL DEFAULT false + "reputationsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, + "countersEnabled" BOOLEAN NOT NULL DEFAULT FALSE ); -INSERT INTO "new_Guild" ("countersEnabled", "creditsEnabled", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "id", "pointsEnabled", "pointsRate", "pointsTimeout", "reputationsEnabled") SELECT "countersEnabled", "creditsEnabled", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "id", "pointsEnabled", "pointsRate", "pointsTimeout", "reputationsEnabled" FROM "Guild"; + +INSERT INTO "new_Guild" ("countersEnabled", "creditsEnabled", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "id", "pointsEnabled", "pointsRate", "pointsTimeout", "reputationsEnabled") +SELECT + "countersEnabled", + "creditsEnabled", + "creditsRate", + "creditsTimeout", + "creditsWorkRate", + "creditsWorkTimeout", + "id", + "pointsEnabled", + "pointsRate", + "pointsTimeout", + "reputationsEnabled" +FROM + "Guild"; + DROP TABLE "Guild"; + ALTER TABLE "new_Guild" RENAME TO "Guild"; -CREATE UNIQUE INDEX "Guild_id_key" ON "Guild"("id"); + +CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); + PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; + +PRAGMA foreign_keys = ON; + diff --git a/prisma/migrations/20221019114543_modules/migration.sql b/prisma/migrations/20221019114543_modules/migration.sql index aa9074e..d15916d 100644 --- a/prisma/migrations/20221019114543_modules/migration.sql +++ b/prisma/migrations/20221019114543_modules/migration.sql @@ -1,23 +1,46 @@ -- RedefineTables -PRAGMA foreign_keys=OFF; +PRAGMA foreign_keys = OFF; + CREATE TABLE "new_Guild" ( "id" TEXT NOT NULL, - "creditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "creditsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "creditsRate" INTEGER NOT NULL DEFAULT 1, "creditsTimeout" INTEGER NOT NULL DEFAULT 5, "creditsWorkRate" INTEGER NOT NULL DEFAULT 25, "creditsWorkTimeout" INTEGER NOT NULL DEFAULT 86400, "creditsMinimumLength" INTEGER NOT NULL DEFAULT 5, - "pointsEnabled" BOOLEAN NOT NULL DEFAULT false, + "pointsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "pointsRate" INTEGER NOT NULL DEFAULT 1, "pointsTimeout" INTEGER NOT NULL DEFAULT 5, "pointsMinimumLength" INTEGER NOT NULL DEFAULT 5, - "reputationsEnabled" BOOLEAN NOT NULL DEFAULT false, - "countersEnabled" BOOLEAN NOT NULL DEFAULT false + "reputationsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, + "countersEnabled" BOOLEAN NOT NULL DEFAULT FALSE ); -INSERT INTO "new_Guild" ("countersEnabled", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "id", "pointsEnabled", "pointsRate", "pointsTimeout", "reputationsEnabled") SELECT "countersEnabled", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "id", "pointsEnabled", "pointsRate", "pointsTimeout", "reputationsEnabled" FROM "Guild"; + +INSERT INTO "new_Guild" ("countersEnabled", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "id", "pointsEnabled", "pointsRate", "pointsTimeout", "reputationsEnabled") +SELECT + "countersEnabled", + "creditsEnabled", + "creditsMinimumLength", + "creditsRate", + "creditsTimeout", + "creditsWorkRate", + "creditsWorkTimeout", + "id", + "pointsEnabled", + "pointsRate", + "pointsTimeout", + "reputationsEnabled" +FROM + "Guild"; + DROP TABLE "Guild"; + ALTER TABLE "new_Guild" RENAME TO "Guild"; -CREATE UNIQUE INDEX "Guild_id_key" ON "Guild"("id"); + +CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); + PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; + +PRAGMA foreign_keys = ON; + diff --git a/prisma/migrations/20221019142757_modules/migration.sql b/prisma/migrations/20221019142757_modules/migration.sql index ec153f0..e4bccc3 100644 --- a/prisma/migrations/20221019142757_modules/migration.sql +++ b/prisma/migrations/20221019142757_modules/migration.sql @@ -1,5 +1,6 @@ -- RedefineTables -PRAGMA foreign_keys=OFF; +PRAGMA foreign_keys = OFF; + CREATE TABLE "new_GuildMember" ( "userId" TEXT NOT NULL, "guildId" TEXT NOT NULL, @@ -8,9 +9,23 @@ CREATE TABLE "new_GuildMember" ( CONSTRAINT "GuildMember_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "GuildMember_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_GuildMember" ("creditsEarned", "guildId", "pointsEarned", "userId") SELECT coalesce("creditsEarned", 0) AS "creditsEarned", "guildId", coalesce("pointsEarned", 0) AS "pointsEarned", "userId" FROM "GuildMember"; + +INSERT INTO "new_GuildMember" ("creditsEarned", "guildId", "pointsEarned", "userId") +SELECT + coalesce("creditsEarned", 0) AS "creditsEarned", + "guildId", + coalesce("pointsEarned", 0) AS "pointsEarned", + "userId" +FROM + "GuildMember"; + DROP TABLE "GuildMember"; + ALTER TABLE "new_GuildMember" RENAME TO "GuildMember"; -CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember"("userId", "guildId"); + +CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember" ("userId", "guildId"); + PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; + +PRAGMA foreign_keys = ON; + diff --git a/prisma/migrations/20221019153247_cooldowns/migration.sql b/prisma/migrations/20221019153247_cooldowns/migration.sql index ddaf6d9..58b4dff 100644 --- a/prisma/migrations/20221019153247_cooldowns/migration.sql +++ b/prisma/migrations/20221019153247_cooldowns/migration.sql @@ -9,4 +9,6 @@ CREATE TABLE "Cooldown" ( ); -- CreateIndex -CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown"("guildId", "userId", "timeoutId"); + +CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown" ("guildId", "userId", "timeoutId"); + diff --git a/prisma/migrations/20221019153652_audit_dates/migration.sql b/prisma/migrations/20221019153652_audit_dates/migration.sql index 7bc464b..0171217 100644 --- a/prisma/migrations/20221019153652_audit_dates/migration.sql +++ b/prisma/migrations/20221019153652_audit_dates/migration.sql @@ -1,36 +1,58 @@ /* - Warnings: + Warnings: - - Added the required column `updatedAt` to the `Guild` table without a default value. This is not possible if the table is not empty. - - Added the required column `updatedAt` to the `Cooldown` table without a default value. This is not possible if the table is not empty. - - Added the required column `updatedAt` to the `GuildCounter` table without a default value. This is not possible if the table is not empty. - - Added the required column `updatedAt` to the `User` table without a default value. This is not possible if the table is not empty. - - Added the required column `updatedAt` to the `GuildMember` table without a default value. This is not possible if the table is not empty. - -*/ + - Added the required column `updatedAt` to the `Guild` table without a default value. This is not possible if the table is not empty. + - Added the required column `updatedAt` to the `Cooldown` table without a default value. This is not possible if the table is not empty. + - Added the required column `updatedAt` to the `GuildCounter` table without a default value. This is not possible if the table is not empty. + - Added the required column `updatedAt` to the `User` table without a default value. This is not possible if the table is not empty. + - Added the required column `updatedAt` to the `GuildMember` table without a default value. This is not possible if the table is not empty. + */ -- RedefineTables -PRAGMA foreign_keys=OFF; + +PRAGMA foreign_keys = OFF; + CREATE TABLE "new_Guild" ( "id" TEXT NOT NULL, - "creditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "creditsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "creditsRate" INTEGER NOT NULL DEFAULT 1, "creditsTimeout" INTEGER NOT NULL DEFAULT 5, "creditsWorkRate" INTEGER NOT NULL DEFAULT 25, "creditsWorkTimeout" INTEGER NOT NULL DEFAULT 86400, "creditsMinimumLength" INTEGER NOT NULL DEFAULT 5, - "pointsEnabled" BOOLEAN NOT NULL DEFAULT false, + "pointsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "pointsRate" INTEGER NOT NULL DEFAULT 1, "pointsTimeout" INTEGER NOT NULL DEFAULT 5, "pointsMinimumLength" INTEGER NOT NULL DEFAULT 5, - "reputationsEnabled" BOOLEAN NOT NULL DEFAULT false, - "countersEnabled" BOOLEAN NOT NULL DEFAULT false, + "reputationsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, + "countersEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" DATETIME NOT NULL ); -INSERT INTO "new_Guild" ("countersEnabled", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled") SELECT "countersEnabled", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled" FROM "Guild"; + +INSERT INTO "new_Guild" ("countersEnabled", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled") +SELECT + "countersEnabled", + "creditsEnabled", + "creditsMinimumLength", + "creditsRate", + "creditsTimeout", + "creditsWorkRate", + "creditsWorkTimeout", + "id", + "pointsEnabled", + "pointsMinimumLength", + "pointsRate", + "pointsTimeout", + "reputationsEnabled" +FROM + "Guild"; + DROP TABLE "Guild"; + ALTER TABLE "new_Guild" RENAME TO "Guild"; -CREATE UNIQUE INDEX "Guild_id_key" ON "Guild"("id"); + +CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); + CREATE TABLE "new_Cooldown" ( "guildId" TEXT NOT NULL, "userId" TEXT NOT NULL, @@ -41,10 +63,22 @@ CREATE TABLE "new_Cooldown" ( CONSTRAINT "Cooldown_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "Cooldown_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_Cooldown" ("cooldown", "guildId", "timeoutId", "userId") SELECT "cooldown", "guildId", "timeoutId", "userId" FROM "Cooldown"; + +INSERT INTO "new_Cooldown" ("cooldown", "guildId", "timeoutId", "userId") +SELECT + "cooldown", + "guildId", + "timeoutId", + "userId" +FROM + "Cooldown"; + DROP TABLE "Cooldown"; + ALTER TABLE "new_Cooldown" RENAME TO "Cooldown"; -CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown"("guildId", "userId", "timeoutId"); + +CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown" ("guildId", "userId", "timeoutId"); + CREATE TABLE "new_GuildCounter" ( "guildId" TEXT NOT NULL, "channelId" TEXT NOT NULL, @@ -54,20 +88,42 @@ CREATE TABLE "new_GuildCounter" ( "updatedAt" DATETIME NOT NULL, CONSTRAINT "GuildCounter_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_GuildCounter" ("channelId", "count", "guildId", "triggerWord") SELECT "channelId", "count", "guildId", "triggerWord" FROM "GuildCounter"; + +INSERT INTO "new_GuildCounter" ("channelId", "count", "guildId", "triggerWord") +SELECT + "channelId", + "count", + "guildId", + "triggerWord" +FROM + "GuildCounter"; + DROP TABLE "GuildCounter"; + ALTER TABLE "new_GuildCounter" RENAME TO "GuildCounter"; -CREATE UNIQUE INDEX "GuildCounter_guildId_channelId_key" ON "GuildCounter"("guildId", "channelId"); + +CREATE UNIQUE INDEX "GuildCounter_guildId_channelId_key" ON "GuildCounter" ("guildId", "channelId"); + CREATE TABLE "new_User" ( "id" TEXT NOT NULL, "reputationsEarned" INTEGER NOT NULL DEFAULT 0, "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" DATETIME NOT NULL ); -INSERT INTO "new_User" ("id", "reputationsEarned") SELECT "id", "reputationsEarned" FROM "User"; + +INSERT INTO "new_User" ("id", "reputationsEarned") +SELECT + "id", + "reputationsEarned" +FROM + "User"; + DROP TABLE "User"; + ALTER TABLE "new_User" RENAME TO "User"; -CREATE UNIQUE INDEX "User_id_key" ON "User"("id"); + +CREATE UNIQUE INDEX "User_id_key" ON "User" ("id"); + CREATE TABLE "new_GuildMember" ( "userId" TEXT NOT NULL, "guildId" TEXT NOT NULL, @@ -78,9 +134,23 @@ CREATE TABLE "new_GuildMember" ( CONSTRAINT "GuildMember_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "GuildMember_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_GuildMember" ("creditsEarned", "guildId", "pointsEarned", "userId") SELECT "creditsEarned", "guildId", "pointsEarned", "userId" FROM "GuildMember"; + +INSERT INTO "new_GuildMember" ("creditsEarned", "guildId", "pointsEarned", "userId") +SELECT + "creditsEarned", + "guildId", + "pointsEarned", + "userId" +FROM + "GuildMember"; + DROP TABLE "GuildMember"; + ALTER TABLE "new_GuildMember" RENAME TO "GuildMember"; -CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember"("userId", "guildId"); + +CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember" ("userId", "guildId"); + PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; + +PRAGMA foreign_keys = ON; + diff --git a/prisma/migrations/20221019172846_embedconfig/migration.sql b/prisma/migrations/20221019172846_embedconfig/migration.sql index f2d2415..aeea219 100644 --- a/prisma/migrations/20221019172846_embedconfig/migration.sql +++ b/prisma/migrations/20221019172846_embedconfig/migration.sql @@ -1,5 +1,6 @@ -- RedefineTables -PRAGMA foreign_keys=OFF; +PRAGMA foreign_keys = OFF; + CREATE TABLE "new_Guild" ( "id" TEXT NOT NULL, "embedColorSuccess" TEXT NOT NULL DEFAULT '#22bb33', @@ -7,24 +8,49 @@ CREATE TABLE "new_Guild" ( "embedColorError" TEXT NOT NULL DEFAULT '#bb2124', "embedFooterText" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg/xyter', "embedFooterIcon" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg.png', - "creditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "creditsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "creditsRate" INTEGER NOT NULL DEFAULT 1, "creditsTimeout" INTEGER NOT NULL DEFAULT 5, "creditsWorkRate" INTEGER NOT NULL DEFAULT 25, "creditsWorkTimeout" INTEGER NOT NULL DEFAULT 86400, "creditsMinimumLength" INTEGER NOT NULL DEFAULT 5, - "pointsEnabled" BOOLEAN NOT NULL DEFAULT false, + "pointsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "pointsRate" INTEGER NOT NULL DEFAULT 1, "pointsTimeout" INTEGER NOT NULL DEFAULT 5, "pointsMinimumLength" INTEGER NOT NULL DEFAULT 5, - "reputationsEnabled" BOOLEAN NOT NULL DEFAULT false, - "countersEnabled" BOOLEAN NOT NULL DEFAULT false, + "reputationsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, + "countersEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" DATETIME NOT NULL ); -INSERT INTO "new_Guild" ("countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "updatedAt") SELECT "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "updatedAt" FROM "Guild"; + +INSERT INTO "new_Guild" ("countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "updatedAt") +SELECT + "countersEnabled", + "createdAt", + "creditsEnabled", + "creditsMinimumLength", + "creditsRate", + "creditsTimeout", + "creditsWorkRate", + "creditsWorkTimeout", + "id", + "pointsEnabled", + "pointsMinimumLength", + "pointsRate", + "pointsTimeout", + "reputationsEnabled", + "updatedAt" +FROM + "Guild"; + DROP TABLE "Guild"; + ALTER TABLE "new_Guild" RENAME TO "Guild"; -CREATE UNIQUE INDEX "Guild_id_key" ON "Guild"("id"); + +CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); + PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; + +PRAGMA foreign_keys = ON; + diff --git a/prisma/migrations/20221020081238_cpgg_api/migration.sql b/prisma/migrations/20221020081238_cpgg_api/migration.sql index cf7293f..c69d565 100644 --- a/prisma/migrations/20221020081238_cpgg_api/migration.sql +++ b/prisma/migrations/20221020081238_cpgg_api/migration.sql @@ -1,5 +1,13 @@ -- AlterTable -ALTER TABLE "Guild" ADD COLUMN "apiCpggTokenContent" TEXT; -ALTER TABLE "Guild" ADD COLUMN "apiCpggTokenIv" TEXT; -ALTER TABLE "Guild" ADD COLUMN "apiCpggUrlContent" TEXT; -ALTER TABLE "Guild" ADD COLUMN "apiCpggUrlIv" TEXT; +ALTER TABLE "Guild" + ADD COLUMN "apiCpggTokenContent" TEXT; + +ALTER TABLE "Guild" + ADD COLUMN "apiCpggTokenIv" TEXT; + +ALTER TABLE "Guild" + ADD COLUMN "apiCpggUrlContent" TEXT; + +ALTER TABLE "Guild" + ADD COLUMN "apiCpggUrlIv" TEXT; + diff --git a/prisma/migrations/20221020084750_cooldown_string/migration.sql b/prisma/migrations/20221020084750_cooldown_string/migration.sql index 24aefc0..20f0bf5 100644 --- a/prisma/migrations/20221020084750_cooldown_string/migration.sql +++ b/prisma/migrations/20221020084750_cooldown_string/migration.sql @@ -1,5 +1,6 @@ -- RedefineTables -PRAGMA foreign_keys=OFF; +PRAGMA foreign_keys = OFF; + CREATE TABLE "new_Cooldown" ( "guildId" TEXT NOT NULL, "userId" TEXT NOT NULL, @@ -10,9 +11,25 @@ CREATE TABLE "new_Cooldown" ( CONSTRAINT "Cooldown_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "Cooldown_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_Cooldown" ("cooldown", "createdAt", "guildId", "timeoutId", "updatedAt", "userId") SELECT "cooldown", "createdAt", "guildId", "timeoutId", "updatedAt", "userId" FROM "Cooldown"; + +INSERT INTO "new_Cooldown" ("cooldown", "createdAt", "guildId", "timeoutId", "updatedAt", "userId") +SELECT + "cooldown", + "createdAt", + "guildId", + "timeoutId", + "updatedAt", + "userId" +FROM + "Cooldown"; + DROP TABLE "Cooldown"; + ALTER TABLE "new_Cooldown" RENAME TO "Cooldown"; -CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown"("guildId", "userId", "timeoutId"); + +CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown" ("guildId", "userId", "timeoutId"); + PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; + +PRAGMA foreign_keys = ON; + diff --git a/prisma/migrations/20221020084922_cooldown_int/migration.sql b/prisma/migrations/20221020084922_cooldown_int/migration.sql index 51c6d0b..282e7d1 100644 --- a/prisma/migrations/20221020084922_cooldown_int/migration.sql +++ b/prisma/migrations/20221020084922_cooldown_int/migration.sql @@ -1,11 +1,12 @@ /* - Warnings: + Warnings: - - You are about to alter the column `cooldown` on the `Cooldown` table. The data in that column could be lost. The data in that column will be cast from `String` to `Int`. - -*/ + - You are about to alter the column `cooldown` on the `Cooldown` table. The data in that column could be lost. The data in that column will be cast from `String` to `Int`. + */ -- RedefineTables -PRAGMA foreign_keys=OFF; + +PRAGMA foreign_keys = OFF; + CREATE TABLE "new_Cooldown" ( "guildId" TEXT NOT NULL, "userId" TEXT NOT NULL, @@ -16,9 +17,25 @@ CREATE TABLE "new_Cooldown" ( CONSTRAINT "Cooldown_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "Cooldown_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_Cooldown" ("cooldown", "createdAt", "guildId", "timeoutId", "updatedAt", "userId") SELECT "cooldown", "createdAt", "guildId", "timeoutId", "updatedAt", "userId" FROM "Cooldown"; + +INSERT INTO "new_Cooldown" ("cooldown", "createdAt", "guildId", "timeoutId", "updatedAt", "userId") +SELECT + "cooldown", + "createdAt", + "guildId", + "timeoutId", + "updatedAt", + "userId" +FROM + "Cooldown"; + DROP TABLE "Cooldown"; + ALTER TABLE "new_Cooldown" RENAME TO "Cooldown"; -CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown"("guildId", "userId", "timeoutId"); + +CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown" ("guildId", "userId", "timeoutId"); + PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; + +PRAGMA foreign_keys = ON; + diff --git a/prisma/migrations/20221020111948_audits_module/migration.sql b/prisma/migrations/20221020111948_audits_module/migration.sql index 46db9e6..b1b6293 100644 --- a/prisma/migrations/20221020111948_audits_module/migration.sql +++ b/prisma/migrations/20221020111948_audits_module/migration.sql @@ -1,5 +1,6 @@ -- RedefineTables -PRAGMA foreign_keys=OFF; +PRAGMA foreign_keys = OFF; + CREATE TABLE "new_Guild" ( "id" TEXT NOT NULL, "embedColorSuccess" TEXT NOT NULL DEFAULT '#22bb33', @@ -7,30 +8,64 @@ CREATE TABLE "new_Guild" ( "embedColorError" TEXT NOT NULL DEFAULT '#bb2124', "embedFooterText" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg/xyter', "embedFooterIcon" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg.png', - "creditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "creditsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "creditsRate" INTEGER NOT NULL DEFAULT 1, "creditsTimeout" INTEGER NOT NULL DEFAULT 5, "creditsWorkRate" INTEGER NOT NULL DEFAULT 25, "creditsWorkTimeout" INTEGER NOT NULL DEFAULT 86400, "creditsMinimumLength" INTEGER NOT NULL DEFAULT 5, - "pointsEnabled" BOOLEAN NOT NULL DEFAULT false, + "pointsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "pointsRate" INTEGER NOT NULL DEFAULT 1, "pointsTimeout" INTEGER NOT NULL DEFAULT 5, "pointsMinimumLength" INTEGER NOT NULL DEFAULT 5, - "reputationsEnabled" BOOLEAN NOT NULL DEFAULT false, - "countersEnabled" BOOLEAN NOT NULL DEFAULT false, + "reputationsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, + "countersEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "apiCpggUrlIv" TEXT, "apiCpggUrlContent" TEXT, "apiCpggTokenIv" TEXT, "apiCpggTokenContent" TEXT, - "auditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "auditsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "auditsChannelId" TEXT, "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" DATETIME NOT NULL ); -INSERT INTO "new_Guild" ("apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "updatedAt") SELECT "apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "updatedAt" FROM "Guild"; + +INSERT INTO "new_Guild" ("apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "updatedAt") +SELECT + "apiCpggTokenContent", + "apiCpggTokenIv", + "apiCpggUrlContent", + "apiCpggUrlIv", + "countersEnabled", + "createdAt", + "creditsEnabled", + "creditsMinimumLength", + "creditsRate", + "creditsTimeout", + "creditsWorkRate", + "creditsWorkTimeout", + "embedColorError", + "embedColorSuccess", + "embedColorWait", + "embedFooterIcon", + "embedFooterText", + "id", + "pointsEnabled", + "pointsMinimumLength", + "pointsRate", + "pointsTimeout", + "reputationsEnabled", + "updatedAt" +FROM + "Guild"; + DROP TABLE "Guild"; + ALTER TABLE "new_Guild" RENAME TO "Guild"; -CREATE UNIQUE INDEX "Guild_id_key" ON "Guild"("id"); + +CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); + PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; + +PRAGMA foreign_keys = ON; + diff --git a/prisma/migrations/20221020113312_shop_module/migration.sql b/prisma/migrations/20221020113312_shop_module/migration.sql index 12a71d6..14cd966 100644 --- a/prisma/migrations/20221020113312_shop_module/migration.sql +++ b/prisma/migrations/20221020113312_shop_module/migration.sql @@ -1,5 +1,6 @@ -- RedefineTables -PRAGMA foreign_keys=OFF; +PRAGMA foreign_keys = OFF; + CREATE TABLE "new_Guild" ( "id" TEXT NOT NULL, "embedColorSuccess" TEXT NOT NULL DEFAULT '#22bb33', @@ -7,32 +8,68 @@ CREATE TABLE "new_Guild" ( "embedColorError" TEXT NOT NULL DEFAULT '#bb2124', "embedFooterText" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg/xyter', "embedFooterIcon" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg.png', - "creditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "creditsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "creditsRate" INTEGER NOT NULL DEFAULT 1, "creditsTimeout" INTEGER NOT NULL DEFAULT 5, "creditsWorkRate" INTEGER NOT NULL DEFAULT 25, "creditsWorkTimeout" INTEGER NOT NULL DEFAULT 86400, "creditsMinimumLength" INTEGER NOT NULL DEFAULT 5, - "pointsEnabled" BOOLEAN NOT NULL DEFAULT false, + "pointsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "pointsRate" INTEGER NOT NULL DEFAULT 1, "pointsTimeout" INTEGER NOT NULL DEFAULT 5, "pointsMinimumLength" INTEGER NOT NULL DEFAULT 5, - "reputationsEnabled" BOOLEAN NOT NULL DEFAULT false, - "countersEnabled" BOOLEAN NOT NULL DEFAULT false, + "reputationsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, + "countersEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "apiCpggUrlIv" TEXT, "apiCpggUrlContent" TEXT, "apiCpggTokenIv" TEXT, "apiCpggTokenContent" TEXT, - "auditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "auditsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "auditsChannelId" TEXT, - "shopRolesEnabled" BOOLEAN NOT NULL DEFAULT false, + "shopRolesEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "shopRolesPricePerHour" INTEGER NOT NULL DEFAULT 5, "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" DATETIME NOT NULL ); -INSERT INTO "new_Guild" ("apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "updatedAt") SELECT "apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "updatedAt" FROM "Guild"; + +INSERT INTO "new_Guild" ("apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "updatedAt") +SELECT + "apiCpggTokenContent", + "apiCpggTokenIv", + "apiCpggUrlContent", + "apiCpggUrlIv", + "auditsChannelId", + "auditsEnabled", + "countersEnabled", + "createdAt", + "creditsEnabled", + "creditsMinimumLength", + "creditsRate", + "creditsTimeout", + "creditsWorkRate", + "creditsWorkTimeout", + "embedColorError", + "embedColorSuccess", + "embedColorWait", + "embedFooterIcon", + "embedFooterText", + "id", + "pointsEnabled", + "pointsMinimumLength", + "pointsRate", + "pointsTimeout", + "reputationsEnabled", + "updatedAt" +FROM + "Guild"; + DROP TABLE "Guild"; + ALTER TABLE "new_Guild" RENAME TO "Guild"; -CREATE UNIQUE INDEX "Guild_id_key" ON "Guild"("id"); + +CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); + PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; + +PRAGMA foreign_keys = ON; + diff --git a/prisma/migrations/20221020113704_welcome_module/migration.sql b/prisma/migrations/20221020113704_welcome_module/migration.sql index c69df84..0c55776 100644 --- a/prisma/migrations/20221020113704_welcome_module/migration.sql +++ b/prisma/migrations/20221020113704_welcome_module/migration.sql @@ -1,5 +1,6 @@ -- RedefineTables -PRAGMA foreign_keys=OFF; +PRAGMA foreign_keys = OFF; + CREATE TABLE "new_Guild" ( "id" TEXT NOT NULL, "embedColorSuccess" TEXT NOT NULL DEFAULT '#22bb33', @@ -7,35 +8,73 @@ CREATE TABLE "new_Guild" ( "embedColorError" TEXT NOT NULL DEFAULT '#bb2124', "embedFooterText" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg/xyter', "embedFooterIcon" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg.png', - "creditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "creditsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "creditsRate" INTEGER NOT NULL DEFAULT 1, "creditsTimeout" INTEGER NOT NULL DEFAULT 5, "creditsWorkRate" INTEGER NOT NULL DEFAULT 25, "creditsWorkTimeout" INTEGER NOT NULL DEFAULT 86400, "creditsMinimumLength" INTEGER NOT NULL DEFAULT 5, - "pointsEnabled" BOOLEAN NOT NULL DEFAULT false, + "pointsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "pointsRate" INTEGER NOT NULL DEFAULT 1, "pointsTimeout" INTEGER NOT NULL DEFAULT 5, "pointsMinimumLength" INTEGER NOT NULL DEFAULT 5, - "reputationsEnabled" BOOLEAN NOT NULL DEFAULT false, - "countersEnabled" BOOLEAN NOT NULL DEFAULT false, + "reputationsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, + "countersEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "apiCpggUrlIv" TEXT, "apiCpggUrlContent" TEXT, "apiCpggTokenIv" TEXT, "apiCpggTokenContent" TEXT, - "auditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "auditsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "auditsChannelId" TEXT, - "shopRolesEnabled" BOOLEAN NOT NULL DEFAULT false, + "shopRolesEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "shopRolesPricePerHour" INTEGER NOT NULL DEFAULT 5, - "welcomeEnabled" BOOLEAN NOT NULL DEFAULT false, + "welcomeEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "welcomeJoinChannelId" TEXT, "welcomejoinChannelMessahe" TEXT, "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" DATETIME NOT NULL ); -INSERT INTO "new_Guild" ("apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt") SELECT "apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt" FROM "Guild"; + +INSERT INTO "new_Guild" ("apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt") +SELECT + "apiCpggTokenContent", + "apiCpggTokenIv", + "apiCpggUrlContent", + "apiCpggUrlIv", + "auditsChannelId", + "auditsEnabled", + "countersEnabled", + "createdAt", + "creditsEnabled", + "creditsMinimumLength", + "creditsRate", + "creditsTimeout", + "creditsWorkRate", + "creditsWorkTimeout", + "embedColorError", + "embedColorSuccess", + "embedColorWait", + "embedFooterIcon", + "embedFooterText", + "id", + "pointsEnabled", + "pointsMinimumLength", + "pointsRate", + "pointsTimeout", + "reputationsEnabled", + "shopRolesEnabled", + "shopRolesPricePerHour", + "updatedAt" +FROM + "Guild"; + DROP TABLE "Guild"; + ALTER TABLE "new_Guild" RENAME TO "Guild"; -CREATE UNIQUE INDEX "Guild_id_key" ON "Guild"("id"); + +CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); + PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; + +PRAGMA foreign_keys = ON; + diff --git a/prisma/migrations/20221020113756_welcome_module_correction/migration.sql b/prisma/migrations/20221020113756_welcome_module_correction/migration.sql index f6817b0..d2e95ac 100644 --- a/prisma/migrations/20221020113756_welcome_module_correction/migration.sql +++ b/prisma/migrations/20221020113756_welcome_module_correction/migration.sql @@ -1,11 +1,12 @@ /* - Warnings: + Warnings: - - You are about to drop the column `welcomejoinChannelMessahe` on the `Guild` table. All the data in the column will be lost. - -*/ + - You are about to drop the column `welcomejoinChannelMessahe` on the `Guild` table. All the data in the column will be lost. + */ -- RedefineTables -PRAGMA foreign_keys=OFF; + +PRAGMA foreign_keys = OFF; + CREATE TABLE "new_Guild" ( "id" TEXT NOT NULL, "embedColorSuccess" TEXT NOT NULL DEFAULT '#22bb33', @@ -13,27 +14,27 @@ CREATE TABLE "new_Guild" ( "embedColorError" TEXT NOT NULL DEFAULT '#bb2124', "embedFooterText" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg/xyter', "embedFooterIcon" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg.png', - "creditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "creditsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "creditsRate" INTEGER NOT NULL DEFAULT 1, "creditsTimeout" INTEGER NOT NULL DEFAULT 5, "creditsWorkRate" INTEGER NOT NULL DEFAULT 25, "creditsWorkTimeout" INTEGER NOT NULL DEFAULT 86400, "creditsMinimumLength" INTEGER NOT NULL DEFAULT 5, - "pointsEnabled" BOOLEAN NOT NULL DEFAULT false, + "pointsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "pointsRate" INTEGER NOT NULL DEFAULT 1, "pointsTimeout" INTEGER NOT NULL DEFAULT 5, "pointsMinimumLength" INTEGER NOT NULL DEFAULT 5, - "reputationsEnabled" BOOLEAN NOT NULL DEFAULT false, - "countersEnabled" BOOLEAN NOT NULL DEFAULT false, + "reputationsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, + "countersEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "apiCpggUrlIv" TEXT, "apiCpggUrlContent" TEXT, "apiCpggTokenIv" TEXT, "apiCpggTokenContent" TEXT, - "auditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "auditsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "auditsChannelId" TEXT, - "shopRolesEnabled" BOOLEAN NOT NULL DEFAULT false, + "shopRolesEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "shopRolesPricePerHour" INTEGER NOT NULL DEFAULT 5, - "welcomeEnabled" BOOLEAN NOT NULL DEFAULT false, + "welcomeEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "welcomeJoinChannelId" TEXT, "welcomeJoinChannelMessahe" TEXT, "welcomeLeaveChannelId" TEXT, @@ -41,9 +42,49 @@ CREATE TABLE "new_Guild" ( "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" DATETIME NOT NULL ); -INSERT INTO "new_Guild" ("apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt", "welcomeEnabled", "welcomeJoinChannelId") SELECT "apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt", "welcomeEnabled", "welcomeJoinChannelId" FROM "Guild"; + +INSERT INTO "new_Guild" ("apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt", "welcomeEnabled", "welcomeJoinChannelId") +SELECT + "apiCpggTokenContent", + "apiCpggTokenIv", + "apiCpggUrlContent", + "apiCpggUrlIv", + "auditsChannelId", + "auditsEnabled", + "countersEnabled", + "createdAt", + "creditsEnabled", + "creditsMinimumLength", + "creditsRate", + "creditsTimeout", + "creditsWorkRate", + "creditsWorkTimeout", + "embedColorError", + "embedColorSuccess", + "embedColorWait", + "embedFooterIcon", + "embedFooterText", + "id", + "pointsEnabled", + "pointsMinimumLength", + "pointsRate", + "pointsTimeout", + "reputationsEnabled", + "shopRolesEnabled", + "shopRolesPricePerHour", + "updatedAt", + "welcomeEnabled", + "welcomeJoinChannelId" +FROM + "Guild"; + DROP TABLE "Guild"; + ALTER TABLE "new_Guild" RENAME TO "Guild"; -CREATE UNIQUE INDEX "Guild_id_key" ON "Guild"("id"); + +CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); + PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; + +PRAGMA foreign_keys = ON; + diff --git a/prisma/migrations/20221020113831_welcome_module_correction/migration.sql b/prisma/migrations/20221020113831_welcome_module_correction/migration.sql index 5ee06ca..191112f 100644 --- a/prisma/migrations/20221020113831_welcome_module_correction/migration.sql +++ b/prisma/migrations/20221020113831_welcome_module_correction/migration.sql @@ -1,11 +1,12 @@ /* - Warnings: + Warnings: - - You are about to drop the column `welcomeJoinChannelMessahe` on the `Guild` table. All the data in the column will be lost. - -*/ + - You are about to drop the column `welcomeJoinChannelMessahe` on the `Guild` table. All the data in the column will be lost. + */ -- RedefineTables -PRAGMA foreign_keys=OFF; + +PRAGMA foreign_keys = OFF; + CREATE TABLE "new_Guild" ( "id" TEXT NOT NULL, "embedColorSuccess" TEXT NOT NULL DEFAULT '#22bb33', @@ -13,27 +14,27 @@ CREATE TABLE "new_Guild" ( "embedColorError" TEXT NOT NULL DEFAULT '#bb2124', "embedFooterText" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg/xyter', "embedFooterIcon" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg.png', - "creditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "creditsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "creditsRate" INTEGER NOT NULL DEFAULT 1, "creditsTimeout" INTEGER NOT NULL DEFAULT 5, "creditsWorkRate" INTEGER NOT NULL DEFAULT 25, "creditsWorkTimeout" INTEGER NOT NULL DEFAULT 86400, "creditsMinimumLength" INTEGER NOT NULL DEFAULT 5, - "pointsEnabled" BOOLEAN NOT NULL DEFAULT false, + "pointsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "pointsRate" INTEGER NOT NULL DEFAULT 1, "pointsTimeout" INTEGER NOT NULL DEFAULT 5, "pointsMinimumLength" INTEGER NOT NULL DEFAULT 5, - "reputationsEnabled" BOOLEAN NOT NULL DEFAULT false, - "countersEnabled" BOOLEAN NOT NULL DEFAULT false, + "reputationsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, + "countersEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "apiCpggUrlIv" TEXT, "apiCpggUrlContent" TEXT, "apiCpggTokenIv" TEXT, "apiCpggTokenContent" TEXT, - "auditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "auditsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "auditsChannelId" TEXT, - "shopRolesEnabled" BOOLEAN NOT NULL DEFAULT false, + "shopRolesEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "shopRolesPricePerHour" INTEGER NOT NULL DEFAULT 5, - "welcomeEnabled" BOOLEAN NOT NULL DEFAULT false, + "welcomeEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "welcomeJoinChannelId" TEXT, "welcomeJoinChannelMessage" TEXT, "welcomeLeaveChannelId" TEXT, @@ -41,9 +42,51 @@ CREATE TABLE "new_Guild" ( "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" DATETIME NOT NULL ); -INSERT INTO "new_Guild" ("apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt", "welcomeEnabled", "welcomeJoinChannelId", "welcomeLeaveChannelId", "welcomeLeaveChannelMessage") SELECT "apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt", "welcomeEnabled", "welcomeJoinChannelId", "welcomeLeaveChannelId", "welcomeLeaveChannelMessage" FROM "Guild"; + +INSERT INTO "new_Guild" ("apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt", "welcomeEnabled", "welcomeJoinChannelId", "welcomeLeaveChannelId", "welcomeLeaveChannelMessage") +SELECT + "apiCpggTokenContent", + "apiCpggTokenIv", + "apiCpggUrlContent", + "apiCpggUrlIv", + "auditsChannelId", + "auditsEnabled", + "countersEnabled", + "createdAt", + "creditsEnabled", + "creditsMinimumLength", + "creditsRate", + "creditsTimeout", + "creditsWorkRate", + "creditsWorkTimeout", + "embedColorError", + "embedColorSuccess", + "embedColorWait", + "embedFooterIcon", + "embedFooterText", + "id", + "pointsEnabled", + "pointsMinimumLength", + "pointsRate", + "pointsTimeout", + "reputationsEnabled", + "shopRolesEnabled", + "shopRolesPricePerHour", + "updatedAt", + "welcomeEnabled", + "welcomeJoinChannelId", + "welcomeLeaveChannelId", + "welcomeLeaveChannelMessage" +FROM + "Guild"; + DROP TABLE "Guild"; + ALTER TABLE "new_Guild" RENAME TO "Guild"; -CREATE UNIQUE INDEX "Guild_id_key" ON "Guild"("id"); + +CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); + PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; + +PRAGMA foreign_keys = ON; + From f1ddaf7df98b9279de7c2c8201ca43473dd4c89a Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 21 Oct 2022 10:19:54 +0000 Subject: [PATCH 179/215] Restyled by whitespace --- prisma/migrations/20221019063840_init/migration.sql | 1 - prisma/migrations/20221019064232_init/migration.sql | 1 - prisma/migrations/20221019081114_modules/migration.sql | 1 - prisma/migrations/20221019081816_modules/migration.sql | 1 - prisma/migrations/20221019113258_modules/migration.sql | 1 - prisma/migrations/20221019114543_modules/migration.sql | 1 - prisma/migrations/20221019142757_modules/migration.sql | 1 - prisma/migrations/20221019153247_cooldowns/migration.sql | 1 - prisma/migrations/20221019153652_audit_dates/migration.sql | 1 - prisma/migrations/20221019172846_embedconfig/migration.sql | 1 - prisma/migrations/20221020081238_cpgg_api/migration.sql | 1 - prisma/migrations/20221020084750_cooldown_string/migration.sql | 1 - prisma/migrations/20221020084922_cooldown_int/migration.sql | 1 - prisma/migrations/20221020111948_audits_module/migration.sql | 1 - prisma/migrations/20221020113312_shop_module/migration.sql | 1 - prisma/migrations/20221020113704_welcome_module/migration.sql | 1 - .../20221020113756_welcome_module_correction/migration.sql | 1 - .../20221020113831_welcome_module_correction/migration.sql | 1 - prisma/migrations/migration_lock.toml | 2 +- 19 files changed, 1 insertion(+), 19 deletions(-) diff --git a/prisma/migrations/20221019063840_init/migration.sql b/prisma/migrations/20221019063840_init/migration.sql index d69499d..d7577f0 100644 --- a/prisma/migrations/20221019063840_init/migration.sql +++ b/prisma/migrations/20221019063840_init/migration.sql @@ -27,4 +27,3 @@ CREATE UNIQUE INDEX "User_id_key" ON "User" ("id"); -- CreateIndex CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember" ("userId", "guildId"); - diff --git a/prisma/migrations/20221019064232_init/migration.sql b/prisma/migrations/20221019064232_init/migration.sql index 27ed6aa..2028506 100644 --- a/prisma/migrations/20221019064232_init/migration.sql +++ b/prisma/migrations/20221019064232_init/migration.sql @@ -24,4 +24,3 @@ CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember" ("userId", PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; - diff --git a/prisma/migrations/20221019081114_modules/migration.sql b/prisma/migrations/20221019081114_modules/migration.sql index 9ebd925..d20c517 100644 --- a/prisma/migrations/20221019081114_modules/migration.sql +++ b/prisma/migrations/20221019081114_modules/migration.sql @@ -69,4 +69,3 @@ PRAGMA foreign_keys = ON; -- CreateIndex CREATE UNIQUE INDEX "GuildCounter_guildId_channelId_key" ON "GuildCounter" ("guildId", "channelId"); - diff --git a/prisma/migrations/20221019081816_modules/migration.sql b/prisma/migrations/20221019081816_modules/migration.sql index 4cba8c4..d2fcde5 100644 --- a/prisma/migrations/20221019081816_modules/migration.sql +++ b/prisma/migrations/20221019081816_modules/migration.sql @@ -33,4 +33,3 @@ CREATE UNIQUE INDEX "GuildCounter_guildId_channelId_key" ON "GuildCounter" ("gui PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; - diff --git a/prisma/migrations/20221019113258_modules/migration.sql b/prisma/migrations/20221019113258_modules/migration.sql index d88a0fb..a22b2a3 100644 --- a/prisma/migrations/20221019113258_modules/migration.sql +++ b/prisma/migrations/20221019113258_modules/migration.sql @@ -41,4 +41,3 @@ CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; - diff --git a/prisma/migrations/20221019114543_modules/migration.sql b/prisma/migrations/20221019114543_modules/migration.sql index d15916d..0d89d31 100644 --- a/prisma/migrations/20221019114543_modules/migration.sql +++ b/prisma/migrations/20221019114543_modules/migration.sql @@ -43,4 +43,3 @@ CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; - diff --git a/prisma/migrations/20221019142757_modules/migration.sql b/prisma/migrations/20221019142757_modules/migration.sql index e4bccc3..387fb6e 100644 --- a/prisma/migrations/20221019142757_modules/migration.sql +++ b/prisma/migrations/20221019142757_modules/migration.sql @@ -28,4 +28,3 @@ CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember" ("userId", PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; - diff --git a/prisma/migrations/20221019153247_cooldowns/migration.sql b/prisma/migrations/20221019153247_cooldowns/migration.sql index 58b4dff..b85f815 100644 --- a/prisma/migrations/20221019153247_cooldowns/migration.sql +++ b/prisma/migrations/20221019153247_cooldowns/migration.sql @@ -11,4 +11,3 @@ CREATE TABLE "Cooldown" ( -- CreateIndex CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown" ("guildId", "userId", "timeoutId"); - diff --git a/prisma/migrations/20221019153652_audit_dates/migration.sql b/prisma/migrations/20221019153652_audit_dates/migration.sql index 0171217..fd40071 100644 --- a/prisma/migrations/20221019153652_audit_dates/migration.sql +++ b/prisma/migrations/20221019153652_audit_dates/migration.sql @@ -153,4 +153,3 @@ CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember" ("userId", PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; - diff --git a/prisma/migrations/20221019172846_embedconfig/migration.sql b/prisma/migrations/20221019172846_embedconfig/migration.sql index aeea219..f404f36 100644 --- a/prisma/migrations/20221019172846_embedconfig/migration.sql +++ b/prisma/migrations/20221019172846_embedconfig/migration.sql @@ -53,4 +53,3 @@ CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; - diff --git a/prisma/migrations/20221020081238_cpgg_api/migration.sql b/prisma/migrations/20221020081238_cpgg_api/migration.sql index c69d565..6b056d0 100644 --- a/prisma/migrations/20221020081238_cpgg_api/migration.sql +++ b/prisma/migrations/20221020081238_cpgg_api/migration.sql @@ -10,4 +10,3 @@ ALTER TABLE "Guild" ALTER TABLE "Guild" ADD COLUMN "apiCpggUrlIv" TEXT; - diff --git a/prisma/migrations/20221020084750_cooldown_string/migration.sql b/prisma/migrations/20221020084750_cooldown_string/migration.sql index 20f0bf5..a9521a5 100644 --- a/prisma/migrations/20221020084750_cooldown_string/migration.sql +++ b/prisma/migrations/20221020084750_cooldown_string/migration.sql @@ -32,4 +32,3 @@ CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown" ("guil PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; - diff --git a/prisma/migrations/20221020084922_cooldown_int/migration.sql b/prisma/migrations/20221020084922_cooldown_int/migration.sql index 282e7d1..822d410 100644 --- a/prisma/migrations/20221020084922_cooldown_int/migration.sql +++ b/prisma/migrations/20221020084922_cooldown_int/migration.sql @@ -38,4 +38,3 @@ CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown" ("guil PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; - diff --git a/prisma/migrations/20221020111948_audits_module/migration.sql b/prisma/migrations/20221020111948_audits_module/migration.sql index b1b6293..c44d8b6 100644 --- a/prisma/migrations/20221020111948_audits_module/migration.sql +++ b/prisma/migrations/20221020111948_audits_module/migration.sql @@ -68,4 +68,3 @@ CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; - diff --git a/prisma/migrations/20221020113312_shop_module/migration.sql b/prisma/migrations/20221020113312_shop_module/migration.sql index 14cd966..8cdbd73 100644 --- a/prisma/migrations/20221020113312_shop_module/migration.sql +++ b/prisma/migrations/20221020113312_shop_module/migration.sql @@ -72,4 +72,3 @@ CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; - diff --git a/prisma/migrations/20221020113704_welcome_module/migration.sql b/prisma/migrations/20221020113704_welcome_module/migration.sql index 0c55776..7d5c6c5 100644 --- a/prisma/migrations/20221020113704_welcome_module/migration.sql +++ b/prisma/migrations/20221020113704_welcome_module/migration.sql @@ -77,4 +77,3 @@ CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; - diff --git a/prisma/migrations/20221020113756_welcome_module_correction/migration.sql b/prisma/migrations/20221020113756_welcome_module_correction/migration.sql index d2e95ac..1035421 100644 --- a/prisma/migrations/20221020113756_welcome_module_correction/migration.sql +++ b/prisma/migrations/20221020113756_welcome_module_correction/migration.sql @@ -87,4 +87,3 @@ CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; - diff --git a/prisma/migrations/20221020113831_welcome_module_correction/migration.sql b/prisma/migrations/20221020113831_welcome_module_correction/migration.sql index 191112f..0c05518 100644 --- a/prisma/migrations/20221020113831_welcome_module_correction/migration.sql +++ b/prisma/migrations/20221020113831_welcome_module_correction/migration.sql @@ -89,4 +89,3 @@ CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; - diff --git a/prisma/migrations/migration_lock.toml b/prisma/migrations/migration_lock.toml index e5e5c47..6fcf33d 100644 --- a/prisma/migrations/migration_lock.toml +++ b/prisma/migrations/migration_lock.toml @@ -1,3 +1,3 @@ # Please do not edit this file manually # It should be added in your version-control system (i.e. Git) -provider = "sqlite" \ No newline at end of file +provider = "sqlite" From 9c07f320c0b6cb83c6683f08ae9eeb7f3db18c66 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 21 Oct 2022 10:40:35 +0000 Subject: [PATCH 180/215] Pin dependency prisma to 4.5.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d3def57..7d67f33 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,7 @@ "lint-staged": "13.0.3", "nodemon": "2.0.20", "prettier": "2.7.1", - "prisma": "^4.5.0" + "prisma": "4.5.0" }, "lint-staged": { "*.ts": "eslint --cache --fix" From a3ac4ca7fab4dcad726a3b55ce4f8e090a489014 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 15:45:56 +0200 Subject: [PATCH 181/215] =?UTF-8?q?=F0=9F=9A=A7=20Moving=20guard=20classes?= =?UTF-8?q?=20out=20of=20metadata?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handlers/command/index.ts | 30 +++++++++---------- src/helpers/checkPermission/index.ts | 12 ++++++++ 2 files changed, 26 insertions(+), 16 deletions(-) create mode 100644 src/helpers/checkPermission/index.ts diff --git a/src/events/interactionCreate/handlers/command/index.ts b/src/events/interactionCreate/handlers/command/index.ts index db90796..2f726e9 100644 --- a/src/events/interactionCreate/handlers/command/index.ts +++ b/src/events/interactionCreate/handlers/command/index.ts @@ -1,7 +1,5 @@ // Dependencies import { ChatInputCommandInteraction } from "discord.js"; -import { command as CooldownCommand } from "../../../../handlers/cooldown"; -import deferReply from "../../../../handlers/deferReply"; import getCommandMetadata from "../../../../helpers/getCommandMetadata"; export default async (interaction: ChatInputCommandInteraction) => { @@ -12,23 +10,23 @@ export default async (interaction: ChatInputCommandInteraction) => { if (!currentCommand) throw new Error(`Unknown command ${commandName}`); const metadata = await getCommandMetadata(interaction, currentCommand); - await deferReply(interaction, metadata.ephemeral || false); + // await deferReply(interaction, metadata.ephemeral || false); - if (metadata.guildOnly && !interaction.guild) - throw new Error("This command is guild only."); + // if (metadata.guildOnly && !interaction.guild) + // throw new Error("This command is guild only."); - if ( - metadata.permissions && - metadata.guildOnly && - !interaction.memberPermissions?.has(metadata.permissions) - ) - throw new Error("You don't have the required permissions"); + // if (metadata.dmOnly && interaction.guild) + // throw new Error("This command is only available in DM"); - if (metadata.dmOnly && interaction.guild) - throw new Error("This command is only available in DM"); + // if ( + // metadata.permissions && + // metadata.guildOnly && + // !interaction.memberPermissions?.has(metadata.permissions) + // ) + // throw new Error("You don't have the required permissions"); - if (metadata.cooldown) { - await CooldownCommand(interaction, metadata.cooldown); - } + // if (metadata.cooldown) { + // await CooldownCommand(interaction, metadata.cooldown); + // } await currentCommand.execute(interaction); }; diff --git a/src/helpers/checkPermission/index.ts b/src/helpers/checkPermission/index.ts new file mode 100644 index 0000000..2de1162 --- /dev/null +++ b/src/helpers/checkPermission/index.ts @@ -0,0 +1,12 @@ +import { BaseInteraction, PermissionResolvable } from "discord.js"; + +export default async ( + interaction: BaseInteraction, + permission: PermissionResolvable +) => { + if (!interaction.memberPermissions) + throw new Error("Could not check user for permissions"); + + if (!interaction.memberPermissions.has(permission)) + throw new Error("Permission denied"); +}; From ab7043d75f10cd64246b19937747713b8ff9bccc Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 15:49:11 +0200 Subject: [PATCH 182/215] =?UTF-8?q?=F0=9F=97=91=EF=B8=8F=20deprecate=20mod?= =?UTF-8?q?uleData=20and=20metadata?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/events/interactionCreate/handlers/command/index.ts | 3 +-- src/handlers/command/index.ts | 4 ---- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/events/interactionCreate/handlers/command/index.ts b/src/events/interactionCreate/handlers/command/index.ts index 2f726e9..0e79da8 100644 --- a/src/events/interactionCreate/handlers/command/index.ts +++ b/src/events/interactionCreate/handlers/command/index.ts @@ -1,6 +1,5 @@ // Dependencies import { ChatInputCommandInteraction } from "discord.js"; -import getCommandMetadata from "../../../../helpers/getCommandMetadata"; export default async (interaction: ChatInputCommandInteraction) => { if (!interaction.isCommand()) return; @@ -9,7 +8,7 @@ export default async (interaction: ChatInputCommandInteraction) => { const currentCommand = client.commands.get(commandName); if (!currentCommand) throw new Error(`Unknown command ${commandName}`); - const metadata = await getCommandMetadata(interaction, currentCommand); + // const metadata = await getCommandMetadata(interaction, currentCommand); // await deferReply(interaction, metadata.ephemeral || false); // if (metadata.guildOnly && !interaction.guild) diff --git a/src/handlers/command/index.ts b/src/handlers/command/index.ts index 865c349..09d05e2 100644 --- a/src/handlers/command/index.ts +++ b/src/handlers/command/index.ts @@ -21,10 +21,6 @@ export const register = async (client: Client) => { throw new Error( `📦 No command builder found while importing "${commandName}"` ); - if (!command.moduleData) - throw new Error( - `📦 No command moduleData found while importing "${commandName}"` - ); // Add command to collection client.commands.set(command.builder.name, command); From 9d2bd0c848a8e16037d3dafe5852c8c805e8afba Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 16:07:25 +0200 Subject: [PATCH 183/215] =?UTF-8?q?=F0=9F=8E=A8=20Config=20Command=20is=20?= =?UTF-8?q?now=20using=20guard=20classes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/config/index.ts | 60 +++++++++++--------- src/commands/config/modules/audits/index.ts | 14 ++--- src/commands/config/modules/cpgg/index.ts | 12 ++-- src/commands/config/modules/credits/index.ts | 12 ++-- src/commands/config/modules/embeds/index.ts | 12 ++-- src/commands/config/modules/index.ts | 9 --- src/commands/config/modules/points/index.ts | 12 ++-- src/commands/config/modules/shop/index.ts | 12 ++-- src/commands/config/modules/welcome/index.ts | 12 ++-- 9 files changed, 77 insertions(+), 78 deletions(-) delete mode 100644 src/commands/config/modules/index.ts diff --git a/src/commands/config/index.ts b/src/commands/config/index.ts index 783219b..cbaa582 100644 --- a/src/commands/config/index.ts +++ b/src/commands/config/index.ts @@ -1,43 +1,51 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction } from "discord.js"; -import modules from "./modules"; + +// Modules +import moduleAudits from "./modules/audits"; +import moduleCpgg from "./modules/cpgg"; +import moduleCredits from "./modules/credits"; +import moduleEmbeds from "./modules/embeds"; +import modulePoints from "./modules/points"; +import moduleShop from "./modules/shop"; +import moduleWelcome from "./modules/welcome"; export const builder = new SlashCommandBuilder() .setName("config") .setDescription("Manage guild configurations.") + .setDMPermission(false) - .addSubcommand(modules.cpgg.builder) - .addSubcommand(modules.credits.builder) - .addSubcommand(modules.points.builder) - .addSubcommand(modules.welcome.builder) - .addSubcommand(modules.audits.builder) - .addSubcommand(modules.shop.builder) - .addSubcommand(modules.embeds.builder); - -export const moduleData = modules; + // Modules + .addSubcommand(moduleAudits.builder) + .addSubcommand(moduleCpgg.builder) + .addSubcommand(moduleCredits.builder) + .addSubcommand(moduleEmbeds.builder) + .addSubcommand(modulePoints.builder) + .addSubcommand(moduleShop.builder) + .addSubcommand(moduleWelcome.builder); export const execute = async (interaction: ChatInputCommandInteraction) => { - switch (interaction.options?.getSubcommand()) { + switch (interaction.options.getSubcommand()) { + case "audits": + await moduleAudits.execute(interaction); + break; case "cpgg": - await modules.cpgg.execute(interaction); + await moduleCpgg.execute(interaction); break; case "credits": - await modules.credits.execute(interaction); - break; - case "points": - await modules.points.execute(interaction); - break; - case "welcome": - await modules.welcome.execute(interaction); - break; - case "audits": - await modules.audits.execute(interaction); - break; - case "shop": - await modules.shop.execute(interaction); + await moduleCredits.execute(interaction); break; case "embeds": - await modules.embeds.execute(interaction); + await moduleEmbeds.execute(interaction); + break; + case "points": + await modulePoints.execute(interaction); + break; + case "shop": + await moduleShop.execute(interaction); + break; + case "welcome": + await moduleWelcome.execute(interaction); break; default: throw new Error("No module found for that specific command."); diff --git a/src/commands/config/modules/audits/index.ts b/src/commands/config/modules/audits/index.ts index 3a6dd1f..a3d4c00 100644 --- a/src/commands/config/modules/audits/index.ts +++ b/src/commands/config/modules/audits/index.ts @@ -1,21 +1,17 @@ -import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChannelType } from "discord-api-types/v10"; import { ChatInputCommandInteraction, EmbedBuilder, PermissionsBitField, + SlashCommandSubcommandBuilder, } from "discord.js"; import prisma from "../../../../handlers/database"; +import deferReply from "../../../../handlers/deferReply"; +import checkPermission from "../../../../helpers/checkPermission"; import getEmbedConfig from "../../../../helpers/getEmbedData"; import logger from "../../../../middlewares/logger"; export default { - metadata: { - guildOnly: true, - ephemeral: true, - permissions: [PermissionsBitField.Flags.ManageGuild], - }, - builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("audits") @@ -35,6 +31,10 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { + await deferReply(interaction, true); + + await checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); + const { guild, options } = interaction; const { successColor, footerText, footerIcon } = await getEmbedConfig( guild diff --git a/src/commands/config/modules/cpgg/index.ts b/src/commands/config/modules/cpgg/index.ts index 01d13ed..b9ce119 100644 --- a/src/commands/config/modules/cpgg/index.ts +++ b/src/commands/config/modules/cpgg/index.ts @@ -5,17 +5,13 @@ import { PermissionsBitField, } from "discord.js"; import prisma from "../../../../handlers/database"; +import deferReply from "../../../../handlers/deferReply"; +import checkPermission from "../../../../helpers/checkPermission"; import encryption from "../../../../helpers/encryption"; import getEmbedConfig from "../../../../helpers/getEmbedData"; import logger from "../../../../middlewares/logger"; export default { - metadata: { - guildOnly: true, - ephemeral: true, - permissions: [PermissionsBitField.Flags.ManageGuild], - }, - builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("cpgg") @@ -44,6 +40,10 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { + await deferReply(interaction, true); + + await checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); + const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild ); diff --git a/src/commands/config/modules/credits/index.ts b/src/commands/config/modules/credits/index.ts index 4d25feb..e76cd77 100644 --- a/src/commands/config/modules/credits/index.ts +++ b/src/commands/config/modules/credits/index.ts @@ -5,16 +5,12 @@ import { PermissionsBitField, } from "discord.js"; import prisma from "../../../../handlers/database"; +import deferReply from "../../../../handlers/deferReply"; +import checkPermission from "../../../../helpers/checkPermission"; import getEmbedConfig from "../../../../helpers/getEmbedData"; import logger from "../../../../middlewares/logger"; export default { - metadata: { - guildOnly: true, - ephemeral: true, - permissions: [PermissionsBitField.Flags.ManageGuild], - }, - builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("credits") @@ -57,6 +53,10 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { + await deferReply(interaction, true); + + await checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); + const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild ); diff --git a/src/commands/config/modules/embeds/index.ts b/src/commands/config/modules/embeds/index.ts index 3ec6661..a9e1ae9 100644 --- a/src/commands/config/modules/embeds/index.ts +++ b/src/commands/config/modules/embeds/index.ts @@ -5,15 +5,11 @@ import { } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import deferReply from "../../../../handlers/deferReply"; +import checkPermission from "../../../../helpers/checkPermission"; import getValues from "./components/getValues"; export default { - metadata: { - guildOnly: true, - ephemeral: true, - permissions: [PermissionsBitField.Flags.ManageGuild], - }, - builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("embeds") @@ -50,6 +46,10 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { + await deferReply(interaction, true); + + await checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); + const { guild } = interaction; if (!guild) throw new Error("Guild not found"); diff --git a/src/commands/config/modules/index.ts b/src/commands/config/modules/index.ts deleted file mode 100644 index 7d8ba77..0000000 --- a/src/commands/config/modules/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -import audits from "./audits"; -import cpgg from "./cpgg"; -import credits from "./credits"; -import embeds from "./embeds"; -import points from "./points"; -import shop from "./shop"; -import welcome from "./welcome"; - -export default { audits, credits, points, cpgg, shop, welcome, embeds }; diff --git a/src/commands/config/modules/points/index.ts b/src/commands/config/modules/points/index.ts index fc67d3b..7f89c8a 100644 --- a/src/commands/config/modules/points/index.ts +++ b/src/commands/config/modules/points/index.ts @@ -5,16 +5,12 @@ import { PermissionsBitField, } from "discord.js"; import prisma from "../../../../handlers/database"; +import deferReply from "../../../../handlers/deferReply"; +import checkPermission from "../../../../helpers/checkPermission"; import getEmbedConfig from "../../../../helpers/getEmbedData"; import logger from "../../../../middlewares/logger"; export default { - metadata: { - guildOnly: true, - ephemeral: true, - permissions: [PermissionsBitField.Flags.ManageGuild], - }, - builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("points") @@ -45,6 +41,10 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { + await deferReply(interaction, true); + + await checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); + const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild ); diff --git a/src/commands/config/modules/shop/index.ts b/src/commands/config/modules/shop/index.ts index 2d605d6..fd23ac1 100644 --- a/src/commands/config/modules/shop/index.ts +++ b/src/commands/config/modules/shop/index.ts @@ -5,16 +5,12 @@ import { PermissionsBitField, } from "discord.js"; import prisma from "../../../../handlers/database"; +import deferReply from "../../../../handlers/deferReply"; +import checkPermission from "../../../../helpers/checkPermission"; import getEmbedConfig from "../../../../helpers/getEmbedData"; import logger from "../../../../middlewares/logger"; export default { - metadata: { - guildOnly: true, - ephemeral: true, - permissions: [PermissionsBitField.Flags.ManageGuild], - }, - builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("shop") @@ -33,6 +29,10 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { + await deferReply(interaction, true); + + await checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); + const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild ); diff --git a/src/commands/config/modules/welcome/index.ts b/src/commands/config/modules/welcome/index.ts index fd604a1..259a63f 100644 --- a/src/commands/config/modules/welcome/index.ts +++ b/src/commands/config/modules/welcome/index.ts @@ -6,16 +6,12 @@ import { PermissionsBitField, } from "discord.js"; import prisma from "../../../../handlers/database"; +import deferReply from "../../../../handlers/deferReply"; +import checkPermission from "../../../../helpers/checkPermission"; import getEmbedConfig from "../../../../helpers/getEmbedData"; import logger from "../../../../middlewares/logger"; export default { - metadata: { - guildOnly: true, - ephemeral: true, - permissions: [PermissionsBitField.Flags.ManageGuild], - }, - builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("welcome") @@ -56,6 +52,10 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { + await deferReply(interaction, true); + + await checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); + const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild ); From dd5ed64e1aae826bb42860fb6004df0a3db8da30 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 16:15:44 +0200 Subject: [PATCH 184/215] =?UTF-8?q?=F0=9F=8E=A8=20Counters=20Command=20is?= =?UTF-8?q?=20now=20using=20guard=20classes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/counters/index.ts | 17 +++++++++++------ src/commands/counters/modules/index.ts | 3 --- src/commands/counters/modules/view/index.ts | 5 +++-- 3 files changed, 14 insertions(+), 11 deletions(-) delete mode 100644 src/commands/counters/modules/index.ts diff --git a/src/commands/counters/index.ts b/src/commands/counters/index.ts index e70e460..edb73e2 100644 --- a/src/commands/counters/index.ts +++ b/src/commands/counters/index.ts @@ -1,18 +1,23 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction } from "discord.js"; -import modules from "./modules"; +// Modules +import moduleView from "./modules/view"; export const builder = new SlashCommandBuilder() .setName("counters") .setDescription("View guild counters") + .setDMPermission(false) - .addSubcommand(modules.view.builder); - -export const moduleData = modules; + // Modules + .addSubcommand(moduleView.builder); export const execute = async (interaction: ChatInputCommandInteraction) => { - if (interaction.options.getSubcommand() === "view") { - await modules.view.execute(interaction); + switch (interaction.options.getSubcommand()) { + case "view": + await moduleView.execute(interaction); + break; + default: + throw new Error("No module found for that command."); } }; diff --git a/src/commands/counters/modules/index.ts b/src/commands/counters/modules/index.ts deleted file mode 100644 index dc539f8..0000000 --- a/src/commands/counters/modules/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import view from "./view"; - -export default { view }; diff --git a/src/commands/counters/modules/view/index.ts b/src/commands/counters/modules/view/index.ts index dd8e510..76611f8 100644 --- a/src/commands/counters/modules/view/index.ts +++ b/src/commands/counters/modules/view/index.ts @@ -2,11 +2,10 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChannelType } from "discord-api-types/v10"; import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js"; import prisma from "../../../../handlers/database"; +import deferReply from "../../../../handlers/deferReply"; import getEmbedConfig from "../../../../helpers/getEmbedData"; export default { - metadata: { guildOnly: true, ephemeral: false }, - builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("view") @@ -23,6 +22,8 @@ export default { }, execute: async (interaction: ChatInputCommandInteraction) => { + await deferReply(interaction, false); + const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild ); From be500e7f3424d6104f98a101d96671727c894e20 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 16:15:49 +0200 Subject: [PATCH 185/215] =?UTF-8?q?=F0=9F=8E=A8=20Credits=20Command=20is?= =?UTF-8?q?=20now=20using=20guard=20classes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/credits/index.ts | 26 +++++++++++-------- src/commands/credits/modules/balance/index.ts | 4 ++- src/commands/credits/modules/gift/index.ts | 5 ++-- src/commands/credits/modules/index.ts | 6 ----- src/commands/credits/modules/top/index.ts | 3 +++ src/commands/credits/modules/work/index.ts | 5 ++-- 6 files changed, 27 insertions(+), 22 deletions(-) delete mode 100644 src/commands/credits/modules/index.ts diff --git a/src/commands/credits/index.ts b/src/commands/credits/index.ts index ad0f771..a1aaad6 100644 --- a/src/commands/credits/index.ts +++ b/src/commands/credits/index.ts @@ -2,34 +2,38 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction } from "discord.js"; import logger from "../../middlewares/logger"; -import modules from "./modules"; +// Modules +import moduleBalance from "./modules/balance"; +import moduleGift from "./modules/gift"; +import moduleTop from "./modules/top"; +import moduleWork from "./modules/work"; export const builder = new SlashCommandBuilder() .setName("credits") .setDescription("Manage your credits.") + .setDMPermission(false) - .addSubcommand(modules.balance.builder) - .addSubcommand(modules.gift.builder) - .addSubcommand(modules.top.builder) - .addSubcommand(modules.work.builder); - -export const moduleData = modules; + // Modules + .addSubcommand(moduleBalance.builder) + .addSubcommand(moduleGift.builder) + .addSubcommand(moduleTop.builder) + .addSubcommand(moduleWork.builder); export const execute = async (interaction: ChatInputCommandInteraction) => { const { options } = interaction; switch (options.getSubcommand()) { case "balance": - await modules.balance.execute(interaction); + await moduleBalance.execute(interaction); break; case "gift": - await modules.gift.execute(interaction); + await moduleGift.execute(interaction); break; case "top": - await modules.top.execute(interaction); + await moduleTop.execute(interaction); break; case "work": - await modules.work.execute(interaction); + await moduleWork.execute(interaction); break; default: logger.silly(`Unknown subcommand ${options.getSubcommand()}`); diff --git a/src/commands/credits/modules/balance/index.ts b/src/commands/credits/modules/balance/index.ts index a360c8e..9034f63 100644 --- a/src/commands/credits/modules/balance/index.ts +++ b/src/commands/credits/modules/balance/index.ts @@ -1,11 +1,11 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { CommandInteraction, EmbedBuilder } from "discord.js"; import prisma from "../../../../handlers/database"; +import deferReply from "../../../../handlers/deferReply"; import getEmbedConfig from "../../../../helpers/getEmbedData"; import logger from "../../../../middlewares/logger"; export default { - metadata: { guildOnly: true, ephemeral: true }, builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("balance") @@ -17,6 +17,8 @@ export default { ); }, execute: async (interaction: CommandInteraction) => { + await deferReply(interaction, true); + const { errorColor, successColor, footerText, footerIcon } = await getEmbedConfig(interaction.guild); const { options, user, guild } = interaction; diff --git a/src/commands/credits/modules/gift/index.ts b/src/commands/credits/modules/gift/index.ts index 4c2e541..db3435c 100644 --- a/src/commands/credits/modules/gift/index.ts +++ b/src/commands/credits/modules/gift/index.ts @@ -7,13 +7,12 @@ import { } from "discord.js"; import transferCredits from "../../../../helpers/transferCredits"; // Configurations +import deferReply from "../../../../handlers/deferReply"; import getEmbedConfig from "../../../../helpers/getEmbedData"; // Handlers // Function export default { - metadata: { guildOnly: true, ephemeral: true }, - builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("gift") @@ -35,6 +34,8 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { + await deferReply(interaction, true); + const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild ); diff --git a/src/commands/credits/modules/index.ts b/src/commands/credits/modules/index.ts deleted file mode 100644 index 20edcaf..0000000 --- a/src/commands/credits/modules/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -import balance from "./balance"; -import gift from "./gift"; -import top from "./top"; -import work from "./work"; - -export default { balance, gift, top, work }; diff --git a/src/commands/credits/modules/top/index.ts b/src/commands/credits/modules/top/index.ts index 7162744..075c599 100644 --- a/src/commands/credits/modules/top/index.ts +++ b/src/commands/credits/modules/top/index.ts @@ -2,6 +2,7 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { GuildMember } from "@prisma/client"; import { CommandInteraction, EmbedBuilder } from "discord.js"; import prisma from "../../../../handlers/database"; +import deferReply from "../../../../handlers/deferReply"; import getEmbedConfig from "../../../../helpers/getEmbedData"; import logger from "../../../../middlewares/logger"; @@ -12,6 +13,8 @@ export default { return command.setName("top").setDescription(`View the top users`); }, execute: async (interaction: CommandInteraction) => { + await deferReply(interaction, false); + const { errorColor, successColor, footerText, footerIcon } = await getEmbedConfig(interaction.guild); const { guild } = interaction; diff --git a/src/commands/credits/modules/work/index.ts b/src/commands/credits/modules/work/index.ts index 1a5407b..939ee06 100644 --- a/src/commands/credits/modules/work/index.ts +++ b/src/commands/credits/modules/work/index.ts @@ -9,15 +9,16 @@ import getEmbedConfig from "../../../../helpers/getEmbedData"; // Helpers // Handlers import prisma from "../../../../handlers/database"; +import deferReply from "../../../../handlers/deferReply"; import logger from "../../../../middlewares/logger"; export default { - metadata: { guildOnly: true, ephemeral: true }, - builder: (command: SlashCommandSubcommandBuilder) => { return command.setName("work").setDescription(`Work to earn credits`); }, execute: async (interaction: CommandInteraction) => { + await deferReply(interaction, true); + const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild ); // Destructure member From f5c988b77bdeda9bf03aa99136a2680ab50dcc02 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 16:18:00 +0200 Subject: [PATCH 186/215] =?UTF-8?q?=F0=9F=8E=A8=20DNS=20Commands=20is=20no?= =?UTF-8?q?w=20using=20guard=20classes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/dns/index.ts | 9 +++++---- src/commands/dns/modules/index.ts | 3 --- src/commands/dns/modules/lookup/index.ts | 5 +++-- 3 files changed, 8 insertions(+), 9 deletions(-) delete mode 100644 src/commands/dns/modules/index.ts diff --git a/src/commands/dns/index.ts b/src/commands/dns/index.ts index 551814b..cd5f9ec 100644 --- a/src/commands/dns/index.ts +++ b/src/commands/dns/index.ts @@ -1,20 +1,21 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction } from "discord.js"; -import modules from "./modules"; -export const moduleData = modules; +// Modules +import moduleLookup from "./modules/lookup"; export const builder = new SlashCommandBuilder() .setName("dns") .setDescription("DNS commands.") - .addSubcommand(modules.lookup.builder); + // Modules + .addSubcommand(moduleLookup.builder); // Execute the command export const execute = async (interaction: ChatInputCommandInteraction) => { switch (interaction.options.getSubcommand()) { case "lookup": - await modules.lookup.execute(interaction); + await moduleLookup.execute(interaction); break; default: throw new Error( diff --git a/src/commands/dns/modules/index.ts b/src/commands/dns/modules/index.ts deleted file mode 100644 index 92a80ac..0000000 --- a/src/commands/dns/modules/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import lookup from "./lookup"; - -export default { lookup }; diff --git a/src/commands/dns/modules/lookup/index.ts b/src/commands/dns/modules/lookup/index.ts index afa51a6..b64c18f 100644 --- a/src/commands/dns/modules/lookup/index.ts +++ b/src/commands/dns/modules/lookup/index.ts @@ -1,11 +1,10 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import axios from "axios"; import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js"; +import deferReply from "../../../../handlers/deferReply"; import getEmbedConfig from "../../../../helpers/getEmbedData"; export default { - metadata: { guildOnly: false, ephemeral: false }, - builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("lookup") @@ -20,6 +19,8 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { + await deferReply(interaction, false); + const { errorColor, successColor, footerText, footerIcon } = await getEmbedConfig(interaction.guild); const embedTitle = "[:hammer:] Utility (Lookup)"; From cb19e0f788155c2157b86b608cfffb6b402bce3c Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 16:33:31 +0200 Subject: [PATCH 187/215] =?UTF-8?q?=F0=9F=8E=A8=20Fun=20Command=20is=20now?= =?UTF-8?q?=20using=20guard=20classes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/fun/index.ts | 9 ++++----- src/commands/fun/modules/index.ts | 5 ----- src/commands/fun/modules/meme/index.ts | 8 ++++++-- 3 files changed, 10 insertions(+), 12 deletions(-) delete mode 100644 src/commands/fun/modules/index.ts diff --git a/src/commands/fun/index.ts b/src/commands/fun/index.ts index 8c166f0..e010d5d 100644 --- a/src/commands/fun/index.ts +++ b/src/commands/fun/index.ts @@ -2,21 +2,20 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction } from "discord.js"; import logger from "../../middlewares/logger"; -import modules from "./modules"; +// Modules +import moduleMeme from "./modules/meme"; export const builder = new SlashCommandBuilder() .setName("fun") .setDescription("Fun commands.") - .addSubcommand(modules.meme.builder); - -export const moduleData = modules; + .addSubcommand(moduleMeme.builder); export const execute = async (interaction: ChatInputCommandInteraction) => { const { options } = interaction; if (options.getSubcommand() === "meme") { - await modules.meme.execute(interaction); + await moduleMeme.execute(interaction); } else { logger.silly(`Unknown subcommand ${options.getSubcommand()}`); } diff --git a/src/commands/fun/modules/index.ts b/src/commands/fun/modules/index.ts deleted file mode 100644 index 53aeddc..0000000 --- a/src/commands/fun/modules/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import meme from "./meme"; - -export default { - meme, -}; diff --git a/src/commands/fun/modules/meme/index.ts b/src/commands/fun/modules/meme/index.ts index b5c3db3..1ed1ea0 100644 --- a/src/commands/fun/modules/meme/index.ts +++ b/src/commands/fun/modules/meme/index.ts @@ -1,16 +1,20 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import axios from "axios"; import { CommandInteraction, EmbedBuilder } from "discord.js"; +import { command as CooldownCommand } from "../../../../handlers/cooldown"; +import deferReply from "../../../../handlers/deferReply"; import getEmbedConfig from "../../../../helpers/getEmbedData"; export default { - metadata: { guildOnly: false, ephemeral: false, cooldown: 15 }, - builder: (command: SlashCommandSubcommandBuilder) => { return command.setName("meme").setDescription("Get a meme from r/memes)"); }, execute: async (interaction: CommandInteraction) => { + await deferReply(interaction, false); + + await CooldownCommand(interaction, 15); + const { guild } = interaction; const embedConfig = await getEmbedConfig(guild); From 4606392189108a00811e6c690d24db80a55f43d9 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 16:33:49 +0200 Subject: [PATCH 188/215] =?UTF-8?q?=F0=9F=8E=A8=20Manage=20Command=20is=20?= =?UTF-8?q?now=20using=20guard=20classes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/manage/index.ts | 18 ++--- src/commands/manage/modules/counters/index.ts | 55 +++++++------- .../modules/counters/modules/add/index.ts | 12 ++-- .../manage/modules/counters/modules/index.ts | 4 -- .../modules/counters/modules/remove/index.ts | 12 ++-- src/commands/manage/modules/credits/index.ts | 71 ++++++++++--------- .../modules/credits/modules/give/index.ts | 12 ++-- .../modules/credits/modules/giveaway/index.ts | 12 ++-- .../manage/modules/credits/modules/index.ts | 7 -- .../modules/credits/modules/set/index.ts | 12 ++-- .../modules/credits/modules/take/index.ts | 12 ++-- .../modules/credits/modules/transfer/index.ts | 13 ++-- src/commands/manage/modules/index.ts | 4 -- 13 files changed, 116 insertions(+), 128 deletions(-) delete mode 100644 src/commands/manage/modules/counters/modules/index.ts delete mode 100644 src/commands/manage/modules/credits/modules/index.ts delete mode 100644 src/commands/manage/modules/index.ts diff --git a/src/commands/manage/index.ts b/src/commands/manage/index.ts index d488bd1..0062de7 100644 --- a/src/commands/manage/index.ts +++ b/src/commands/manage/index.ts @@ -2,17 +2,19 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction } from "discord.js"; -// Groups -import modules from "./modules"; - -export const moduleData = modules; +// Modules +import moduleCounters from "./modules/counters"; +import moduleCredits from "./modules/credits"; // Function export const builder = new SlashCommandBuilder() .setName("manage") .setDescription("Manage the bot.") - .addSubcommandGroup(modules.counters.builder) - .addSubcommandGroup(modules.credits.builder); + .setDMPermission(false) + + // Modules + .addSubcommandGroup(moduleCounters.builder) + .addSubcommandGroup(moduleCredits.builder); export const execute = async (interaction: ChatInputCommandInteraction) => { // Destructure @@ -20,11 +22,11 @@ export const execute = async (interaction: ChatInputCommandInteraction) => { switch (options.getSubcommandGroup()) { case "credits": { - await modules.credits.execute(interaction); + await moduleCredits.execute(interaction); break; } case "counters": { - await modules.counters.execute(interaction); + await moduleCounters.execute(interaction); break; } default: { diff --git a/src/commands/manage/modules/counters/index.ts b/src/commands/manage/modules/counters/index.ts index 941d672..7412a09 100644 --- a/src/commands/manage/modules/counters/index.ts +++ b/src/commands/manage/modules/counters/index.ts @@ -3,35 +3,32 @@ import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction } from "discord.js"; // Modules -import modules from "./modules"; +import moduleAdd from "./modules/add"; +import moduleRemove from "./modules/remove"; -// Function -export const moduleData = modules; +export default { + builder: (group: SlashCommandSubcommandGroupBuilder) => { + return group + .setName("counters") + .setDescription("Manage guild counters.") + .addSubcommand(moduleAdd.builder) + .addSubcommand(moduleRemove.builder); + }, + execute: async (interaction: ChatInputCommandInteraction) => { + const { options } = interaction; -// Create a discord builder -export const builder = (group: SlashCommandSubcommandGroupBuilder) => { - return group - .setName("counters") - .setDescription("Manage guild counters.") - .addSubcommand(modules.add.builder) - .addSubcommand(modules.remove.builder); -}; - -// Execute the command -export const execute = async (interaction: ChatInputCommandInteraction) => { - const { options } = interaction; - - switch (options.getSubcommand()) { - case "add": { - await modules.add.execute(interaction); - break; - } - case "remove": { - await modules.remove.execute(interaction); - break; - } - default: { - throw new Error("Could not found a module for that command."); - } - } + switch (options.getSubcommand()) { + case "add": { + await moduleAdd.execute(interaction); + break; + } + case "remove": { + await moduleRemove.execute(interaction); + break; + } + default: { + throw new Error("Could not found a module for that command."); + } + } + }, }; diff --git a/src/commands/manage/modules/counters/modules/add/index.ts b/src/commands/manage/modules/counters/modules/add/index.ts index 403a234..13399bc 100644 --- a/src/commands/manage/modules/counters/modules/add/index.ts +++ b/src/commands/manage/modules/counters/modules/add/index.ts @@ -6,6 +6,8 @@ import { EmbedBuilder, PermissionsBitField, } from "discord.js"; +import deferReply from "../../../../../../handlers/deferReply"; +import checkPermission from "../../../../../../helpers/checkPermission"; // Configurations import prisma from "../../../../../../handlers/database"; import getEmbedConfig from "../../../../../../helpers/getEmbedData"; @@ -13,12 +15,6 @@ import logger from "../../../../../../middlewares/logger"; // Function export default { - metadata: { - guildOnly: true, - ephemeral: true, - permissions: [PermissionsBitField.Flags.ManageGuild], - }, - builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("add") @@ -43,6 +39,10 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { + await deferReply(interaction, true); + + await checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); + const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild ); diff --git a/src/commands/manage/modules/counters/modules/index.ts b/src/commands/manage/modules/counters/modules/index.ts deleted file mode 100644 index bc9da9c..0000000 --- a/src/commands/manage/modules/counters/modules/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import add from "./add"; -import remove from "./remove"; - -export default { add, remove }; diff --git a/src/commands/manage/modules/counters/modules/remove/index.ts b/src/commands/manage/modules/counters/modules/remove/index.ts index 74caae3..dff0ec8 100644 --- a/src/commands/manage/modules/counters/modules/remove/index.ts +++ b/src/commands/manage/modules/counters/modules/remove/index.ts @@ -7,18 +7,14 @@ import { EmbedBuilder, PermissionsBitField, } from "discord.js"; +import deferReply from "../../../../../../handlers/deferReply"; +import checkPermission from "../../../../../../helpers/checkPermission"; // Configurations import prisma from "../../../../../../handlers/database"; import getEmbedConfig from "../../../../../../helpers/getEmbedData"; // Function export default { - metadata: { - guildOnly: true, - ephemeral: true, - permissions: [PermissionsBitField.Flags.ManageGuild], - }, - builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("remove") @@ -32,6 +28,10 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { + await deferReply(interaction, true); + + await checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); + const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild ); diff --git a/src/commands/manage/modules/credits/index.ts b/src/commands/manage/modules/credits/index.ts index bf6f578..681cc24 100644 --- a/src/commands/manage/modules/credits/index.ts +++ b/src/commands/manage/modules/credits/index.ts @@ -1,38 +1,43 @@ import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction } from "discord.js"; -import modules from "./modules"; -export const moduleData = modules; +// Modules +import moduleGive from "./modules/give"; +import moduleGiveaway from "./modules/giveaway"; +import moduleSet from "./modules/set"; +import moduleTake from "./modules/take"; +import moduleTransfer from "./modules/transfer"; -export const builder = (group: SlashCommandSubcommandGroupBuilder) => { - return group - .setName("credits") - .setDescription("Manage the credits of a user.") - .addSubcommand(modules.give.builder) - .addSubcommand(modules.set.builder) - .addSubcommand(modules.take.builder) - .addSubcommand(modules.transfer.builder) - .addSubcommand(modules.giveaway.builder); -}; - -export const execute = async (interaction: ChatInputCommandInteraction) => { - switch (interaction.options.getSubcommand()) { - case "give": - await modules.give.execute(interaction); - break; - case "set": - await modules.set.execute(interaction); - break; - case "take": - await modules.take.execute(interaction); - break; - case "transfer": - await modules.transfer.execute(interaction); - break; - case "giveaway": - await modules.giveaway.execute(interaction); - break; - default: - throw new Error("No module found for that specific command"); - } +export default { + builder: (group: SlashCommandSubcommandGroupBuilder) => { + return group + .setName("credits") + .setDescription("Manage the credits of a user.") + .addSubcommand(moduleGive.builder) + .addSubcommand(moduleSet.builder) + .addSubcommand(moduleTake.builder) + .addSubcommand(moduleTransfer.builder) + .addSubcommand(moduleGiveaway.builder); + }, + execute: async (interaction: ChatInputCommandInteraction) => { + switch (interaction.options.getSubcommand()) { + case "give": + await moduleGive.execute(interaction); + break; + case "set": + await moduleSet.execute(interaction); + break; + case "take": + await moduleTake.execute(interaction); + break; + case "transfer": + await moduleTransfer.execute(interaction); + break; + case "giveaway": + await moduleGiveaway.execute(interaction); + break; + default: + throw new Error("No module found for that specific command"); + } + }, }; diff --git a/src/commands/manage/modules/credits/modules/give/index.ts b/src/commands/manage/modules/credits/modules/give/index.ts index 3235c7e..28d7eeb 100644 --- a/src/commands/manage/modules/credits/modules/give/index.ts +++ b/src/commands/manage/modules/credits/modules/give/index.ts @@ -13,14 +13,10 @@ import pluralize from "../../../../../../helpers/pluralize"; // Models // Handlers import prisma from "../../../../../../handlers/database"; +import deferReply from "../../../../../../handlers/deferReply"; +import checkPermission from "../../../../../../helpers/checkPermission"; // Function export default { - metadata: { - guildOnly: true, - ephemeral: true, - permissions: [PermissionsBitField.Flags.ManageGuild], - }, - builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("give") @@ -39,6 +35,10 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { + await deferReply(interaction, true); + + await checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); + const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild ); // Destructure diff --git a/src/commands/manage/modules/credits/modules/giveaway/index.ts b/src/commands/manage/modules/credits/modules/giveaway/index.ts index db3beb5..3c2ea05 100644 --- a/src/commands/manage/modules/credits/modules/giveaway/index.ts +++ b/src/commands/manage/modules/credits/modules/giveaway/index.ts @@ -13,17 +13,13 @@ import { v4 as uuidv4 } from "uuid"; import encryption from "../../../../../../helpers/encryption"; // Configurations import prisma from "../../../../../../handlers/database"; +import deferReply from "../../../../../../handlers/deferReply"; +import checkPermission from "../../../../../../helpers/checkPermission"; import getEmbedConfig from "../../../../../../helpers/getEmbedData"; import logger from "../../../../../../middlewares/logger"; // Function export default { - metadata: { - guildOnly: true, - ephemeral: true, - permissions: [PermissionsBitField.Flags.ManageGuild], - }, - builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("giveaway") @@ -49,6 +45,10 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { + await deferReply(interaction, true); + + await checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); + const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild ); // Destructure diff --git a/src/commands/manage/modules/credits/modules/index.ts b/src/commands/manage/modules/credits/modules/index.ts deleted file mode 100644 index c82650d..0000000 --- a/src/commands/manage/modules/credits/modules/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -import give from "./give"; -import giveaway from "./giveaway"; -import set from "./set"; -import take from "./take"; -import transfer from "./transfer"; - -export default { give, set, take, transfer, giveaway }; diff --git a/src/commands/manage/modules/credits/modules/set/index.ts b/src/commands/manage/modules/credits/modules/set/index.ts index efb700e..e8fe3cc 100644 --- a/src/commands/manage/modules/credits/modules/set/index.ts +++ b/src/commands/manage/modules/credits/modules/set/index.ts @@ -11,16 +11,12 @@ import { import getEmbedConfig from "../../../../../../helpers/getEmbedData"; // Handlers import prisma from "../../../../../../handlers/database"; +import deferReply from "../../../../../../handlers/deferReply"; +import checkPermission from "../../../../../../helpers/checkPermission"; import logger from "../../../../../../middlewares/logger"; // Function export default { - metadata: { - guildOnly: true, - ephemeral: true, - permissions: [PermissionsBitField.Flags.ManageGuild], - }, - builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("set") @@ -39,6 +35,10 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { + await deferReply(interaction, true); + + await checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); + const { errorColor, successColor, footerText, footerIcon } = await getEmbedConfig(interaction.guild); const { options, guild } = interaction; diff --git a/src/commands/manage/modules/credits/modules/take/index.ts b/src/commands/manage/modules/credits/modules/take/index.ts index 9f70b1e..8f55ad3 100644 --- a/src/commands/manage/modules/credits/modules/take/index.ts +++ b/src/commands/manage/modules/credits/modules/take/index.ts @@ -12,16 +12,12 @@ import getEmbedConfig from "../../../../../../helpers/getEmbedData"; import pluralize from "../../../../../../helpers/pluralize"; // Handlers import prisma from "../../../../../../handlers/database"; +import deferReply from "../../../../../../handlers/deferReply"; +import checkPermission from "../../../../../../helpers/checkPermission"; import logger from "../../../../../../middlewares/logger"; // Function export default { - metadata: { - guildOnly: true, - ephemeral: true, - permissions: [PermissionsBitField.Flags.ManageGuild], - }, - builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("take") @@ -40,6 +36,10 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { + await deferReply(interaction, true); + + await checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); + const { errorColor, successColor, footerText, footerIcon } = await getEmbedConfig(interaction.guild); // Destructure const { guild, options } = interaction; diff --git a/src/commands/manage/modules/credits/modules/transfer/index.ts b/src/commands/manage/modules/credits/modules/transfer/index.ts index 4a8bd40..488ae70 100644 --- a/src/commands/manage/modules/credits/modules/transfer/index.ts +++ b/src/commands/manage/modules/credits/modules/transfer/index.ts @@ -8,17 +8,12 @@ import { } from "discord.js"; import transferCredits from "../../../../../../helpers/transferCredits"; // Configurations +import deferReply from "../../../../../../handlers/deferReply"; +import checkPermission from "../../../../../../helpers/checkPermission"; import getEmbedConfig from "../../../../../../helpers/getEmbedData"; -// Handlers../../../../../../../helpers/userData // Function export default { - metadata: { - guildOnly: true, - ephemeral: true, - permissions: [PermissionsBitField.Flags.ManageGuild], - }, - builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("transfer") @@ -43,6 +38,10 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { + await deferReply(interaction, true); + + await checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); + const { errorColor, successColor, footerText, footerIcon } = await getEmbedConfig(interaction.guild); // Destructure member const { guild, options } = interaction; diff --git a/src/commands/manage/modules/index.ts b/src/commands/manage/modules/index.ts deleted file mode 100644 index c55982f..0000000 --- a/src/commands/manage/modules/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import * as counters from "./counters"; -import * as credits from "./credits"; - -export default { counters, credits }; From db9c05c2e96d35ae6ab4b01822a3da1086148878 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 16:35:18 +0200 Subject: [PATCH 189/215] =?UTF-8?q?=F0=9F=8E=A8=20Moderation=20Command=20i?= =?UTF-8?q?s=20now=20using=20guard=20classes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/moderation/index.ts | 9 +++++---- src/commands/moderation/modules/index.ts | 3 --- src/commands/moderation/modules/prune/index.ts | 15 +++++++++------ 3 files changed, 14 insertions(+), 13 deletions(-) delete mode 100644 src/commands/moderation/modules/index.ts diff --git a/src/commands/moderation/index.ts b/src/commands/moderation/index.ts index e74193e..cfc9e20 100644 --- a/src/commands/moderation/index.ts +++ b/src/commands/moderation/index.ts @@ -1,20 +1,21 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction } from "discord.js"; -import modules from "./modules"; -export const moduleData = modules; +// Modules +import modulePrune from "./modules/prune"; export const builder = new SlashCommandBuilder() .setName("moderation") .setDescription("Moderation.") + .setDMPermission(false) - .addSubcommand(modules.prune.builder); + .addSubcommand(modulePrune.builder); // Execute the command export const execute = async (interaction: ChatInputCommandInteraction) => { switch (interaction.options.getSubcommand()) { case "prune": { - await modules.prune.execute(interaction); + await modulePrune.execute(interaction); break; } default: { diff --git a/src/commands/moderation/modules/index.ts b/src/commands/moderation/modules/index.ts deleted file mode 100644 index e7dd532..0000000 --- a/src/commands/moderation/modules/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import prune from "./prune"; - -export default { prune }; diff --git a/src/commands/moderation/modules/prune/index.ts b/src/commands/moderation/modules/prune/index.ts index 80251b9..0245a33 100644 --- a/src/commands/moderation/modules/prune/index.ts +++ b/src/commands/moderation/modules/prune/index.ts @@ -6,17 +6,13 @@ import { EmbedBuilder, PermissionsBitField, } from "discord.js"; +import deferReply from "../../../../handlers/deferReply"; +import checkPermission from "../../../../helpers/checkPermission"; // Configurations import getEmbedConfig from "../../../../helpers/getEmbedData"; // Function export default { - metadata: { - guildOnly: true, - ephemeral: false, - permissions: [PermissionsBitField.Flags.ManageMessages], - }, - builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("prune") @@ -32,6 +28,13 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { + await deferReply(interaction, false); + + await checkPermission( + interaction, + PermissionsBitField.Flags.ManageMessages + ); + const { errorColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild ); From 6589ac3ba3cbf34f5d9c7ef242cc4134795fffb2 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 16:38:43 +0200 Subject: [PATCH 190/215] =?UTF-8?q?=F0=9F=8E=A8=20Reputation=20Command=20i?= =?UTF-8?q?s=20now=20using=20guard=20classes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/reputation/index.ts | 18 +++++++++--------- src/commands/reputation/modules/give/index.ts | 5 +++-- src/commands/reputation/modules/index.ts | 4 ---- src/commands/reputation/modules/view/index.ts | 5 +++-- 4 files changed, 15 insertions(+), 17 deletions(-) delete mode 100644 src/commands/reputation/modules/index.ts diff --git a/src/commands/reputation/index.ts b/src/commands/reputation/index.ts index 1f1511a..d339cb2 100644 --- a/src/commands/reputation/index.ts +++ b/src/commands/reputation/index.ts @@ -3,26 +3,26 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction } from "discord.js"; // Modules -import modules from "./modules"; - -// Handlers - -export const moduleData = modules; +import moduleGive from "./modules/give"; +import moduleView from "./modules/view"; // Function export const builder = new SlashCommandBuilder() .setName("reputation") .setDescription("Manage reputation.") - .addSubcommand(modules.give.builder) - .addSubcommand(modules.view.builder); + .setDMPermission(false) + + // Modules + .addSubcommand(moduleGive.builder) + .addSubcommand(moduleView.builder); export const execute = async (interaction: ChatInputCommandInteraction) => { if (interaction.options.getSubcommand() === "give") { - await modules.give.execute(interaction); + await moduleGive.execute(interaction); return; } if (interaction.options.getSubcommand() === "view") { - await modules.view.execute(interaction); + await moduleView.execute(interaction); return; } }; diff --git a/src/commands/reputation/modules/give/index.ts b/src/commands/reputation/modules/give/index.ts index 6f8c438..7adf7be 100644 --- a/src/commands/reputation/modules/give/index.ts +++ b/src/commands/reputation/modules/give/index.ts @@ -6,10 +6,9 @@ import logger from "../../../../middlewares/logger"; import noSelfReputation from "./components/noSelfReputation"; import prisma from "../../../../handlers/database"; +import deferReply from "../../../../handlers/deferReply"; export default { - metadata: { guildOnly: true, ephemeral: true }, - builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("give") @@ -35,6 +34,8 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { + await deferReply(interaction, true); + const { options, user, guild } = interaction; const { successColor, footerText, footerIcon } = await getEmbedConfig( diff --git a/src/commands/reputation/modules/index.ts b/src/commands/reputation/modules/index.ts deleted file mode 100644 index 9e1c2a8..0000000 --- a/src/commands/reputation/modules/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import give from "./give"; -import view from "./view"; - -export default { give, view }; diff --git a/src/commands/reputation/modules/view/index.ts b/src/commands/reputation/modules/view/index.ts index c4ccc41..0722cf3 100644 --- a/src/commands/reputation/modules/view/index.ts +++ b/src/commands/reputation/modules/view/index.ts @@ -1,12 +1,11 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js"; import prisma from "../../../../handlers/database"; +import deferReply from "../../../../handlers/deferReply"; import getEmbedConfig from "../../../../helpers/getEmbedData"; import logger from "../../../../middlewares/logger"; export default { - metadata: { guildOnly: true, ephemeral: true }, - builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("view") @@ -19,6 +18,8 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { + await deferReply(interaction, true); + const { options, user, guild } = interaction; const { successColor, footerText, footerIcon } = await getEmbedConfig( From 0816d0abe270d248ad2d62213779142161f27992 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 16:42:15 +0200 Subject: [PATCH 191/215] =?UTF-8?q?=F0=9F=8E=A8=20Shop=20Command=20is=20no?= =?UTF-8?q?w=20using=20guard=20classes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/shop/index.ts | 18 ++--- src/commands/shop/modules/cpgg/index.ts | 5 +- src/commands/shop/modules/index.ts | 4 -- src/commands/shop/modules/roles/index.ts | 65 ++++++++++--------- .../shop/modules/roles/modules/buy/index.ts | 5 +- .../modules/roles/modules/cancel/index.ts | 5 +- .../shop/modules/roles/modules/index.ts | 7 -- 7 files changed, 52 insertions(+), 57 deletions(-) delete mode 100644 src/commands/shop/modules/index.ts delete mode 100644 src/commands/shop/modules/roles/modules/index.ts diff --git a/src/commands/shop/index.ts b/src/commands/shop/index.ts index 1da2442..bf3c20d 100644 --- a/src/commands/shop/index.ts +++ b/src/commands/shop/index.ts @@ -3,18 +3,18 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction } from "discord.js"; // Modules -import modules from "./modules"; - -// Handlers - -export const moduleData = modules; +import moduleCpgg from "./modules/cpgg"; +import moduleRoles from "./modules/roles"; // Function export const builder = new SlashCommandBuilder() .setName("shop") .setDescription("Shop for credits and custom roles.") - .addSubcommand(modules.cpgg.builder) - .addSubcommandGroup(modules.roles.builder); + .setDMPermission(false) + + // Modules + .addSubcommand(moduleCpgg.builder) + .addSubcommandGroup(moduleRoles.builder); // Execute the command export const execute = async (interaction: ChatInputCommandInteraction) => { @@ -22,7 +22,7 @@ export const execute = async (interaction: ChatInputCommandInteraction) => { switch (options.getSubcommand()) { case "cpgg": { - await modules.cpgg.execute(interaction); + await moduleCpgg.execute(interaction); break; } default: { @@ -32,7 +32,7 @@ export const execute = async (interaction: ChatInputCommandInteraction) => { switch (options.getSubcommandGroup()) { case "roles": { - await modules.roles.execute(interaction); + await moduleRoles.execute(interaction); break; } default: { diff --git a/src/commands/shop/modules/cpgg/index.ts b/src/commands/shop/modules/cpgg/index.ts index f7df0a4..1e50907 100644 --- a/src/commands/shop/modules/cpgg/index.ts +++ b/src/commands/shop/modules/cpgg/index.ts @@ -10,13 +10,12 @@ import { } from "discord.js"; import { v4 as uuidv4 } from "uuid"; import prisma from "../../../../handlers/database"; +import deferReply from "../../../../handlers/deferReply"; import encryption from "../../../../helpers/encryption"; import getEmbedData from "../../../../helpers/getEmbedData"; import logger from "../../../../middlewares/logger"; export default { - metadata: { guildOnly: true, ephemeral: true }, - builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("cpgg") @@ -29,6 +28,8 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { + await deferReply(interaction, true); + const { errorColor, successColor, footerText, footerIcon } = await getEmbedData(interaction.guild); const { options, guild, user, client } = interaction; diff --git a/src/commands/shop/modules/index.ts b/src/commands/shop/modules/index.ts deleted file mode 100644 index c3df89d..0000000 --- a/src/commands/shop/modules/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import cpgg from "./cpgg"; -import * as roles from "./roles"; - -export default { cpgg, roles }; diff --git a/src/commands/shop/modules/roles/index.ts b/src/commands/shop/modules/roles/index.ts index ae87e29..0064d14 100644 --- a/src/commands/shop/modules/roles/index.ts +++ b/src/commands/shop/modules/roles/index.ts @@ -5,39 +5,42 @@ import { ChatInputCommandInteraction } from "discord.js"; // Handlers // Modules -import modules from "./modules"; +import moduleBuy from "./modules/buy"; +import moduleCancel from "./modules/cancel"; import guildSchema from "../../../../models/guild"; -export const moduleData = modules; +export default { + builder: (group: SlashCommandSubcommandGroupBuilder) => { + return ( + group + .setName("roles") + .setDescription("Shop for custom roles.") -// Function -export const builder = (group: SlashCommandSubcommandGroupBuilder) => { - return group - .setName("roles") - .setDescription("Shop for custom roles.") - .addSubcommand(modules.buy.builder) - .addSubcommand(modules.cancel.builder); -}; - -export const execute = async (interaction: ChatInputCommandInteraction) => { - if (!interaction.guild) return; - const { options, guild } = interaction; - - const guildDB = await guildSchema?.findOne({ - guildId: guild?.id, - }); - - if (guildDB === null) return; - - if (!guildDB.shop.roles.status) - throw new Error("This server has disabled shop roles."); - - if (options?.getSubcommand() === "buy") { - await modules.buy.execute(interaction); - } - - if (options?.getSubcommand() === "cancel") { - await modules.cancel.execute(interaction); - } + // Modules + .addSubcommand(moduleBuy.builder) + .addSubcommand(moduleCancel.builder) + ); + }, + execute: async (interaction: ChatInputCommandInteraction) => { + if (!interaction.guild) return; + const { options, guild } = interaction; + + const guildDB = await guildSchema?.findOne({ + guildId: guild?.id, + }); + + if (guildDB === null) return; + + if (!guildDB.shop.roles.status) + throw new Error("This server has disabled shop roles."); + + if (options?.getSubcommand() === "buy") { + await moduleBuy.execute(interaction); + } + + if (options?.getSubcommand() === "cancel") { + await moduleCancel.execute(interaction); + } + }, }; diff --git a/src/commands/shop/modules/roles/modules/buy/index.ts b/src/commands/shop/modules/roles/modules/buy/index.ts index f776e2c..e1ca0b2 100644 --- a/src/commands/shop/modules/roles/modules/buy/index.ts +++ b/src/commands/shop/modules/roles/modules/buy/index.ts @@ -2,14 +2,13 @@ // Helpers import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction } from "discord.js"; +import deferReply from "../../../../../../handlers/deferReply"; // Configurations // import fetchUser from "../../../../../../helpers/userData"; // Models // Function export default { - metadata: { guildOnly: true, ephemeral: true }, - builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("buy") @@ -28,6 +27,8 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { + await deferReply(interaction, true); + // const { successColor, footerText, footerIcon } = await getEmbedConfig( // interaction.guild // ); diff --git a/src/commands/shop/modules/roles/modules/cancel/index.ts b/src/commands/shop/modules/roles/modules/cancel/index.ts index 4d0cfc9..4f842f9 100644 --- a/src/commands/shop/modules/roles/modules/cancel/index.ts +++ b/src/commands/shop/modules/roles/modules/cancel/index.ts @@ -5,11 +5,10 @@ import { ChatInputCommandInteraction } from "discord.js"; // Configurations // import fetchUser from "../../../../../../helpers/userData"; // Models +import deferReply from "../../../../../../handlers/deferReply"; // Function export default { - metadata: { guildOnly: true, ephemeral: true }, - builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("cancel") @@ -22,6 +21,8 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { + await deferReply(interaction, true); + // const { successColor, footerText, footerIcon } = await getEmbedConfig( // interaction.guild // ); diff --git a/src/commands/shop/modules/roles/modules/index.ts b/src/commands/shop/modules/roles/modules/index.ts deleted file mode 100644 index b9e1626..0000000 --- a/src/commands/shop/modules/roles/modules/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -import buy from "./buy"; -import cancel from "./cancel"; - -export default { - buy, - cancel, -}; From 5c97c21e2a120204d6806392f70a5aca381e17f6 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 16:44:41 +0200 Subject: [PATCH 192/215] =?UTF-8?q?=F0=9F=8E=A8=20Utility=20Command=20is?= =?UTF-8?q?=20now=20using=20guard=20classes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/utility/index.ts | 24 ++++++++++++-------- src/commands/utility/modules/about/index.ts | 5 ++-- src/commands/utility/modules/avatar/index.ts | 5 ++-- src/commands/utility/modules/index.ts | 11 --------- src/commands/utility/modules/ping/index.ts | 5 ++-- src/commands/utility/modules/stats/index.ts | 5 ++-- 6 files changed, 26 insertions(+), 29 deletions(-) delete mode 100644 src/commands/utility/modules/index.ts diff --git a/src/commands/utility/index.ts b/src/commands/utility/index.ts index fb87528..a58d229 100644 --- a/src/commands/utility/index.ts +++ b/src/commands/utility/index.ts @@ -1,32 +1,36 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction } from "discord.js"; -import modules from "./modules"; -export const moduleData = modules; +// Modules +import moduleAbout from "./modules/about"; +import moduleAvatar from "./modules/avatar"; +import modulePing from "./modules/ping"; +import moduleStats from "./modules/stats"; export const builder = new SlashCommandBuilder() .setName("utility") .setDescription("Common utility.") - .addSubcommand(modules.about.builder) - .addSubcommand(modules.stats.builder) - .addSubcommand(modules.avatar.builder) - .addSubcommand(modules.ping.builder); + // Modules + .addSubcommand(moduleAbout.builder) + .addSubcommand(moduleStats.builder) + .addSubcommand(moduleAvatar.builder) + .addSubcommand(modulePing.builder); // Execute the command export const execute = async (interaction: ChatInputCommandInteraction) => { switch (interaction.options.getSubcommand()) { case "about": - await modules.about.execute(interaction); + await moduleAbout.execute(interaction); break; case "stats": - await modules.stats.execute(interaction); + await moduleStats.execute(interaction); break; case "avatar": - await modules.avatar.execute(interaction); + await moduleAvatar.execute(interaction); break; case "ping": - await modules.ping.execute(interaction); + await modulePing.execute(interaction); break; default: throw new Error( diff --git a/src/commands/utility/modules/about/index.ts b/src/commands/utility/modules/about/index.ts index 7265dad..01f0ad7 100644 --- a/src/commands/utility/modules/about/index.ts +++ b/src/commands/utility/modules/about/index.ts @@ -7,17 +7,18 @@ import { CommandInteraction, EmbedBuilder, } from "discord.js"; +import deferReply from "../../../../handlers/deferReply"; // Configurations import getEmbedConfig from "../../../../helpers/getEmbedData"; // Function export default { - metadata: { guildOnly: false, ephemeral: false }, - builder: (command: SlashCommandSubcommandBuilder) => { return command.setName("about").setDescription("About this bot!)"); }, execute: async (interaction: CommandInteraction) => { + await deferReply(interaction, false); + const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild ); diff --git a/src/commands/utility/modules/avatar/index.ts b/src/commands/utility/modules/avatar/index.ts index 1b87931..a6e4ffb 100644 --- a/src/commands/utility/modules/avatar/index.ts +++ b/src/commands/utility/modules/avatar/index.ts @@ -1,10 +1,9 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { CommandInteraction, EmbedBuilder } from "discord.js"; +import deferReply from "../../../../handlers/deferReply"; import getEmbedConfig from "../../../../helpers/getEmbedData"; export default { - metadata: { guildOnly: false, ephemeral: false }, - builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("avatar") @@ -16,6 +15,8 @@ export default { ); }, execute: async (interaction: CommandInteraction) => { + await deferReply(interaction, false); + const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild ); diff --git a/src/commands/utility/modules/index.ts b/src/commands/utility/modules/index.ts deleted file mode 100644 index 7383403..0000000 --- a/src/commands/utility/modules/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -import about from "./about"; -import avatar from "./avatar"; -import ping from "./ping"; -import stats from "./stats"; - -export default { - avatar, - about, - stats, - ping, -}; diff --git a/src/commands/utility/modules/ping/index.ts b/src/commands/utility/modules/ping/index.ts index 1442e03..3855e89 100644 --- a/src/commands/utility/modules/ping/index.ts +++ b/src/commands/utility/modules/ping/index.ts @@ -2,16 +2,17 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { CommandInteraction, EmbedBuilder } from "discord.js"; // Configurations +import deferReply from "../../../../handlers/deferReply"; import getEmbedConfig from "../../../../helpers/getEmbedData"; // Function export default { - metadata: { guildOnly: false, ephemeral: false }, - builder: (command: SlashCommandSubcommandBuilder) => { return command.setName("ping").setDescription("Ping this bot"); }, execute: async (interaction: CommandInteraction) => { + await deferReply(interaction, false); + const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild ); diff --git a/src/commands/utility/modules/stats/index.ts b/src/commands/utility/modules/stats/index.ts index eae22f3..b422423 100644 --- a/src/commands/utility/modules/stats/index.ts +++ b/src/commands/utility/modules/stats/index.ts @@ -1,14 +1,15 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { CommandInteraction, EmbedBuilder } from "discord.js"; +import deferReply from "../../../../handlers/deferReply"; import getEmbedConfig from "../../../../helpers/getEmbedData"; export default { - metadata: { guildOnly: false, ephemeral: false }, - builder: (command: SlashCommandSubcommandBuilder) => { return command.setName("stats").setDescription("Check bot statistics!)"); }, execute: async (interaction: CommandInteraction) => { + await deferReply(interaction, false); + const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild ); From 193b778910be1d48bc896fcf0ecb317f111d3abb Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 16:49:35 +0200 Subject: [PATCH 193/215] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Rewritten=20join?= =?UTF-8?q?=20and=20leave=20messages=20to=20use=20Prisma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/events/guildMemberAdd/joinMessage.ts | 26 +++++++++++--------- src/events/guildMemberRemove/leaveMessage.ts | 26 +++++++++++--------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/src/events/guildMemberAdd/joinMessage.ts b/src/events/guildMemberAdd/joinMessage.ts index bf97b12..57703fb 100644 --- a/src/events/guildMemberAdd/joinMessage.ts +++ b/src/events/guildMemberAdd/joinMessage.ts @@ -1,6 +1,6 @@ -import { EmbedBuilder, GuildMember, TextChannel } from "discord.js"; +import { ChannelType, EmbedBuilder, GuildMember } from "discord.js"; +import prisma from "../../handlers/database"; import getEmbedConfig from "../../helpers/getEmbedData"; -import guildSchema from "../../models/guild"; export default { execute: async (member: GuildMember) => { @@ -8,29 +8,33 @@ export default { member.guild ); - const guildData = await guildSchema.findOne({ guildId: member.guild.id }); + const getGuild = await prisma.guild.findUnique({ + where: { id: member.guild.id }, + }); + + if (!getGuild) throw new Error("Guild not found"); const { client } = member; - if (guildData === null) return; - - if (guildData.welcome.status !== true) return; - if (!guildData.welcome.joinChannel) return; + if (getGuild.welcomeEnabled !== true) return; + if (!getGuild.welcomeJoinChannelId) return; const channel = client.channels.cache.get( - `${guildData.welcome.joinChannel}` + `${getGuild.welcomeJoinChannelId}` ); - if (channel === null) return; + if (!channel) throw new Error("Channel not found"); + if (channel.type !== ChannelType.GuildText) + throw new Error("Channel is not a text channel"); - (channel as TextChannel).send({ + channel.send({ embeds: [ new EmbedBuilder() .setColor(successColor) .setTitle(`${member.user.username} has joined the server!`) .setThumbnail(member.user.displayAvatarURL()) .setDescription( - guildData.welcome.joinChannelMessage || + getGuild.welcomeJoinChannelMessage || "Configure a join message in the `/settings guild welcome`." ) .setTimestamp() diff --git a/src/events/guildMemberRemove/leaveMessage.ts b/src/events/guildMemberRemove/leaveMessage.ts index 79a2460..9ac7c85 100644 --- a/src/events/guildMemberRemove/leaveMessage.ts +++ b/src/events/guildMemberRemove/leaveMessage.ts @@ -1,6 +1,6 @@ -import { EmbedBuilder, GuildMember, TextChannel } from "discord.js"; +import { ChannelType, EmbedBuilder, GuildMember } from "discord.js"; +import prisma from "../../handlers/database"; import getEmbedConfig from "../../helpers/getEmbedData"; -import guildSchema from "../../models/guild"; export default { execute: async (member: GuildMember) => { @@ -8,29 +8,33 @@ export default { member.guild ); - const guildData = await guildSchema.findOne({ guildId: member.guild.id }); + const getGuild = await prisma.guild.findUnique({ + where: { id: member.guild.id }, + }); + + if (!getGuild) throw new Error("Guild not found"); const { client } = member; - if (guildData === null) return; - - if (guildData.welcome.status !== true) return; - if (!guildData.welcome.leaveChannel) return; + if (getGuild.welcomeEnabled !== true) return; + if (!getGuild.welcomeLeaveChannelId) return; const channel = client.channels.cache.get( - `${guildData.welcome.leaveChannel}` + `${getGuild.welcomeLeaveChannelId}` ); - if (channel === null) return; + if (!channel) throw new Error("Channel not found"); + if (channel.type !== ChannelType.GuildText) + throw new Error("Channel is not a text channel"); - (channel as TextChannel).send({ + channel.send({ embeds: [ new EmbedBuilder() .setColor(errorColor) .setTitle(`${member.user.username} has left the server!`) .setThumbnail(member.user.displayAvatarURL()) .setDescription( - guildData.welcome.leaveChannelMessage || + getGuild.welcomeLeaveChannelMessage || "Configure a leave message in the `/settings guild welcome`." ) .setTimestamp() From 8898959c848d057dd176180e27b2b07fbd3725c6 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 17:36:34 +0200 Subject: [PATCH 194/215] =?UTF-8?q?=F0=9F=9A=80=20Bot=20is=20fully=20migra?= =?UTF-8?q?ted=20over=20to=20Prisma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migration.sql | 16 ++ .../migration.sql | 25 +++ .../migration.sql | 20 ++ .../migration.sql | 20 ++ prisma/migrations/migration_lock.toml | 2 +- prisma/schema.prisma | 32 ++- src/commands/shop/modules/roles/index.ts | 11 +- .../shop/modules/roles/modules/buy/index.ts | 207 ++++++++++++------ .../modules/roles/modules/cancel/index.ts | 144 ++++++++---- src/events/guildMemberAdd/audits.ts | 21 +- src/events/guildMemberRemove/audits.ts | 17 +- src/events/interactionCreate/audits.ts | 19 +- src/events/messageDelete/audits.ts | 15 +- src/events/messageUpdate/audits.ts | 15 +- src/models/guild.ts | 142 ------------ src/models/shopRole.ts | 48 ---- src/models/timeout.ts | 38 ---- src/models/user.ts | 42 ---- .../modules/roles/components/dueForPayment.ts | 4 +- .../roles/components/overDueForPayment.ts | 140 ++++++++---- src/schedules/shop/modules/roles/index.ts | 35 ++- src/schedules/timeouts/index.ts | 44 ++-- 22 files changed, 541 insertions(+), 516 deletions(-) create mode 100644 prisma/migrations/20221021150615_shoproles_model/migration.sql create mode 100644 prisma/migrations/20221021151136_shoproles_model_correction/migration.sql create mode 100644 prisma/migrations/20221021151337_shoproles_model_correction/migration.sql create mode 100644 prisma/migrations/20221021153546_shoproles_model_correction/migration.sql delete mode 100644 src/models/guild.ts delete mode 100644 src/models/shopRole.ts delete mode 100644 src/models/timeout.ts delete mode 100644 src/models/user.ts diff --git a/prisma/migrations/20221021150615_shoproles_model/migration.sql b/prisma/migrations/20221021150615_shoproles_model/migration.sql new file mode 100644 index 0000000..1859cc1 --- /dev/null +++ b/prisma/migrations/20221021150615_shoproles_model/migration.sql @@ -0,0 +1,16 @@ +-- CreateTable +CREATE TABLE "GuildShopRoles" ( + "guildId" TEXT NOT NULL, + "channelId" TEXT NOT NULL, + "roleId" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "pricePerHour" INTEGER NOT NULL DEFAULT 5, + "lastPayed" DATETIME NOT NULL, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + CONSTRAINT "GuildShopRoles_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, + CONSTRAINT "GuildShopRoles_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE +); + +-- CreateIndex +CREATE UNIQUE INDEX "GuildShopRoles_guildId_channelId_key" ON "GuildShopRoles"("guildId", "channelId"); diff --git a/prisma/migrations/20221021151136_shoproles_model_correction/migration.sql b/prisma/migrations/20221021151136_shoproles_model_correction/migration.sql new file mode 100644 index 0000000..5631656 --- /dev/null +++ b/prisma/migrations/20221021151136_shoproles_model_correction/migration.sql @@ -0,0 +1,25 @@ +/* + Warnings: + + - You are about to drop the column `channelId` on the `GuildShopRoles` table. All the data in the column will be lost. + +*/ +-- RedefineTables +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_GuildShopRoles" ( + "guildId" TEXT NOT NULL, + "roleId" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "pricePerHour" INTEGER NOT NULL DEFAULT 5, + "lastPayed" DATETIME NOT NULL, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + CONSTRAINT "GuildShopRoles_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, + CONSTRAINT "GuildShopRoles_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE +); +INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") SELECT "createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId" FROM "GuildShopRoles"; +DROP TABLE "GuildShopRoles"; +ALTER TABLE "new_GuildShopRoles" RENAME TO "GuildShopRoles"; +CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles"("guildId", "userId", "roleId"); +PRAGMA foreign_key_check; +PRAGMA foreign_keys=ON; diff --git a/prisma/migrations/20221021151337_shoproles_model_correction/migration.sql b/prisma/migrations/20221021151337_shoproles_model_correction/migration.sql new file mode 100644 index 0000000..8a3fe75 --- /dev/null +++ b/prisma/migrations/20221021151337_shoproles_model_correction/migration.sql @@ -0,0 +1,20 @@ +-- RedefineTables +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_GuildShopRoles" ( + "guildId" TEXT NOT NULL, + "roleId" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "pricePerHour" INTEGER NOT NULL DEFAULT 5, + "lastPayed" DATETIME NOT NULL, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + CONSTRAINT "GuildShopRoles_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, + CONSTRAINT "GuildShopRoles_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, + CONSTRAINT "GuildShopRoles_guildId_userId_fkey" FOREIGN KEY ("guildId", "userId") REFERENCES "GuildMember" ("guildId", "userId") ON DELETE RESTRICT ON UPDATE CASCADE +); +INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") SELECT "createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId" FROM "GuildShopRoles"; +DROP TABLE "GuildShopRoles"; +ALTER TABLE "new_GuildShopRoles" RENAME TO "GuildShopRoles"; +CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles"("guildId", "userId", "roleId"); +PRAGMA foreign_key_check; +PRAGMA foreign_keys=ON; diff --git a/prisma/migrations/20221021153546_shoproles_model_correction/migration.sql b/prisma/migrations/20221021153546_shoproles_model_correction/migration.sql new file mode 100644 index 0000000..88d1d66 --- /dev/null +++ b/prisma/migrations/20221021153546_shoproles_model_correction/migration.sql @@ -0,0 +1,20 @@ +-- RedefineTables +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_GuildShopRoles" ( + "guildId" TEXT NOT NULL, + "roleId" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "pricePerHour" INTEGER NOT NULL DEFAULT 5, + "lastPayed" DATETIME NOT NULL, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + CONSTRAINT "GuildShopRoles_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, + CONSTRAINT "GuildShopRoles_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, + CONSTRAINT "GuildShopRoles_userId_guildId_fkey" FOREIGN KEY ("userId", "guildId") REFERENCES "GuildMember" ("userId", "guildId") ON DELETE RESTRICT ON UPDATE CASCADE +); +INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") SELECT "createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId" FROM "GuildShopRoles"; +DROP TABLE "GuildShopRoles"; +ALTER TABLE "new_GuildShopRoles" RENAME TO "GuildShopRoles"; +CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles"("guildId", "userId", "roleId"); +PRAGMA foreign_key_check; +PRAGMA foreign_keys=ON; diff --git a/prisma/migrations/migration_lock.toml b/prisma/migrations/migration_lock.toml index 6fcf33d..e5e5c47 100644 --- a/prisma/migrations/migration_lock.toml +++ b/prisma/migrations/migration_lock.toml @@ -1,3 +1,3 @@ # Please do not edit this file manually # It should be added in your version-control system (i.e. Git) -provider = "sqlite" +provider = "sqlite" \ No newline at end of file diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 5418d5b..f7923d4 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -58,8 +58,9 @@ model Guild { welcomeLeaveChannelId String? welcomeLeaveChannelMessage String? - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + GuildShopRoles GuildShopRoles[] } model User { @@ -72,8 +73,9 @@ model User { reputationsEarned Int @default(0) Cooldown Cooldown[] - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + GuildShopRoles GuildShopRoles[] } model GuildMember { @@ -89,8 +91,9 @@ model GuildMember { creditsEarned Int @default(0) pointsEarned Int @default(0) - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + GuildShopRoles GuildShopRoles[] // Unique Identifier @@unique([userId, guildId]) @@ -122,3 +125,20 @@ model Cooldown { @@unique([guildId, userId, timeoutId]) } + +model GuildShopRoles { + guildId String + roleId String + userId String + pricePerHour Int @default(5) + lastPayed DateTime + + guild Guild @relation(fields: [guildId], references: [id]) + user User @relation(fields: [userId], references: [id]) + + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + member GuildMember? @relation(fields: [userId, guildId], references: [userId, guildId]) + + @@unique([guildId, userId, roleId]) +} diff --git a/src/commands/shop/modules/roles/index.ts b/src/commands/shop/modules/roles/index.ts index 0064d14..4d954cf 100644 --- a/src/commands/shop/modules/roles/index.ts +++ b/src/commands/shop/modules/roles/index.ts @@ -8,7 +8,7 @@ import { ChatInputCommandInteraction } from "discord.js"; import moduleBuy from "./modules/buy"; import moduleCancel from "./modules/cancel"; -import guildSchema from "../../../../models/guild"; +import prisma from "../../../../handlers/database"; export default { builder: (group: SlashCommandSubcommandGroupBuilder) => { @@ -26,13 +26,12 @@ export default { if (!interaction.guild) return; const { options, guild } = interaction; - const guildDB = await guildSchema?.findOne({ - guildId: guild?.id, + const getGuild = await prisma.guild.findUnique({ + where: { id: guild.id }, }); + if (!getGuild) throw new Error("Guild not found"); - if (guildDB === null) return; - - if (!guildDB.shop.roles.status) + if (!getGuild.shopRolesEnabled) throw new Error("This server has disabled shop roles."); if (options?.getSubcommand() === "buy") { diff --git a/src/commands/shop/modules/roles/modules/buy/index.ts b/src/commands/shop/modules/roles/modules/buy/index.ts index e1ca0b2..a6e3b0b 100644 --- a/src/commands/shop/modules/roles/modules/buy/index.ts +++ b/src/commands/shop/modules/roles/modules/buy/index.ts @@ -1,12 +1,22 @@ // Dependencies // Helpers import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import { ChatInputCommandInteraction } from "discord.js"; +import { + ChatInputCommandInteraction, + ColorResolvable, + EmbedBuilder, + GuildMemberRoleManager, +} from "discord.js"; import deferReply from "../../../../../../handlers/deferReply"; +import getEmbedData from "../../../../../../helpers/getEmbedData"; +import logger from "../../../../../../middlewares/logger"; // Configurations // import fetchUser from "../../../../../../helpers/userData"; // Models +import prisma from "../../../../../../handlers/database"; +import pluralize from "../../../../../../helpers/pluralize"; + // Function export default { builder: (command: SlashCommandSubcommandBuilder) => { @@ -29,65 +39,140 @@ export default { execute: async (interaction: ChatInputCommandInteraction) => { await deferReply(interaction, true); - // const { successColor, footerText, footerIcon } = await getEmbedConfig( - // interaction.guild - // ); - // const { options, guild, user, member } = interaction; - // const optionName = options?.getString("name"); - // const optionColor = options?.getString("color"); - // // If amount is null - // if (optionName === null) - // throw new Error("We could not read your requested name"); - // await guild?.roles - // .create({ - // name: optionName, - // color: optionColor as ColorResolvable, - // reason: `${user?.id} bought from shop`, - // }) - // .then(async (role) => { - // // Get guild object - // const guildDB = await guildSchema?.findOne({ - // guildId: guild?.id, - // }); - // const userDB = await fetchUser(user, guild); - // if (userDB === null) { - // return logger?.silly(`User is null`); - // } - // if (guildDB === null) { - // return logger?.silly(`Guild is null`); - // } - // if (guildDB.shop === null) { - // return logger?.silly(`Shop is null`); - // } - // const { pricePerHour } = guildDB.shop.roles; - // userDB.credits -= pricePerHour; - // await userDB?.save(); - // await shopRolesSchema?.create({ - // roleId: role?.id, - // userId: user?.id, - // guildId: guild?.id, - // pricePerHour, - // lastPayed: new Date(), - // }); - // await (member?.roles as GuildMemberRoleManager)?.add(role?.id); - // logger?.silly(`Role ${role?.name} was bought by ${user?.tag}`); - // const interactionEmbed = new EmbedBuilder() - // .setTitle("[:shopping_cart:] Buy") - // .setDescription( - // `You bought **${optionName}** for **${pluralize( - // pricePerHour, - // "credit" - // )}**.` - // ) - // .setTimestamp() - // .setColor(successColor) - // .setFooter({ text: footerText, iconURL: footerIcon }); - // return interaction?.editReply({ - // embeds: [interactionEmbed], - // }); - // }) - // .catch(() => { - // throw new Error("Failed creating role."); - // }); + const { successColor, footerText, footerIcon } = await getEmbedData( + interaction.guild + ); + const { options, guild, user, member } = interaction; + const optionName = options?.getString("name"); + const optionColor = options?.getString("color"); + // If amount is null + if (optionName === null) + throw new Error("We could not read your requested name"); + await guild?.roles + .create({ + name: optionName, + color: optionColor as ColorResolvable, + reason: `${user?.id} bought from shop`, + }) + .then(async (role) => { + const userId = "SNOWFLKAE"; + const guildId = "SNOWFLAKE"; + + const createGuildMember = await prisma.guildMember.upsert({ + where: { + userId_guildId: { + userId, + guildId, + }, + }, + update: {}, + create: { + user: { + connectOrCreate: { + create: { + id: userId, + }, + where: { + id: userId, + }, + }, + }, + guild: { + connectOrCreate: { + create: { + id: guildId, + }, + where: { + id: guildId, + }, + }, + }, + }, + include: { + user: true, + guild: true, + }, + }); + + logger.silly(createGuildMember); + + // Get guild object + const pricePerHour = createGuildMember.guild.shopRolesPricePerHour; + + const updateGuildMember = await prisma.guildMember.update({ + where: { + userId_guildId: { + userId, + guildId, + }, + }, + data: { + creditsEarned: { decrement: pricePerHour }, + }, + }); + + logger.silly(updateGuildMember); + + const createShopRole = await prisma.guildShopRoles.upsert({ + where: { + guildId_userId_roleId: { + guildId: guild.id, + userId: user.id, + roleId: role.id, + }, + }, + update: {}, + create: { + roleId: role.id, + lastPayed: new Date(), + user: { + connectOrCreate: { + create: { + id: user.id, + }, + where: { + id: user.id, + }, + }, + }, + guild: { + connectOrCreate: { + create: { + id: guild.id, + }, + where: { + id: guild.id, + }, + }, + }, + }, + include: { + user: true, + guild: true, + }, + }); + + logger.silly(createShopRole); + + await (member?.roles as GuildMemberRoleManager)?.add(role?.id); + logger?.silly(`Role ${role?.name} was bought by ${user?.tag}`); + const interactionEmbed = new EmbedBuilder() + .setTitle("[:shopping_cart:] Buy") + .setDescription( + `You bought **${optionName}** for **${pluralize( + pricePerHour, + "credit" + )}**.` + ) + .setTimestamp() + .setColor(successColor) + .setFooter({ text: footerText, iconURL: footerIcon }); + return interaction?.editReply({ + embeds: [interactionEmbed], + }); + }) + .catch(() => { + throw new Error("Failed creating role."); + }); }, }; diff --git a/src/commands/shop/modules/roles/modules/cancel/index.ts b/src/commands/shop/modules/roles/modules/cancel/index.ts index 4f842f9..8807ac4 100644 --- a/src/commands/shop/modules/roles/modules/cancel/index.ts +++ b/src/commands/shop/modules/roles/modules/cancel/index.ts @@ -1,11 +1,21 @@ // Dependencies // Helpers import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import { ChatInputCommandInteraction } from "discord.js"; +import { + ChatInputCommandInteraction, + EmbedBuilder, + GuildMemberRoleManager, +} from "discord.js"; // Configurations -// import fetchUser from "../../../../../../helpers/userData"; // Models import deferReply from "../../../../../../handlers/deferReply"; +import logger from "../../../../../../middlewares/logger"; +// Configurations +// Models + +import prisma from "../../../../../../handlers/database"; +import getEmbedData from "../../../../../../helpers/getEmbedData"; +import pluralize from "../../../../../../helpers/pluralize"; // Function export default { @@ -23,45 +33,95 @@ export default { execute: async (interaction: ChatInputCommandInteraction) => { await deferReply(interaction, true); - // const { successColor, footerText, footerIcon } = await getEmbedConfig( - // interaction.guild - // ); - // const { options, guild, user, member } = interaction; - // const optionRole = options.getRole("role"); - // if (optionRole === null) - // throw new Error("We could not read your requested role."); - // const roleExist = await shopRolesSchema?.findOne({ - // guildId: guild?.id, - // userId: user?.id, - // roleId: optionRole?.id, - // }); - // if (roleExist === null) return; - // await (member?.roles as GuildMemberRoleManager)?.remove(optionRole?.id); - // await guild?.roles - // .delete(optionRole?.id, `${user?.id} canceled from shop`) - // .then(async () => { - // const userDB = await fetchUser(user, guild); - // if (userDB === null) { - // return logger?.silly(`User is null`); - // } - // await shopRolesSchema?.deleteOne({ - // roleId: optionRole?.id, - // userId: user?.id, - // guildId: guild?.id, - // }); - // const interactionEmbed = new EmbedBuilder() - // .setTitle("[:shopping_cart:] Cancel") - // .setDescription(`You have canceled ${optionRole.name}.`) - // .setTimestamp() - // .setColor(successColor) - // .addFields({ - // name: "Your balance", - // value: `${pluralize(userDB?.credits, "credit")}`, - // }) - // .setFooter({ text: footerText, iconURL: footerIcon }); - // return interaction?.editReply({ - // embeds: [interactionEmbed], - // }); - // }); + const { successColor, footerText, footerIcon } = await getEmbedData( + interaction.guild + ); + const { options, guild, user, member } = interaction; + const optionRole = options.getRole("role"); + if (optionRole === null) + throw new Error("We could not read your requested role."); + if (!guild) throw new Error("No guild specified"); + if (!user) throw new Error("No user specified"); + + const roleExist = await prisma.guildShopRoles.findUnique({ + where: { + guildId_userId_roleId: { + guildId: guild.id, + userId: user.id, + roleId: optionRole.id, + }, + }, + }); + if (roleExist === null) return; + await (member?.roles as GuildMemberRoleManager)?.remove(optionRole?.id); + await guild?.roles + .delete(optionRole?.id, `${user?.id} canceled from shop`) + .then(async () => { + const createGuildMember = await prisma.guildMember.upsert({ + where: { + userId_guildId: { + userId: user.id, + guildId: guild.id, + }, + }, + update: {}, + create: { + user: { + connectOrCreate: { + create: { + id: user.id, + }, + where: { + id: user.id, + }, + }, + }, + guild: { + connectOrCreate: { + create: { + id: guild.id, + }, + where: { + id: guild.id, + }, + }, + }, + }, + include: { + user: true, + guild: true, + }, + }); + + logger.silly(createGuildMember); + + if (!createGuildMember) throw new Error("Guild member not created"); + + const deleteShopRole = await prisma.guildShopRoles.delete({ + where: { + guildId_userId_roleId: { + guildId: guild?.id, + userId: user?.id, + roleId: optionRole?.id, + }, + }, + }); + + logger.silly(deleteShopRole); + + const interactionEmbed = new EmbedBuilder() + .setTitle("[:shopping_cart:] Cancel") + .setDescription(`You have canceled ${optionRole.name}.`) + .setTimestamp() + .setColor(successColor) + .addFields({ + name: "Your balance", + value: `${pluralize(createGuildMember.creditsEarned, "credit")}`, + }) + .setFooter({ text: footerText, iconURL: footerIcon }); + return interaction?.editReply({ + embeds: [interactionEmbed], + }); + }); }, }; diff --git a/src/events/guildMemberAdd/audits.ts b/src/events/guildMemberAdd/audits.ts index 697408d..0d61fa1 100644 --- a/src/events/guildMemberAdd/audits.ts +++ b/src/events/guildMemberAdd/audits.ts @@ -1,25 +1,28 @@ import { ChannelType, EmbedBuilder, GuildMember } from "discord.js"; +import prisma from "../../handlers/database"; import getEmbedConfig from "../../helpers/getEmbedData"; import logger from "../../middlewares/logger"; -import guildSchema from "../../models/guild"; export default { execute: async (member: GuildMember) => { const { client, guild } = member; - const guildData = await guildSchema.findOne({ guildId: member.guild.id }); - if (!guildData) { - throw new Error("Could not find guild"); - } - if (guildData.audits.status !== true) return; - if (!guildData.audits.channelId) { + const getGuild = await prisma.guild.findUnique({ + where: { id: member.guild.id }, + }); + if (!getGuild) throw new Error("Guild not found"); + + if (getGuild.auditsEnabled !== true) return; + if (!getGuild.auditsChannelId) { throw new Error("Channel not found"); } const embedConfig = await getEmbedConfig(guild); - const channel = client.channels.cache.get(guildData.audits.channelId); - if (channel?.type !== ChannelType.GuildText) { + const channel = client.channels.cache.get(getGuild.auditsChannelId); + + if (!channel) throw new Error("Channel not found"); + if (channel.type !== ChannelType.GuildText) { throw new Error("Channel must be a text channel"); } diff --git a/src/events/guildMemberRemove/audits.ts b/src/events/guildMemberRemove/audits.ts index d3967cd..ff4bb59 100644 --- a/src/events/guildMemberRemove/audits.ts +++ b/src/events/guildMemberRemove/audits.ts @@ -1,24 +1,25 @@ import { ChannelType, EmbedBuilder, GuildMember } from "discord.js"; +import prisma from "../../handlers/database"; import getEmbedConfig from "../../helpers/getEmbedData"; import logger from "../../middlewares/logger"; -import guildSchema from "../../models/guild"; export default { execute: async (member: GuildMember) => { const { client, guild } = member; - const guildData = await guildSchema.findOne({ guildId: member.guild.id }); - if (!guildData) { - throw new Error("Could not find guild"); - } - if (guildData.audits.status !== true) return; - if (!guildData.audits.channelId) { + const getGuild = await prisma.guild.findUnique({ + where: { id: member.guild.id }, + }); + if (!getGuild) throw new Error("Guild not found"); + + if (getGuild.auditsEnabled !== true) return; + if (!getGuild.auditsChannelId) { throw new Error("Channel not found"); } const embedConfig = await getEmbedConfig(guild); - const channel = client.channels.cache.get(guildData.audits.channelId); + const channel = client.channels.cache.get(getGuild.auditsChannelId); if (channel?.type !== ChannelType.GuildText) { throw new Error("Channel must be a text channel"); } diff --git a/src/events/interactionCreate/audits.ts b/src/events/interactionCreate/audits.ts index 3fc22f3..90a55e4 100644 --- a/src/events/interactionCreate/audits.ts +++ b/src/events/interactionCreate/audits.ts @@ -1,7 +1,7 @@ import { BaseInteraction, ChannelType, EmbedBuilder } from "discord.js"; +import prisma from "../../handlers/database"; import getEmbedConfig from "../../helpers/getEmbedData"; import logger from "../../middlewares/logger"; -import guildSchema from "../../models/guild"; export default { execute: async (interaction: BaseInteraction) => { @@ -9,22 +9,21 @@ export default { if (interaction.guild === null) return; + const getGuild = await prisma.guild.findUnique({ + where: { id: interaction.guild.id }, + }); + if (!getGuild) throw new Error("Guild not found"); + const { footerText, footerIcon, successColor } = await getEmbedConfig( interaction.guild ); - const guildData = await guildSchema.findOne({ - guildId: interaction.guild.id, - }); - const { client } = interaction; - if (guildData === null) return; + if (getGuild.auditsEnabled !== true) return; + if (!getGuild.auditsChannelId) return; - if (guildData.audits.status !== true) return; - if (!guildData.audits.channelId) return; - - const channel = client.channels.cache.get(`${guildData.audits.channelId}`); + const channel = client.channels.cache.get(`${getGuild.auditsChannelId}`); if (!channel) return; if (channel.type !== ChannelType.GuildText) return; diff --git a/src/events/messageDelete/audits.ts b/src/events/messageDelete/audits.ts index 9bf3ae9..56a8ac1 100644 --- a/src/events/messageDelete/audits.ts +++ b/src/events/messageDelete/audits.ts @@ -1,7 +1,7 @@ import { ChannelType, EmbedBuilder, Message } from "discord.js"; +import prisma from "../../handlers/database"; import getEmbedConfig from "../../helpers/getEmbedData"; import logger from "../../middlewares/logger"; -import guildSchema from "../../models/guild"; export default { execute: async (message: Message) => { @@ -13,18 +13,19 @@ export default { message.guild ); - const guildData = await guildSchema.findOne({ - guildId: message.guild.id, + const getGuild = await prisma.guild.findUnique({ + where: { id: message.guild.id }, }); + if (!getGuild) throw new Error("Guild not found"); const { client } = message; - if (guildData === null) return; + if (!getGuild) throw new Error("Guild not found"); - if (guildData.audits.status !== true) return; - if (!guildData.audits.channelId) return; + if (getGuild.auditsEnabled !== true) return; + if (!getGuild.auditsChannelId) return; - const channel = client.channels.cache.get(`${guildData.audits.channelId}`); + const channel = client.channels.cache.get(`${getGuild.auditsChannelId}`); if (!channel) return; if (channel.type !== ChannelType.GuildText) return; diff --git a/src/events/messageUpdate/audits.ts b/src/events/messageUpdate/audits.ts index ba35962..a498385 100644 --- a/src/events/messageUpdate/audits.ts +++ b/src/events/messageUpdate/audits.ts @@ -1,8 +1,8 @@ /* eslint-disable no-loops/no-loops */ import { ChannelType, EmbedBuilder, Message } from "discord.js"; +import prisma from "../../handlers/database"; import getEmbedConfig from "../../helpers/getEmbedData"; import logger from "../../middlewares/logger"; -import guildSchema from "../../models/guild"; export default { execute: async (oldMessage: Message, newMessage: Message) => { @@ -16,18 +16,17 @@ export default { newMessage.guild ); - const guildData = await guildSchema.findOne({ - guildId: oldMessage.guild.id, + const getGuild = await prisma.guild.findUnique({ + where: { id: oldMessage.guild.id }, }); + if (!getGuild) throw new Error("Guild not found"); const { client } = oldMessage; - if (guildData === null) return; + if (getGuild.auditsEnabled !== true) return; + if (!getGuild.auditsChannelId) return; - if (guildData.audits.status !== true) return; - if (!guildData.audits.channelId) return; - - const channel = client.channels.cache.get(`${guildData.audits.channelId}`); + const channel = client.channels.cache.get(`${getGuild.auditsChannelId}`); if (!channel) return; if (channel.type !== ChannelType.GuildText) return; diff --git a/src/models/guild.ts b/src/models/guild.ts deleted file mode 100644 index 140befa..0000000 --- a/src/models/guild.ts +++ /dev/null @@ -1,142 +0,0 @@ -import { ColorResolvable } from "discord.js"; -import { model, Schema } from "mongoose"; - -interface IGuild { - guildId: string; - credits: { - status: boolean; - rate: number; - timeout: number; - workRate: number; - minimumLength: number; - workTimeout: number; - }; - embeds: { - successColor: ColorResolvable; - waitColor: ColorResolvable; - errorColor: ColorResolvable; - footerIcon: string; - footerText: string; - }; - shop: { roles: { status: boolean; pricePerHour: number } }; - points: { - status: boolean; - rate: number; - minimumLength: number; - timeout: number; - }; - welcome: { - status: boolean; - joinChannel: string; - leaveChannel: string; - joinChannelMessage: string; - leaveChannelMessage: string; - }; - audits: { status: boolean; channelId: string }; -} - -const guildSchema = new Schema( - { - guildId: { - type: String, - required: true, - unique: true, - index: true, - }, - credits: { - status: { - type: Boolean, - default: true, - }, - rate: { - type: Number, - default: 1, - }, - minimumLength: { - type: Number, - default: 5, - }, - timeout: { - type: Number, - default: 5, - }, - workRate: { - type: Number, - default: 15, - }, - workTimeout: { - type: Number, - default: 900, - }, - }, - embeds: { - successColor: { - type: String, - default: "#22bb33", - }, - waitColor: { - type: String, - default: "#f0ad4e", - }, - errorColor: { - type: String, - default: "#bb2124", - }, - footerText: { - type: String, - default: "https://github.com/ZynerOrg/xyter", - }, - footerIcon: { - type: String, - default: "https://github.com/ZynerOrg.png", - }, - }, - shop: { - roles: { - status: { - type: Boolean, - default: false, - }, - pricePerHour: { - type: Number, - default: 5, - }, - }, - }, - points: { - status: { - type: Boolean, - default: false, - }, - rate: { - type: Number, - default: 1, - }, - minimumLength: { - type: Number, - default: 5, - }, - timeout: { - type: Number, - default: 5, - }, - }, - welcome: { - status: { - type: Boolean, - default: false, - }, - joinChannel: { type: String }, - leaveChannel: { type: String }, - joinChannelMessage: { type: String }, - leaveChannelMessage: { type: String }, - }, - audits: { - status: { type: Boolean, default: false }, - channelId: { type: String }, - }, - }, - { timestamps: true } -); - -export default model("guild", guildSchema); diff --git a/src/models/shopRole.ts b/src/models/shopRole.ts deleted file mode 100644 index 8711760..0000000 --- a/src/models/shopRole.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { Snowflake } from "discord.js"; -import { model, Schema } from "mongoose"; - -export interface IShopRole { - roleId: Snowflake; - userId: Snowflake; - guildId: Snowflake; - pricePerHour: number; - lastPayed: Date; -} - -const shopRoleSchema = new Schema( - { - roleId: { - type: String, - required: true, - unique: false, - index: true, - }, - userId: { - type: String, - required: true, - unique: false, - index: true, - }, - guildId: { - type: String, - required: true, - unique: false, - index: true, - }, - pricePerHour: { - type: Number, - required: true, - unique: false, - index: true, - default: 5, - }, - lastPayed: { - type: Date, - unique: false, - index: true, - }, - }, - { timestamps: true } -); - -export default model("shopRole", shopRoleSchema); diff --git a/src/models/timeout.ts b/src/models/timeout.ts deleted file mode 100644 index dc1ba97..0000000 --- a/src/models/timeout.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { Snowflake } from "discord.js"; -import { model, Schema } from "mongoose"; - -export interface ITimeout { - userId: Snowflake; - guildId: Snowflake; - cooldown: number; - timeoutId: string; - createdAt: Date; - updatedAt: Date; -} - -const timeoutSchema = new Schema( - { - userId: { - type: String, - required: true, - unique: false, - index: true, - }, - guildId: { - type: String, - required: true, - unique: false, - index: true, - }, - cooldown: { - type: Number, - required: true, - unique: false, - index: true, - }, - timeoutId: { type: String }, - }, - { timestamps: true } -); - -export default model("timeout", timeoutSchema); diff --git a/src/models/user.ts b/src/models/user.ts deleted file mode 100644 index 8170ac6..0000000 --- a/src/models/user.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { Snowflake } from "discord.js"; -import { model, Schema } from "mongoose"; - -export interface IUser { - guildId: Snowflake; - userId: Snowflake; - language: string; - reputation: number; - credits: number; - level: number; - points: number; - updatedAt: Date; - createdAt: Date; -} - -const userSchema = new Schema( - { - guildId: { - type: String, - required: true, - unique: false, - index: true, - }, - userId: { - type: String, - required: true, - unique: false, - index: true, - }, - language: { - type: String, - default: "en", - }, - reputation: { type: Number, default: 0 }, - credits: { type: Number, default: 0 }, - level: { type: Number, default: 0 }, - points: { type: Number, default: 0 }, - }, - { timestamps: true } -); - -export default model("user", userSchema); diff --git a/src/schedules/shop/modules/roles/components/dueForPayment.ts b/src/schedules/shop/modules/roles/components/dueForPayment.ts index f2b487d..f87c94c 100644 --- a/src/schedules/shop/modules/roles/components/dueForPayment.ts +++ b/src/schedules/shop/modules/roles/components/dueForPayment.ts @@ -1,9 +1,9 @@ import { Client } from "discord.js"; import logger from "../../../../../middlewares/logger"; -import { IShopRole } from "../../../../../interfaces/ShopRole"; +import { GuildShopRoles } from "@prisma/client"; -export const execute = async (_client: Client, role: IShopRole) => { +export const execute = async (_client: Client, role: GuildShopRoles) => { const { roleId } = role; logger.silly(`Shop role ${roleId} is not due for payment.`); diff --git a/src/schedules/shop/modules/roles/components/overDueForPayment.ts b/src/schedules/shop/modules/roles/components/overDueForPayment.ts index cbc5568..7020db7 100644 --- a/src/schedules/shop/modules/roles/components/overDueForPayment.ts +++ b/src/schedules/shop/modules/roles/components/overDueForPayment.ts @@ -1,22 +1,14 @@ import { Client } from "discord.js"; import logger from "../../../../../middlewares/logger"; -import { IShopRole } from "../../../../../interfaces/ShopRole"; -import guildSchema from "../../../../../models/guild"; -import shopRoleSchema from "../../../../../models/shopRole"; -import userSchema from "../../../../../models/user"; +import { GuildShopRoles } from "@prisma/client"; +import prisma from "../../../../../handlers/database"; // Execute the component -export const execute = async (client: Client, role: IShopRole) => { +export const execute = async (client: Client, role: GuildShopRoles) => { const { guildId, userId, roleId } = role; if (!userId) throw new Error("User ID not found for shop role."); - const guildData = await guildSchema.findOne({ guildId }); - if (!guildData) throw new Error("Guild not found."); - - const userData = await userSchema.findOne({ guildId, userId }); - if (!userData) throw new Error("User not found."); - const rGuild = client.guilds.cache.get(guildId); if (!rGuild) throw new Error("Guild not found."); @@ -28,26 +20,44 @@ export const execute = async (client: Client, role: IShopRole) => { logger.debug(`Shop role ${roleId} is due for payment.`); - const { pricePerHour } = guildData.shop.roles; + const getGuildMember = await prisma.guildMember.findUnique({ + where: { + userId_guildId: { + userId, + guildId, + }, + }, + include: { + user: true, + guild: true, + }, + }); - if (userData.credits < pricePerHour) { + logger.silly(getGuildMember); + + if (!getGuildMember) throw new Error("Could not find guild member."); + + const pricePerHour = getGuildMember.guild.shopRolesPricePerHour; + + if (getGuildMember.creditsEarned < pricePerHour) { await rMember.roles .remove(roleId) .then(async () => { - await shopRoleSchema - .deleteOne({ - userId, - roleId, - guildId, - }) - .then(() => { - logger.silly( - `Shop role document ${roleId} has been deleted from user ${userId}.` - ); - }) - .catch(() => { - throw new Error("Failed deleting shop role from user."); - }); + const deleteShopRole = await prisma.guildShopRoles.delete({ + where: { + guildId_userId_roleId: { + guildId, + userId, + roleId, + }, + }, + }); + + logger.silly(deleteShopRole); + + logger.silly( + `Shop role document ${roleId} has been deleted from user ${userId}.` + ); }) .catch(() => { throw new Error(`Failed removing role from user.`); @@ -56,25 +66,63 @@ export const execute = async (client: Client, role: IShopRole) => { throw new Error("User does not have enough credits."); } - userData.credits -= pricePerHour; - await userData - .save() - .then(async () => { - logger.silly(`User ${userId} has been updated.`); + const createGuildMember = await prisma.guildMember.upsert({ + where: { + userId_guildId: { + userId, + guildId, + }, + }, + update: { creditsEarned: { decrement: pricePerHour } }, + create: { + creditsEarned: -pricePerHour, + user: { + connectOrCreate: { + create: { + id: userId, + }, + where: { + id: userId, + }, + }, + }, + guild: { + connectOrCreate: { + create: { + id: guildId, + }, + where: { + id: guildId, + }, + }, + }, + }, + include: { + user: true, + guild: true, + }, + }); - role.lastPayed = new Date(); - await role - .save() - .then(() => { - logger.silly(`Shop role ${roleId} has been updated.`); - }) - .catch(() => { - throw new Error("Failed updating shop role."); - }); + logger.silly(createGuildMember); - logger.debug(`Shop role ${roleId} has been paid.`); - }) - .catch(() => { - throw new Error("Failed updating user."); - }); + logger.silly(`User ${userId} has been updated.`); + + const updateGuildShopRole = await prisma.guildShopRoles.update({ + where: { + guildId_userId_roleId: { + guildId, + userId, + roleId, + }, + }, + data: { + lastPayed: new Date(), + }, + }); + + logger.silly(updateGuildShopRole); + + logger.silly(`Shop role ${roleId} has been updated.`); + + logger.debug(`Shop role ${roleId} has been paid.`); }; diff --git a/src/schedules/shop/modules/roles/index.ts b/src/schedules/shop/modules/roles/index.ts index d4e2c21..6dea00e 100644 --- a/src/schedules/shop/modules/roles/index.ts +++ b/src/schedules/shop/modules/roles/index.ts @@ -1,32 +1,27 @@ +/* eslint-disable no-loops/no-loops */ import { Client } from "discord.js"; - -import { IShopRole } from "../../../../interfaces/ShopRole"; -import shopRoleSchema from "../../../../models/shopRole"; +import prisma from "../../../../handlers/database"; import * as dueForPayment from "./components/dueForPayment"; import * as overDueForPayment from "./components/overDueForPayment"; export const execute = async (client: Client) => { - const roles = await shopRoleSchema.find(); + const roles = await prisma.guildShopRoles.findMany(); - await Promise.all( - roles.map(async (role: IShopRole) => { - const { lastPayed } = role; - const nextPayment = new Date( - lastPayed.setHours(lastPayed.getHours() + 1) - ); + for await (const role of roles) { + const { lastPayed } = role; + const nextPayment = new Date(lastPayed.setHours(lastPayed.getHours() + 1)); - const now = new Date(); + const now = new Date(); - if (nextPayment > now) { - await dueForPayment.execute(client, role); + if (nextPayment > now) { + await dueForPayment.execute(client, role); - return; - } + return; + } - if (nextPayment < now) { - await overDueForPayment.execute(client, role); - } - }) - ); + if (nextPayment < now) { + await overDueForPayment.execute(client, role); + } + } }; diff --git a/src/schedules/timeouts/index.ts b/src/schedules/timeouts/index.ts index bcdddd1..764d825 100644 --- a/src/schedules/timeouts/index.ts +++ b/src/schedules/timeouts/index.ts @@ -1,36 +1,40 @@ +/* eslint-disable no-loops/no-loops */ import logger from "../../middlewares/logger"; -import timeoutSchema from "../../models/timeout"; - import addSeconds from "../../helpers/addSeconds"; +import prisma from "../../handlers/database"; + export const options = { schedule: "*/30 * * * *", // https://crontab.guru/ }; // Execute the job export const execute = async () => { - const timeouts = await timeoutSchema.find(); - await Promise.all( - timeouts.map(async (timeout) => { - const { guildId, userId, timeoutId, cooldown, createdAt } = timeout; + const getCooldown = await prisma.cooldown.findMany(); - const overDue = (await addSeconds(cooldown, createdAt)) < new Date(); + for await (const timeout of getCooldown) { + const { guildId, userId, timeoutId, cooldown, createdAt } = timeout; - if (overDue) { - timeoutSchema - .deleteOne({ + const overDue = (await addSeconds(cooldown, createdAt)) < new Date(); + + if (overDue) { + logger.info(timeout); + const deleteCooldown = await prisma.cooldown.delete({ + where: { + guildId_userId_timeoutId: { guildId, userId, timeoutId, - cooldown, - }) - .then(() => { - logger.debug( - `Timeout document ${timeoutId} has been deleted from user ${userId}.` - ); - }); - } - }) - ); + }, + }, + }); + + logger.silly(deleteCooldown); + + logger.debug( + `Timeout document ${timeoutId} has been deleted from user ${userId}.` + ); + } + } }; From 61ab2cba9989c6ebd48c552979292b06c42889da Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 17:43:09 +0200 Subject: [PATCH 195/215] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20cle?= =?UTF-8?q?anup=20of=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 2 +- .eslintignore | 2 -- .eslintrc.json | 15 --------------- .gitignore | 3 --- SECURITY.md | 14 -------------- prisma/.gitignore | 2 ++ 6 files changed, 3 insertions(+), 35 deletions(-) delete mode 100644 .eslintignore delete mode 100644 .eslintrc.json delete mode 100644 SECURITY.md create mode 100644 prisma/.gitignore diff --git a/.env.example b/.env.example index 3fd7d4f..a0b0942 100644 --- a/.env.example +++ b/.env.example @@ -6,7 +6,7 @@ DISCORD_CLIENT_ID="" DISCORD_GUILD_ID="" # Database -MONGO_URL="mongodb+srv://username:password@host/database?retryWrites=true&w=majority" +DATABASE_URL="file:./production.db" # Encryption ENCRYPTION_ALGORITHM="aes-256-ctr" diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 76add87..0000000 --- a/.eslintignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules -dist \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index 39d4adc..0000000 --- a/.eslintrc.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "root": true, - "parser": "@typescript-eslint/parser", - "plugins": ["@typescript-eslint", "no-loops", "prettier"], - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/eslint-recommended", - "plugin:@typescript-eslint/recommended", - "prettier" - ], - "rules": { - "no-console": 1, - "no-loops/no-loops": 2 - } -} diff --git a/.gitignore b/.gitignore index fe6928b..1ab52e9 100644 --- a/.gitignore +++ b/.gitignore @@ -145,6 +145,3 @@ dist # Docker database docker-compose.local.yml - -# Prisma -prisma/*.db* \ No newline at end of file diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 4933326..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,14 +0,0 @@ -# Security Policy - -## Supported Versions - -| Version | Supported | -| ---------- | ------------------ | -| 2022.4.x | :white_check_mark: | -| < 2022.4.x | :x: | - -## Reporting a Vulnerability - -Report a security issue to Vermium#9649 on discord or vermium@zyner.org - -I will try to fix the vulnerability within a month, often in some days only. If vulnerability is declined then still don't abuse it in any way you can. diff --git a/prisma/.gitignore b/prisma/.gitignore new file mode 100644 index 0000000..03f6f26 --- /dev/null +++ b/prisma/.gitignore @@ -0,0 +1,2 @@ +*.db +*.db-journal \ No newline at end of file From cd3f0fcec777b332b8055ed444f7148c70f8f120 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 18:07:54 +0200 Subject: [PATCH 196/215] =?UTF-8?q?=F0=9F=99=88=20Fixed=20missing=20commit?= =?UTF-8?q?=20of=20database=20handler?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 5 ----- src/handlers/database/index.ts | 3 +++ 2 files changed, 3 insertions(+), 5 deletions(-) create mode 100644 src/handlers/database/index.ts diff --git a/.gitignore b/.gitignore index 1ab52e9..9fe2862 100644 --- a/.gitignore +++ b/.gitignore @@ -140,8 +140,3 @@ dist .yarn/build-state.yml .yarn/install-state.gz .pnp.* - - -# Docker -database -docker-compose.local.yml diff --git a/src/handlers/database/index.ts b/src/handlers/database/index.ts new file mode 100644 index 0000000..287669a --- /dev/null +++ b/src/handlers/database/index.ts @@ -0,0 +1,3 @@ +import { PrismaClient } from '@prisma/client' + +export default new PrismaClient() \ No newline at end of file From dc500eb666f4ffabd8bdf83de9237fcafee56ad7 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 18:41:01 +0200 Subject: [PATCH 197/215] =?UTF-8?q?=F0=9F=9A=80=20re-enabled=20audits=20fo?= =?UTF-8?q?r=20interactionCreate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/events/interactionCreate/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/events/interactionCreate/index.ts b/src/events/interactionCreate/index.ts index 21fa2ff..dde7ab2 100644 --- a/src/events/interactionCreate/index.ts +++ b/src/events/interactionCreate/index.ts @@ -7,6 +7,7 @@ import { import { IEventOptions } from "../../interfaces/EventOptions"; import logger from "../../middlewares/logger"; // Dependencies +import audits from "./audits"; import { handleCommandInteraction as HandlersHandleCommandInteraction } from "./handlers"; export const options: IEventOptions = { @@ -21,7 +22,7 @@ export const execute = async (interaction: BaseInteraction) => { `New interaction: ${id} in guild: ${guild?.name} (${guild?.id})` ); - // await audits.execute(interaction); + await audits.execute(interaction); switch (interaction.type) { case InteractionType.ApplicationCommand: From 23e4834836516a47e439c9712583efa44084859f Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 19:30:25 +0200 Subject: [PATCH 198/215] =?UTF-8?q?=F0=9F=A5=85=20Do=20not=20catch=200?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migration.sql | 130 ++++++++++++++++++ .../migration.sql | 130 ++++++++++++++++++ src/commands/config/modules/credits/index.ts | 63 +++++---- 3 files changed, 298 insertions(+), 25 deletions(-) create mode 100644 prisma/migrations/20221021172156_int_to_bigint/migration.sql create mode 100644 prisma/migrations/20221021172345_bigint_to_int/migration.sql diff --git a/prisma/migrations/20221021172156_int_to_bigint/migration.sql b/prisma/migrations/20221021172156_int_to_bigint/migration.sql new file mode 100644 index 0000000..187923d --- /dev/null +++ b/prisma/migrations/20221021172156_int_to_bigint/migration.sql @@ -0,0 +1,130 @@ +/* + Warnings: + + - You are about to alter the column `count` on the `GuildCounter` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `creditsEarned` on the `GuildMember` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `pointsEarned` on the `GuildMember` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `pricePerHour` on the `GuildShopRoles` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `cooldown` on the `Cooldown` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `creditsMinimumLength` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `creditsRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `creditsTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `creditsWorkRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `creditsWorkTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `pointsMinimumLength` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `pointsRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `pointsTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `shopRolesPricePerHour` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `reputationsEarned` on the `User` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + +*/ +-- RedefineTables +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_GuildCounter" ( + "guildId" TEXT NOT NULL, + "channelId" TEXT NOT NULL, + "triggerWord" TEXT NOT NULL, + "count" BIGINT NOT NULL DEFAULT 0, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + CONSTRAINT "GuildCounter_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE +); +INSERT INTO "new_GuildCounter" ("channelId", "count", "createdAt", "guildId", "triggerWord", "updatedAt") SELECT "channelId", "count", "createdAt", "guildId", "triggerWord", "updatedAt" FROM "GuildCounter"; +DROP TABLE "GuildCounter"; +ALTER TABLE "new_GuildCounter" RENAME TO "GuildCounter"; +CREATE UNIQUE INDEX "GuildCounter_guildId_channelId_key" ON "GuildCounter"("guildId", "channelId"); +CREATE TABLE "new_GuildMember" ( + "userId" TEXT NOT NULL, + "guildId" TEXT NOT NULL, + "creditsEarned" BIGINT NOT NULL DEFAULT 0, + "pointsEarned" BIGINT NOT NULL DEFAULT 0, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + CONSTRAINT "GuildMember_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, + CONSTRAINT "GuildMember_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE +); +INSERT INTO "new_GuildMember" ("createdAt", "creditsEarned", "guildId", "pointsEarned", "updatedAt", "userId") SELECT "createdAt", "creditsEarned", "guildId", "pointsEarned", "updatedAt", "userId" FROM "GuildMember"; +DROP TABLE "GuildMember"; +ALTER TABLE "new_GuildMember" RENAME TO "GuildMember"; +CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember"("userId", "guildId"); +CREATE TABLE "new_GuildShopRoles" ( + "guildId" TEXT NOT NULL, + "roleId" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "pricePerHour" BIGINT NOT NULL DEFAULT 5, + "lastPayed" DATETIME NOT NULL, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + CONSTRAINT "GuildShopRoles_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, + CONSTRAINT "GuildShopRoles_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, + CONSTRAINT "GuildShopRoles_userId_guildId_fkey" FOREIGN KEY ("userId", "guildId") REFERENCES "GuildMember" ("userId", "guildId") ON DELETE RESTRICT ON UPDATE CASCADE +); +INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") SELECT "createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId" FROM "GuildShopRoles"; +DROP TABLE "GuildShopRoles"; +ALTER TABLE "new_GuildShopRoles" RENAME TO "GuildShopRoles"; +CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles"("guildId", "userId", "roleId"); +CREATE TABLE "new_Cooldown" ( + "guildId" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "cooldown" BIGINT NOT NULL, + "timeoutId" TEXT NOT NULL, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + CONSTRAINT "Cooldown_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, + CONSTRAINT "Cooldown_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE +); +INSERT INTO "new_Cooldown" ("cooldown", "createdAt", "guildId", "timeoutId", "updatedAt", "userId") SELECT "cooldown", "createdAt", "guildId", "timeoutId", "updatedAt", "userId" FROM "Cooldown"; +DROP TABLE "Cooldown"; +ALTER TABLE "new_Cooldown" RENAME TO "Cooldown"; +CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown"("guildId", "userId", "timeoutId"); +CREATE TABLE "new_Guild" ( + "id" TEXT NOT NULL, + "embedColorSuccess" TEXT NOT NULL DEFAULT '#22bb33', + "embedColorWait" TEXT NOT NULL DEFAULT '#f0ad4e', + "embedColorError" TEXT NOT NULL DEFAULT '#bb2124', + "embedFooterText" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg/xyter', + "embedFooterIcon" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg.png', + "creditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "creditsRate" BIGINT NOT NULL DEFAULT 1, + "creditsTimeout" BIGINT NOT NULL DEFAULT 5, + "creditsWorkRate" BIGINT NOT NULL DEFAULT 25, + "creditsWorkTimeout" BIGINT NOT NULL DEFAULT 86400, + "creditsMinimumLength" BIGINT NOT NULL DEFAULT 5, + "pointsEnabled" BOOLEAN NOT NULL DEFAULT false, + "pointsRate" BIGINT NOT NULL DEFAULT 1, + "pointsTimeout" BIGINT NOT NULL DEFAULT 5, + "pointsMinimumLength" BIGINT NOT NULL DEFAULT 5, + "reputationsEnabled" BOOLEAN NOT NULL DEFAULT false, + "countersEnabled" BOOLEAN NOT NULL DEFAULT false, + "apiCpggUrlIv" TEXT, + "apiCpggUrlContent" TEXT, + "apiCpggTokenIv" TEXT, + "apiCpggTokenContent" TEXT, + "auditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "auditsChannelId" TEXT, + "shopRolesEnabled" BOOLEAN NOT NULL DEFAULT false, + "shopRolesPricePerHour" BIGINT NOT NULL DEFAULT 5, + "welcomeEnabled" BOOLEAN NOT NULL DEFAULT false, + "welcomeJoinChannelId" TEXT, + "welcomeJoinChannelMessage" TEXT, + "welcomeLeaveChannelId" TEXT, + "welcomeLeaveChannelMessage" TEXT, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL +); +INSERT INTO "new_Guild" ("apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt", "welcomeEnabled", "welcomeJoinChannelId", "welcomeJoinChannelMessage", "welcomeLeaveChannelId", "welcomeLeaveChannelMessage") SELECT "apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt", "welcomeEnabled", "welcomeJoinChannelId", "welcomeJoinChannelMessage", "welcomeLeaveChannelId", "welcomeLeaveChannelMessage" FROM "Guild"; +DROP TABLE "Guild"; +ALTER TABLE "new_Guild" RENAME TO "Guild"; +CREATE UNIQUE INDEX "Guild_id_key" ON "Guild"("id"); +CREATE TABLE "new_User" ( + "id" TEXT NOT NULL, + "reputationsEarned" BIGINT NOT NULL DEFAULT 0, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL +); +INSERT INTO "new_User" ("createdAt", "id", "reputationsEarned", "updatedAt") SELECT "createdAt", "id", "reputationsEarned", "updatedAt" FROM "User"; +DROP TABLE "User"; +ALTER TABLE "new_User" RENAME TO "User"; +CREATE UNIQUE INDEX "User_id_key" ON "User"("id"); +PRAGMA foreign_key_check; +PRAGMA foreign_keys=ON; diff --git a/prisma/migrations/20221021172345_bigint_to_int/migration.sql b/prisma/migrations/20221021172345_bigint_to_int/migration.sql new file mode 100644 index 0000000..978ac5c --- /dev/null +++ b/prisma/migrations/20221021172345_bigint_to_int/migration.sql @@ -0,0 +1,130 @@ +/* + Warnings: + + - You are about to alter the column `reputationsEarned` on the `User` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `count` on the `GuildCounter` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `creditsEarned` on the `GuildMember` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `pointsEarned` on the `GuildMember` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `pricePerHour` on the `GuildShopRoles` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `creditsMinimumLength` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `creditsRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `creditsTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `creditsWorkRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `creditsWorkTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `pointsMinimumLength` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `pointsRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `pointsTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `shopRolesPricePerHour` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `cooldown` on the `Cooldown` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + +*/ +-- RedefineTables +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_User" ( + "id" TEXT NOT NULL, + "reputationsEarned" INTEGER NOT NULL DEFAULT 0, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL +); +INSERT INTO "new_User" ("createdAt", "id", "reputationsEarned", "updatedAt") SELECT "createdAt", "id", "reputationsEarned", "updatedAt" FROM "User"; +DROP TABLE "User"; +ALTER TABLE "new_User" RENAME TO "User"; +CREATE UNIQUE INDEX "User_id_key" ON "User"("id"); +CREATE TABLE "new_GuildCounter" ( + "guildId" TEXT NOT NULL, + "channelId" TEXT NOT NULL, + "triggerWord" TEXT NOT NULL, + "count" INTEGER NOT NULL DEFAULT 0, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + CONSTRAINT "GuildCounter_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE +); +INSERT INTO "new_GuildCounter" ("channelId", "count", "createdAt", "guildId", "triggerWord", "updatedAt") SELECT "channelId", "count", "createdAt", "guildId", "triggerWord", "updatedAt" FROM "GuildCounter"; +DROP TABLE "GuildCounter"; +ALTER TABLE "new_GuildCounter" RENAME TO "GuildCounter"; +CREATE UNIQUE INDEX "GuildCounter_guildId_channelId_key" ON "GuildCounter"("guildId", "channelId"); +CREATE TABLE "new_GuildMember" ( + "userId" TEXT NOT NULL, + "guildId" TEXT NOT NULL, + "creditsEarned" INTEGER NOT NULL DEFAULT 0, + "pointsEarned" INTEGER NOT NULL DEFAULT 0, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + CONSTRAINT "GuildMember_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, + CONSTRAINT "GuildMember_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE +); +INSERT INTO "new_GuildMember" ("createdAt", "creditsEarned", "guildId", "pointsEarned", "updatedAt", "userId") SELECT "createdAt", "creditsEarned", "guildId", "pointsEarned", "updatedAt", "userId" FROM "GuildMember"; +DROP TABLE "GuildMember"; +ALTER TABLE "new_GuildMember" RENAME TO "GuildMember"; +CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember"("userId", "guildId"); +CREATE TABLE "new_GuildShopRoles" ( + "guildId" TEXT NOT NULL, + "roleId" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "pricePerHour" INTEGER NOT NULL DEFAULT 5, + "lastPayed" DATETIME NOT NULL, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + CONSTRAINT "GuildShopRoles_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, + CONSTRAINT "GuildShopRoles_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, + CONSTRAINT "GuildShopRoles_userId_guildId_fkey" FOREIGN KEY ("userId", "guildId") REFERENCES "GuildMember" ("userId", "guildId") ON DELETE RESTRICT ON UPDATE CASCADE +); +INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") SELECT "createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId" FROM "GuildShopRoles"; +DROP TABLE "GuildShopRoles"; +ALTER TABLE "new_GuildShopRoles" RENAME TO "GuildShopRoles"; +CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles"("guildId", "userId", "roleId"); +CREATE TABLE "new_Guild" ( + "id" TEXT NOT NULL, + "embedColorSuccess" TEXT NOT NULL DEFAULT '#22bb33', + "embedColorWait" TEXT NOT NULL DEFAULT '#f0ad4e', + "embedColorError" TEXT NOT NULL DEFAULT '#bb2124', + "embedFooterText" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg/xyter', + "embedFooterIcon" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg.png', + "creditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "creditsRate" INTEGER NOT NULL DEFAULT 1, + "creditsTimeout" INTEGER NOT NULL DEFAULT 5, + "creditsWorkRate" INTEGER NOT NULL DEFAULT 25, + "creditsWorkTimeout" INTEGER NOT NULL DEFAULT 86400, + "creditsMinimumLength" INTEGER NOT NULL DEFAULT 5, + "pointsEnabled" BOOLEAN NOT NULL DEFAULT false, + "pointsRate" INTEGER NOT NULL DEFAULT 1, + "pointsTimeout" INTEGER NOT NULL DEFAULT 5, + "pointsMinimumLength" INTEGER NOT NULL DEFAULT 5, + "reputationsEnabled" BOOLEAN NOT NULL DEFAULT false, + "countersEnabled" BOOLEAN NOT NULL DEFAULT false, + "apiCpggUrlIv" TEXT, + "apiCpggUrlContent" TEXT, + "apiCpggTokenIv" TEXT, + "apiCpggTokenContent" TEXT, + "auditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "auditsChannelId" TEXT, + "shopRolesEnabled" BOOLEAN NOT NULL DEFAULT false, + "shopRolesPricePerHour" INTEGER NOT NULL DEFAULT 5, + "welcomeEnabled" BOOLEAN NOT NULL DEFAULT false, + "welcomeJoinChannelId" TEXT, + "welcomeJoinChannelMessage" TEXT, + "welcomeLeaveChannelId" TEXT, + "welcomeLeaveChannelMessage" TEXT, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL +); +INSERT INTO "new_Guild" ("apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt", "welcomeEnabled", "welcomeJoinChannelId", "welcomeJoinChannelMessage", "welcomeLeaveChannelId", "welcomeLeaveChannelMessage") SELECT "apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt", "welcomeEnabled", "welcomeJoinChannelId", "welcomeJoinChannelMessage", "welcomeLeaveChannelId", "welcomeLeaveChannelMessage" FROM "Guild"; +DROP TABLE "Guild"; +ALTER TABLE "new_Guild" RENAME TO "Guild"; +CREATE UNIQUE INDEX "Guild_id_key" ON "Guild"("id"); +CREATE TABLE "new_Cooldown" ( + "guildId" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "cooldown" INTEGER NOT NULL, + "timeoutId" TEXT NOT NULL, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + CONSTRAINT "Cooldown_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, + CONSTRAINT "Cooldown_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE +); +INSERT INTO "new_Cooldown" ("cooldown", "createdAt", "guildId", "timeoutId", "updatedAt", "userId") SELECT "cooldown", "createdAt", "guildId", "timeoutId", "updatedAt", "userId" FROM "Cooldown"; +DROP TABLE "Cooldown"; +ALTER TABLE "new_Cooldown" RENAME TO "Cooldown"; +CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown"("guildId", "userId", "timeoutId"); +PRAGMA foreign_key_check; +PRAGMA foreign_keys=ON; diff --git a/src/commands/config/modules/credits/index.ts b/src/commands/config/modules/credits/index.ts index e76cd77..7608bc9 100644 --- a/src/commands/config/modules/credits/index.ts +++ b/src/commands/config/modules/credits/index.ts @@ -14,41 +14,49 @@ export default { builder: (command: SlashCommandSubcommandBuilder) => { return command .setName("credits") - .setDescription(`Credits`) + .setDescription(`Configure this guild's credits module.`) .addBooleanOption((option) => option - .setName("status") - .setDescription("Should credits be enabled?") + .setName("enabled") + .setDescription("Do you want to activate the credit module?") .setRequired(true) ) .addNumberOption((option) => option .setName("rate") - .setDescription("Amount of credits per message.") + .setDescription("Credit rate per message.") .setRequired(true) + .setMinValue(1) ) .addNumberOption((option) => option .setName("minimum-length") - .setDescription("Minimum length of message to earn credits.") + .setDescription("Minimum message length to receive credit.") .setRequired(true) ) .addNumberOption((option) => option .setName("work-rate") - .setDescription("Maximum amount of credits on work.") + .setDescription( + "The maximum amount of credit that can be obtained within a working day." + ) .setRequired(true) + .setMinValue(1) ) .addNumberOption((option) => option .setName("work-timeout") - .setDescription("Timeout between work schedules (seconds).") + .setDescription( + "How long you need to wait before you can work again provided in seconds." + ) .setRequired(true) ) .addNumberOption((option) => option .setName("timeout") - .setDescription("Timeout between earning credits (seconds).") + .setDescription( + "How long you need to wait before you can earn more credits." + ) .setRequired(true) ); }, @@ -62,27 +70,32 @@ export default { ); const { guild, options } = interaction; - const status = options?.getBoolean("status"); - const rate = options?.getNumber("rate"); - const timeout = options?.getNumber("timeout"); - const minimumLength = options?.getNumber("minimum-length"); - const workRate = options?.getNumber("work-rate"); - const workTimeout = options?.getNumber("work-timeout"); + const enabled = options.getBoolean("enabled"); + const rate = options.getNumber("rate"); + const timeout = options.getNumber("timeout"); + const minimumLength = options.getNumber("minimum-length"); + const workRate = options.getNumber("work-rate"); + const workTimeout = options.getNumber("work-timeout"); - if (!guild) throw new Error("Guild is not found"); - if (status === null) throw new Error("Status is null"); - if (!rate) throw new Error("Rate is null"); - if (!workRate) throw new Error("WorkRate is null"); - if (!workTimeout) throw new Error("WorkTimeout is null"); - if (!timeout) throw new Error("Timeout is null"); - if (!minimumLength) throw new Error("Minimum Length is null"); + if (!guild) throw new Error("Guild not found."); + if (typeof enabled !== "boolean") + throw new Error("Enabled option is not a boolean."); + if (typeof rate !== "number") throw new Error("Rate is not a number."); + if (typeof workRate !== "number") + throw new Error("Work rate is not a number."); + if (typeof workTimeout !== "number") + throw new Error("Work timeout is not a number."); + if (typeof timeout !== "number") + throw new Error("Timeout is not a number."); + if (typeof minimumLength !== "number") + throw new Error("Minimum length is not a number."); const createGuild = await prisma.guild.upsert({ where: { id: guild.id, }, update: { - creditsEnabled: status, + creditsEnabled: enabled, creditsRate: rate, creditsTimeout: timeout, creditsWorkRate: workRate, @@ -91,7 +104,7 @@ export default { }, create: { id: guild.id, - creditsEnabled: status, + creditsEnabled: enabled, creditsRate: rate, creditsTimeout: timeout, creditsWorkRate: workRate, @@ -108,7 +121,7 @@ export default { .setColor(successColor) .addFields( { - name: "🤖 Status", + name: "🤖 Enabled?", value: `${createGuild.creditsEnabled}`, inline: true, }, @@ -144,7 +157,7 @@ export default { text: footerText, }); - await interaction?.editReply({ + await interaction.editReply({ embeds: [interactionEmbed], }); return; From dab00617a28bde6077825344399993a2e7f1fb96 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 19:45:56 +0200 Subject: [PATCH 199/215] =?UTF-8?q?=E2=9A=B0=EF=B8=8F=20remove=20moduleDat?= =?UTF-8?q?a=20and=20metadata=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/helpers/getCommandMetadata/index.ts | 14 -------------- src/interfaces/Command.ts | 1 - 2 files changed, 15 deletions(-) delete mode 100644 src/helpers/getCommandMetadata/index.ts diff --git a/src/helpers/getCommandMetadata/index.ts b/src/helpers/getCommandMetadata/index.ts deleted file mode 100644 index 6a6a8b7..0000000 --- a/src/helpers/getCommandMetadata/index.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { ChatInputCommandInteraction } from "discord.js"; -import { ICommand } from "../../interfaces/Command"; - -export default async ( - interaction: ChatInputCommandInteraction, - currentCommand: ICommand -) => { - const subcommand = interaction.options.getSubcommand(); - const subcommandGroup = interaction.options.getSubcommandGroup(false); - - return subcommandGroup - ? currentCommand.moduleData[subcommandGroup].moduleData[subcommand].metadata - : currentCommand.moduleData[subcommand].metadata; -}; diff --git a/src/interfaces/Command.ts b/src/interfaces/Command.ts index f8a895a..5d6f870 100644 --- a/src/interfaces/Command.ts +++ b/src/interfaces/Command.ts @@ -2,6 +2,5 @@ import { SlashCommandBuilder } from "@discordjs/builders"; export interface ICommand { builder: SlashCommandBuilder; - moduleData: any; execute: Promise; } From 89b67906ec91c58dd17fe406947c68b3a035777a Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 19:50:24 +0200 Subject: [PATCH 200/215] =?UTF-8?q?=E2=9A=B0=EF=B8=8F=20JS-0356=20fixed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manage/modules/credits/modules/transfer/index.ts | 5 +++-- src/commands/reputation/modules/view/index.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/commands/manage/modules/credits/modules/transfer/index.ts b/src/commands/manage/modules/credits/modules/transfer/index.ts index 488ae70..c75da60 100644 --- a/src/commands/manage/modules/credits/modules/transfer/index.ts +++ b/src/commands/manage/modules/credits/modules/transfer/index.ts @@ -42,8 +42,9 @@ export default { await checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); - const { errorColor, successColor, footerText, footerIcon } = - await getEmbedConfig(interaction.guild); // Destructure member + const { successColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); // Destructure member const { guild, options } = interaction; // Get options diff --git a/src/commands/reputation/modules/view/index.ts b/src/commands/reputation/modules/view/index.ts index 0722cf3..23598a0 100644 --- a/src/commands/reputation/modules/view/index.ts +++ b/src/commands/reputation/modules/view/index.ts @@ -20,7 +20,7 @@ export default { execute: async (interaction: ChatInputCommandInteraction) => { await deferReply(interaction, true); - const { options, user, guild } = interaction; + const { options, guild } = interaction; const { successColor, footerText, footerIcon } = await getEmbedConfig( guild From 3e5cbeb2378709e8a11d416f2b9bc76c288c210b Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 19:53:47 +0200 Subject: [PATCH 201/215] =?UTF-8?q?=F0=9F=9A=A8=20Fixed=20some=20JS-0116?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/config/modules/audits/index.ts | 2 +- src/commands/config/modules/cpgg/index.ts | 2 +- src/commands/config/modules/credits/index.ts | 2 +- src/commands/config/modules/embeds/index.ts | 2 +- src/commands/config/modules/points/index.ts | 2 +- src/commands/config/modules/shop/index.ts | 2 +- src/commands/config/modules/welcome/index.ts | 2 +- src/commands/manage/modules/counters/modules/add/index.ts | 2 +- src/commands/manage/modules/counters/modules/remove/index.ts | 2 +- src/commands/manage/modules/credits/modules/give/index.ts | 2 +- .../manage/modules/credits/modules/giveaway/index.ts | 2 +- src/commands/manage/modules/credits/modules/set/index.ts | 2 +- src/commands/manage/modules/credits/modules/take/index.ts | 2 +- .../manage/modules/credits/modules/transfer/index.ts | 2 +- src/commands/moderation/modules/prune/index.ts | 5 +---- src/helpers/checkPermission/index.ts | 2 +- src/schedules/shop/modules/roles/components/dueForPayment.ts | 2 +- src/schedules/shop/modules/roles/index.ts | 2 +- 18 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/commands/config/modules/audits/index.ts b/src/commands/config/modules/audits/index.ts index a3d4c00..bc91291 100644 --- a/src/commands/config/modules/audits/index.ts +++ b/src/commands/config/modules/audits/index.ts @@ -33,7 +33,7 @@ export default { execute: async (interaction: ChatInputCommandInteraction) => { await deferReply(interaction, true); - await checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); + checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); const { guild, options } = interaction; const { successColor, footerText, footerIcon } = await getEmbedConfig( diff --git a/src/commands/config/modules/cpgg/index.ts b/src/commands/config/modules/cpgg/index.ts index b9ce119..56daed8 100644 --- a/src/commands/config/modules/cpgg/index.ts +++ b/src/commands/config/modules/cpgg/index.ts @@ -42,7 +42,7 @@ export default { execute: async (interaction: ChatInputCommandInteraction) => { await deferReply(interaction, true); - await checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); + checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild diff --git a/src/commands/config/modules/credits/index.ts b/src/commands/config/modules/credits/index.ts index 7608bc9..70525f2 100644 --- a/src/commands/config/modules/credits/index.ts +++ b/src/commands/config/modules/credits/index.ts @@ -63,7 +63,7 @@ export default { execute: async (interaction: ChatInputCommandInteraction) => { await deferReply(interaction, true); - await checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); + checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild diff --git a/src/commands/config/modules/embeds/index.ts b/src/commands/config/modules/embeds/index.ts index a9e1ae9..a4c8195 100644 --- a/src/commands/config/modules/embeds/index.ts +++ b/src/commands/config/modules/embeds/index.ts @@ -48,7 +48,7 @@ export default { execute: async (interaction: ChatInputCommandInteraction) => { await deferReply(interaction, true); - await checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); + checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); const { guild } = interaction; if (!guild) throw new Error("Guild not found"); diff --git a/src/commands/config/modules/points/index.ts b/src/commands/config/modules/points/index.ts index 7f89c8a..8761bbe 100644 --- a/src/commands/config/modules/points/index.ts +++ b/src/commands/config/modules/points/index.ts @@ -43,7 +43,7 @@ export default { execute: async (interaction: ChatInputCommandInteraction) => { await deferReply(interaction, true); - await checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); + checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild diff --git a/src/commands/config/modules/shop/index.ts b/src/commands/config/modules/shop/index.ts index fd23ac1..577867b 100644 --- a/src/commands/config/modules/shop/index.ts +++ b/src/commands/config/modules/shop/index.ts @@ -31,7 +31,7 @@ export default { execute: async (interaction: ChatInputCommandInteraction) => { await deferReply(interaction, true); - await checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); + checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild diff --git a/src/commands/config/modules/welcome/index.ts b/src/commands/config/modules/welcome/index.ts index 259a63f..0ac56e1 100644 --- a/src/commands/config/modules/welcome/index.ts +++ b/src/commands/config/modules/welcome/index.ts @@ -54,7 +54,7 @@ export default { execute: async (interaction: ChatInputCommandInteraction) => { await deferReply(interaction, true); - await checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); + checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild diff --git a/src/commands/manage/modules/counters/modules/add/index.ts b/src/commands/manage/modules/counters/modules/add/index.ts index 13399bc..9c3dafe 100644 --- a/src/commands/manage/modules/counters/modules/add/index.ts +++ b/src/commands/manage/modules/counters/modules/add/index.ts @@ -41,7 +41,7 @@ export default { execute: async (interaction: ChatInputCommandInteraction) => { await deferReply(interaction, true); - await checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); + checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild diff --git a/src/commands/manage/modules/counters/modules/remove/index.ts b/src/commands/manage/modules/counters/modules/remove/index.ts index dff0ec8..742ec9a 100644 --- a/src/commands/manage/modules/counters/modules/remove/index.ts +++ b/src/commands/manage/modules/counters/modules/remove/index.ts @@ -30,7 +30,7 @@ export default { execute: async (interaction: ChatInputCommandInteraction) => { await deferReply(interaction, true); - await checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); + checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild diff --git a/src/commands/manage/modules/credits/modules/give/index.ts b/src/commands/manage/modules/credits/modules/give/index.ts index 28d7eeb..f2c070b 100644 --- a/src/commands/manage/modules/credits/modules/give/index.ts +++ b/src/commands/manage/modules/credits/modules/give/index.ts @@ -37,7 +37,7 @@ export default { execute: async (interaction: ChatInputCommandInteraction) => { await deferReply(interaction, true); - await checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); + checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild diff --git a/src/commands/manage/modules/credits/modules/giveaway/index.ts b/src/commands/manage/modules/credits/modules/giveaway/index.ts index 3c2ea05..9a0518c 100644 --- a/src/commands/manage/modules/credits/modules/giveaway/index.ts +++ b/src/commands/manage/modules/credits/modules/giveaway/index.ts @@ -47,7 +47,7 @@ export default { execute: async (interaction: ChatInputCommandInteraction) => { await deferReply(interaction, true); - await checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); + checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild diff --git a/src/commands/manage/modules/credits/modules/set/index.ts b/src/commands/manage/modules/credits/modules/set/index.ts index e8fe3cc..10dd37f 100644 --- a/src/commands/manage/modules/credits/modules/set/index.ts +++ b/src/commands/manage/modules/credits/modules/set/index.ts @@ -37,7 +37,7 @@ export default { execute: async (interaction: ChatInputCommandInteraction) => { await deferReply(interaction, true); - await checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); + checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); const { errorColor, successColor, footerText, footerIcon } = await getEmbedConfig(interaction.guild); diff --git a/src/commands/manage/modules/credits/modules/take/index.ts b/src/commands/manage/modules/credits/modules/take/index.ts index 8f55ad3..9e808af 100644 --- a/src/commands/manage/modules/credits/modules/take/index.ts +++ b/src/commands/manage/modules/credits/modules/take/index.ts @@ -38,7 +38,7 @@ export default { execute: async (interaction: ChatInputCommandInteraction) => { await deferReply(interaction, true); - await checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); + checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); const { errorColor, successColor, footerText, footerIcon } = await getEmbedConfig(interaction.guild); // Destructure diff --git a/src/commands/manage/modules/credits/modules/transfer/index.ts b/src/commands/manage/modules/credits/modules/transfer/index.ts index c75da60..6224ec4 100644 --- a/src/commands/manage/modules/credits/modules/transfer/index.ts +++ b/src/commands/manage/modules/credits/modules/transfer/index.ts @@ -40,7 +40,7 @@ export default { execute: async (interaction: ChatInputCommandInteraction) => { await deferReply(interaction, true); - await checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); + checkPermission(interaction, PermissionsBitField.Flags.ManageGuild); const { successColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild diff --git a/src/commands/moderation/modules/prune/index.ts b/src/commands/moderation/modules/prune/index.ts index 0245a33..3641d98 100644 --- a/src/commands/moderation/modules/prune/index.ts +++ b/src/commands/moderation/modules/prune/index.ts @@ -30,10 +30,7 @@ export default { execute: async (interaction: ChatInputCommandInteraction) => { await deferReply(interaction, false); - await checkPermission( - interaction, - PermissionsBitField.Flags.ManageMessages - ); + checkPermission(interaction, PermissionsBitField.Flags.ManageMessages); const { errorColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild diff --git a/src/helpers/checkPermission/index.ts b/src/helpers/checkPermission/index.ts index 2de1162..a14c82d 100644 --- a/src/helpers/checkPermission/index.ts +++ b/src/helpers/checkPermission/index.ts @@ -1,6 +1,6 @@ import { BaseInteraction, PermissionResolvable } from "discord.js"; -export default async ( +export default ( interaction: BaseInteraction, permission: PermissionResolvable ) => { diff --git a/src/schedules/shop/modules/roles/components/dueForPayment.ts b/src/schedules/shop/modules/roles/components/dueForPayment.ts index f87c94c..ee2eb3f 100644 --- a/src/schedules/shop/modules/roles/components/dueForPayment.ts +++ b/src/schedules/shop/modules/roles/components/dueForPayment.ts @@ -3,7 +3,7 @@ import logger from "../../../../../middlewares/logger"; import { GuildShopRoles } from "@prisma/client"; -export const execute = async (_client: Client, role: GuildShopRoles) => { +export const execute = (_client: Client, role: GuildShopRoles) => { const { roleId } = role; logger.silly(`Shop role ${roleId} is not due for payment.`); diff --git a/src/schedules/shop/modules/roles/index.ts b/src/schedules/shop/modules/roles/index.ts index 6dea00e..6b863d0 100644 --- a/src/schedules/shop/modules/roles/index.ts +++ b/src/schedules/shop/modules/roles/index.ts @@ -15,7 +15,7 @@ export const execute = async (client: Client) => { const now = new Date(); if (nextPayment > now) { - await dueForPayment.execute(client, role); + dueForPayment.execute(client, role); return; } From a510ca7513551403fbe68bc4c22680ce113aa50e Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 19:56:23 +0200 Subject: [PATCH 202/215] =?UTF-8?q?=F0=9F=9A=A8=20Fixed=20some=20JS-C1003?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/credits/modules/work/index.ts | 4 ++-- src/schedules/shop/modules/roles/index.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/commands/credits/modules/work/index.ts b/src/commands/credits/modules/work/index.ts index 939ee06..a69d155 100644 --- a/src/commands/credits/modules/work/index.ts +++ b/src/commands/credits/modules/work/index.ts @@ -3,7 +3,7 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import Chance from "chance"; import { CommandInteraction, EmbedBuilder } from "discord.js"; // Models -import * as cooldown from "../../../../handlers/cooldown"; +import { command as CooldownCommand } from "../../../../handlers/cooldown"; // Configurations import getEmbedConfig from "../../../../helpers/getEmbedData"; // Helpers @@ -51,7 +51,7 @@ export default { logger.silly(createGuild); - await cooldown.command(interaction, createGuild.creditsWorkTimeout); + await CooldownCommand(interaction, createGuild.creditsWorkTimeout); const creditsEarned = chance.integer({ min: 0, diff --git a/src/schedules/shop/modules/roles/index.ts b/src/schedules/shop/modules/roles/index.ts index 6b863d0..d3c7973 100644 --- a/src/schedules/shop/modules/roles/index.ts +++ b/src/schedules/shop/modules/roles/index.ts @@ -2,8 +2,8 @@ import { Client } from "discord.js"; import prisma from "../../../../handlers/database"; -import * as dueForPayment from "./components/dueForPayment"; -import * as overDueForPayment from "./components/overDueForPayment"; +import { execute as dueForPaymentExecute } from "./components/dueForPayment"; +import { execute as overDueForPaymentExecute } from "./components/overDueForPayment"; export const execute = async (client: Client) => { const roles = await prisma.guildShopRoles.findMany(); @@ -15,13 +15,13 @@ export const execute = async (client: Client) => { const now = new Date(); if (nextPayment > now) { - dueForPayment.execute(client, role); + dueForPaymentExecute(client, role); return; } if (nextPayment < now) { - await overDueForPayment.execute(client, role); + await overDueForPaymentExecute(client, role); } } }; From 3deec31b86263ea082a0c5e492712cc700f3c53a Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 20:00:25 +0200 Subject: [PATCH 203/215] =?UTF-8?q?=F0=9F=9A=A8=20Fixed=20some=20JS-D1001?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/config/index.ts | 1 + src/commands/counters/index.ts | 1 + src/commands/credits/index.ts | 1 + src/commands/fun/index.ts | 1 + src/commands/reputation/index.ts | 1 + src/schedules/shop/modules/roles/components/dueForPayment.ts | 1 + src/schedules/shop/modules/roles/index.ts | 1 + 7 files changed, 7 insertions(+) diff --git a/src/commands/config/index.ts b/src/commands/config/index.ts index cbaa582..0d2a3eb 100644 --- a/src/commands/config/index.ts +++ b/src/commands/config/index.ts @@ -24,6 +24,7 @@ export const builder = new SlashCommandBuilder() .addSubcommand(moduleShop.builder) .addSubcommand(moduleWelcome.builder); +// Execute function export const execute = async (interaction: ChatInputCommandInteraction) => { switch (interaction.options.getSubcommand()) { case "audits": diff --git a/src/commands/counters/index.ts b/src/commands/counters/index.ts index edb73e2..5abd43e 100644 --- a/src/commands/counters/index.ts +++ b/src/commands/counters/index.ts @@ -12,6 +12,7 @@ export const builder = new SlashCommandBuilder() // Modules .addSubcommand(moduleView.builder); +// Execute function export const execute = async (interaction: ChatInputCommandInteraction) => { switch (interaction.options.getSubcommand()) { case "view": diff --git a/src/commands/credits/index.ts b/src/commands/credits/index.ts index a1aaad6..777d32c 100644 --- a/src/commands/credits/index.ts +++ b/src/commands/credits/index.ts @@ -19,6 +19,7 @@ export const builder = new SlashCommandBuilder() .addSubcommand(moduleTop.builder) .addSubcommand(moduleWork.builder); +// Execute function export const execute = async (interaction: ChatInputCommandInteraction) => { const { options } = interaction; diff --git a/src/commands/fun/index.ts b/src/commands/fun/index.ts index e010d5d..e4f0972 100644 --- a/src/commands/fun/index.ts +++ b/src/commands/fun/index.ts @@ -11,6 +11,7 @@ export const builder = new SlashCommandBuilder() .addSubcommand(moduleMeme.builder); +// Execute function export const execute = async (interaction: ChatInputCommandInteraction) => { const { options } = interaction; diff --git a/src/commands/reputation/index.ts b/src/commands/reputation/index.ts index d339cb2..a550a7e 100644 --- a/src/commands/reputation/index.ts +++ b/src/commands/reputation/index.ts @@ -16,6 +16,7 @@ export const builder = new SlashCommandBuilder() .addSubcommand(moduleGive.builder) .addSubcommand(moduleView.builder); +// Execute function export const execute = async (interaction: ChatInputCommandInteraction) => { if (interaction.options.getSubcommand() === "give") { await moduleGive.execute(interaction); diff --git a/src/schedules/shop/modules/roles/components/dueForPayment.ts b/src/schedules/shop/modules/roles/components/dueForPayment.ts index ee2eb3f..fd08ae7 100644 --- a/src/schedules/shop/modules/roles/components/dueForPayment.ts +++ b/src/schedules/shop/modules/roles/components/dueForPayment.ts @@ -3,6 +3,7 @@ import logger from "../../../../../middlewares/logger"; import { GuildShopRoles } from "@prisma/client"; +// Execute the dueForPayment function export const execute = (_client: Client, role: GuildShopRoles) => { const { roleId } = role; diff --git a/src/schedules/shop/modules/roles/index.ts b/src/schedules/shop/modules/roles/index.ts index d3c7973..197cecd 100644 --- a/src/schedules/shop/modules/roles/index.ts +++ b/src/schedules/shop/modules/roles/index.ts @@ -5,6 +5,7 @@ import prisma from "../../../../handlers/database"; import { execute as dueForPaymentExecute } from "./components/dueForPayment"; import { execute as overDueForPaymentExecute } from "./components/overDueForPayment"; +// Execute the roles function export const execute = async (client: Client) => { const roles = await prisma.guildShopRoles.findMany(); From 338c3590220c06d9c2891b05ca8d90042beab057 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 21 Oct 2022 18:01:59 +0000 Subject: [PATCH 204/215] Restyled by pg_format --- .../20221019063840_init/migration.sql | 1 + .../20221019064232_init/migration.sql | 1 + .../20221019081114_modules/migration.sql | 1 + .../20221019081816_modules/migration.sql | 1 + .../20221019113258_modules/migration.sql | 1 + .../20221019114543_modules/migration.sql | 1 + .../20221019142757_modules/migration.sql | 1 + .../20221019153247_cooldowns/migration.sql | 1 + .../20221019153652_audit_dates/migration.sql | 1 + .../20221019172846_embedconfig/migration.sql | 1 + .../20221020081238_cpgg_api/migration.sql | 1 + .../migration.sql | 1 + .../20221020084922_cooldown_int/migration.sql | 1 + .../migration.sql | 1 + .../20221020113312_shop_module/migration.sql | 1 + .../migration.sql | 1 + .../migration.sql | 1 + .../migration.sql | 1 + .../migration.sql | 4 +- .../migration.sql | 34 ++- .../migration.sql | 30 ++- .../migration.sql | 30 ++- .../migration.sql | 195 ++++++++++++++---- .../migration.sql | 195 ++++++++++++++---- 24 files changed, 407 insertions(+), 99 deletions(-) diff --git a/prisma/migrations/20221019063840_init/migration.sql b/prisma/migrations/20221019063840_init/migration.sql index d7577f0..d69499d 100644 --- a/prisma/migrations/20221019063840_init/migration.sql +++ b/prisma/migrations/20221019063840_init/migration.sql @@ -27,3 +27,4 @@ CREATE UNIQUE INDEX "User_id_key" ON "User" ("id"); -- CreateIndex CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember" ("userId", "guildId"); + diff --git a/prisma/migrations/20221019064232_init/migration.sql b/prisma/migrations/20221019064232_init/migration.sql index 2028506..27ed6aa 100644 --- a/prisma/migrations/20221019064232_init/migration.sql +++ b/prisma/migrations/20221019064232_init/migration.sql @@ -24,3 +24,4 @@ CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember" ("userId", PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; + diff --git a/prisma/migrations/20221019081114_modules/migration.sql b/prisma/migrations/20221019081114_modules/migration.sql index d20c517..9ebd925 100644 --- a/prisma/migrations/20221019081114_modules/migration.sql +++ b/prisma/migrations/20221019081114_modules/migration.sql @@ -69,3 +69,4 @@ PRAGMA foreign_keys = ON; -- CreateIndex CREATE UNIQUE INDEX "GuildCounter_guildId_channelId_key" ON "GuildCounter" ("guildId", "channelId"); + diff --git a/prisma/migrations/20221019081816_modules/migration.sql b/prisma/migrations/20221019081816_modules/migration.sql index d2fcde5..4cba8c4 100644 --- a/prisma/migrations/20221019081816_modules/migration.sql +++ b/prisma/migrations/20221019081816_modules/migration.sql @@ -33,3 +33,4 @@ CREATE UNIQUE INDEX "GuildCounter_guildId_channelId_key" ON "GuildCounter" ("gui PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; + diff --git a/prisma/migrations/20221019113258_modules/migration.sql b/prisma/migrations/20221019113258_modules/migration.sql index a22b2a3..d88a0fb 100644 --- a/prisma/migrations/20221019113258_modules/migration.sql +++ b/prisma/migrations/20221019113258_modules/migration.sql @@ -41,3 +41,4 @@ CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; + diff --git a/prisma/migrations/20221019114543_modules/migration.sql b/prisma/migrations/20221019114543_modules/migration.sql index 0d89d31..d15916d 100644 --- a/prisma/migrations/20221019114543_modules/migration.sql +++ b/prisma/migrations/20221019114543_modules/migration.sql @@ -43,3 +43,4 @@ CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; + diff --git a/prisma/migrations/20221019142757_modules/migration.sql b/prisma/migrations/20221019142757_modules/migration.sql index 387fb6e..e4bccc3 100644 --- a/prisma/migrations/20221019142757_modules/migration.sql +++ b/prisma/migrations/20221019142757_modules/migration.sql @@ -28,3 +28,4 @@ CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember" ("userId", PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; + diff --git a/prisma/migrations/20221019153247_cooldowns/migration.sql b/prisma/migrations/20221019153247_cooldowns/migration.sql index b85f815..58b4dff 100644 --- a/prisma/migrations/20221019153247_cooldowns/migration.sql +++ b/prisma/migrations/20221019153247_cooldowns/migration.sql @@ -11,3 +11,4 @@ CREATE TABLE "Cooldown" ( -- CreateIndex CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown" ("guildId", "userId", "timeoutId"); + diff --git a/prisma/migrations/20221019153652_audit_dates/migration.sql b/prisma/migrations/20221019153652_audit_dates/migration.sql index fd40071..0171217 100644 --- a/prisma/migrations/20221019153652_audit_dates/migration.sql +++ b/prisma/migrations/20221019153652_audit_dates/migration.sql @@ -153,3 +153,4 @@ CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember" ("userId", PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; + diff --git a/prisma/migrations/20221019172846_embedconfig/migration.sql b/prisma/migrations/20221019172846_embedconfig/migration.sql index f404f36..aeea219 100644 --- a/prisma/migrations/20221019172846_embedconfig/migration.sql +++ b/prisma/migrations/20221019172846_embedconfig/migration.sql @@ -53,3 +53,4 @@ CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; + diff --git a/prisma/migrations/20221020081238_cpgg_api/migration.sql b/prisma/migrations/20221020081238_cpgg_api/migration.sql index 6b056d0..c69d565 100644 --- a/prisma/migrations/20221020081238_cpgg_api/migration.sql +++ b/prisma/migrations/20221020081238_cpgg_api/migration.sql @@ -10,3 +10,4 @@ ALTER TABLE "Guild" ALTER TABLE "Guild" ADD COLUMN "apiCpggUrlIv" TEXT; + diff --git a/prisma/migrations/20221020084750_cooldown_string/migration.sql b/prisma/migrations/20221020084750_cooldown_string/migration.sql index a9521a5..20f0bf5 100644 --- a/prisma/migrations/20221020084750_cooldown_string/migration.sql +++ b/prisma/migrations/20221020084750_cooldown_string/migration.sql @@ -32,3 +32,4 @@ CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown" ("guil PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; + diff --git a/prisma/migrations/20221020084922_cooldown_int/migration.sql b/prisma/migrations/20221020084922_cooldown_int/migration.sql index 822d410..282e7d1 100644 --- a/prisma/migrations/20221020084922_cooldown_int/migration.sql +++ b/prisma/migrations/20221020084922_cooldown_int/migration.sql @@ -38,3 +38,4 @@ CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown" ("guil PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; + diff --git a/prisma/migrations/20221020111948_audits_module/migration.sql b/prisma/migrations/20221020111948_audits_module/migration.sql index c44d8b6..b1b6293 100644 --- a/prisma/migrations/20221020111948_audits_module/migration.sql +++ b/prisma/migrations/20221020111948_audits_module/migration.sql @@ -68,3 +68,4 @@ CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; + diff --git a/prisma/migrations/20221020113312_shop_module/migration.sql b/prisma/migrations/20221020113312_shop_module/migration.sql index 8cdbd73..14cd966 100644 --- a/prisma/migrations/20221020113312_shop_module/migration.sql +++ b/prisma/migrations/20221020113312_shop_module/migration.sql @@ -72,3 +72,4 @@ CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; + diff --git a/prisma/migrations/20221020113704_welcome_module/migration.sql b/prisma/migrations/20221020113704_welcome_module/migration.sql index 7d5c6c5..0c55776 100644 --- a/prisma/migrations/20221020113704_welcome_module/migration.sql +++ b/prisma/migrations/20221020113704_welcome_module/migration.sql @@ -77,3 +77,4 @@ CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; + diff --git a/prisma/migrations/20221020113756_welcome_module_correction/migration.sql b/prisma/migrations/20221020113756_welcome_module_correction/migration.sql index 1035421..d2e95ac 100644 --- a/prisma/migrations/20221020113756_welcome_module_correction/migration.sql +++ b/prisma/migrations/20221020113756_welcome_module_correction/migration.sql @@ -87,3 +87,4 @@ CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; + diff --git a/prisma/migrations/20221020113831_welcome_module_correction/migration.sql b/prisma/migrations/20221020113831_welcome_module_correction/migration.sql index 0c05518..191112f 100644 --- a/prisma/migrations/20221020113831_welcome_module_correction/migration.sql +++ b/prisma/migrations/20221020113831_welcome_module_correction/migration.sql @@ -89,3 +89,4 @@ CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; + diff --git a/prisma/migrations/20221021150615_shoproles_model/migration.sql b/prisma/migrations/20221021150615_shoproles_model/migration.sql index 1859cc1..545a454 100644 --- a/prisma/migrations/20221021150615_shoproles_model/migration.sql +++ b/prisma/migrations/20221021150615_shoproles_model/migration.sql @@ -13,4 +13,6 @@ CREATE TABLE "GuildShopRoles" ( ); -- CreateIndex -CREATE UNIQUE INDEX "GuildShopRoles_guildId_channelId_key" ON "GuildShopRoles"("guildId", "channelId"); + +CREATE UNIQUE INDEX "GuildShopRoles_guildId_channelId_key" ON "GuildShopRoles" ("guildId", "channelId"); + diff --git a/prisma/migrations/20221021151136_shoproles_model_correction/migration.sql b/prisma/migrations/20221021151136_shoproles_model_correction/migration.sql index 5631656..970dead 100644 --- a/prisma/migrations/20221021151136_shoproles_model_correction/migration.sql +++ b/prisma/migrations/20221021151136_shoproles_model_correction/migration.sql @@ -1,11 +1,12 @@ /* - Warnings: + Warnings: - - You are about to drop the column `channelId` on the `GuildShopRoles` table. All the data in the column will be lost. - -*/ + - You are about to drop the column `channelId` on the `GuildShopRoles` table. All the data in the column will be lost. + */ -- RedefineTables -PRAGMA foreign_keys=OFF; + +PRAGMA foreign_keys = OFF; + CREATE TABLE "new_GuildShopRoles" ( "guildId" TEXT NOT NULL, "roleId" TEXT NOT NULL, @@ -17,9 +18,26 @@ CREATE TABLE "new_GuildShopRoles" ( CONSTRAINT "GuildShopRoles_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "GuildShopRoles_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") SELECT "createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId" FROM "GuildShopRoles"; + +INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") +SELECT + "createdAt", + "guildId", + "lastPayed", + "pricePerHour", + "roleId", + "updatedAt", + "userId" +FROM + "GuildShopRoles"; + DROP TABLE "GuildShopRoles"; + ALTER TABLE "new_GuildShopRoles" RENAME TO "GuildShopRoles"; -CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles"("guildId", "userId", "roleId"); + +CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles" ("guildId", "userId", "roleId"); + PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; + +PRAGMA foreign_keys = ON; + diff --git a/prisma/migrations/20221021151337_shoproles_model_correction/migration.sql b/prisma/migrations/20221021151337_shoproles_model_correction/migration.sql index 8a3fe75..35824ff 100644 --- a/prisma/migrations/20221021151337_shoproles_model_correction/migration.sql +++ b/prisma/migrations/20221021151337_shoproles_model_correction/migration.sql @@ -1,5 +1,6 @@ -- RedefineTables -PRAGMA foreign_keys=OFF; +PRAGMA foreign_keys = OFF; + CREATE TABLE "new_GuildShopRoles" ( "guildId" TEXT NOT NULL, "roleId" TEXT NOT NULL, @@ -10,11 +11,30 @@ CREATE TABLE "new_GuildShopRoles" ( "updatedAt" DATETIME NOT NULL, CONSTRAINT "GuildShopRoles_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "GuildShopRoles_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "GuildShopRoles_guildId_userId_fkey" FOREIGN KEY ("guildId", "userId") REFERENCES "GuildMember" ("guildId", "userId") ON DELETE RESTRICT ON UPDATE CASCADE + CONSTRAINT "GuildShopRoles_guildId_userId_fkey" FOREIGN KEY ("guildId", + "userId") REFERENCES "GuildMember" ("guildId", + "userId") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") SELECT "createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId" FROM "GuildShopRoles"; + +INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") +SELECT + "createdAt", + "guildId", + "lastPayed", + "pricePerHour", + "roleId", + "updatedAt", + "userId" +FROM + "GuildShopRoles"; + DROP TABLE "GuildShopRoles"; + ALTER TABLE "new_GuildShopRoles" RENAME TO "GuildShopRoles"; -CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles"("guildId", "userId", "roleId"); + +CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles" ("guildId", "userId", "roleId"); + PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; + +PRAGMA foreign_keys = ON; + diff --git a/prisma/migrations/20221021153546_shoproles_model_correction/migration.sql b/prisma/migrations/20221021153546_shoproles_model_correction/migration.sql index 88d1d66..f7d31ff 100644 --- a/prisma/migrations/20221021153546_shoproles_model_correction/migration.sql +++ b/prisma/migrations/20221021153546_shoproles_model_correction/migration.sql @@ -1,5 +1,6 @@ -- RedefineTables -PRAGMA foreign_keys=OFF; +PRAGMA foreign_keys = OFF; + CREATE TABLE "new_GuildShopRoles" ( "guildId" TEXT NOT NULL, "roleId" TEXT NOT NULL, @@ -10,11 +11,30 @@ CREATE TABLE "new_GuildShopRoles" ( "updatedAt" DATETIME NOT NULL, CONSTRAINT "GuildShopRoles_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "GuildShopRoles_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "GuildShopRoles_userId_guildId_fkey" FOREIGN KEY ("userId", "guildId") REFERENCES "GuildMember" ("userId", "guildId") ON DELETE RESTRICT ON UPDATE CASCADE + CONSTRAINT "GuildShopRoles_userId_guildId_fkey" FOREIGN KEY ("userId", + "guildId") REFERENCES "GuildMember" ("userId", + "guildId") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") SELECT "createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId" FROM "GuildShopRoles"; + +INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") +SELECT + "createdAt", + "guildId", + "lastPayed", + "pricePerHour", + "roleId", + "updatedAt", + "userId" +FROM + "GuildShopRoles"; + DROP TABLE "GuildShopRoles"; + ALTER TABLE "new_GuildShopRoles" RENAME TO "GuildShopRoles"; -CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles"("guildId", "userId", "roleId"); + +CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles" ("guildId", "userId", "roleId"); + PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; + +PRAGMA foreign_keys = ON; + diff --git a/prisma/migrations/20221021172156_int_to_bigint/migration.sql b/prisma/migrations/20221021172156_int_to_bigint/migration.sql index 187923d..aee4d93 100644 --- a/prisma/migrations/20221021172156_int_to_bigint/migration.sql +++ b/prisma/migrations/20221021172156_int_to_bigint/migration.sql @@ -1,25 +1,26 @@ /* - Warnings: + Warnings: - - You are about to alter the column `count` on the `GuildCounter` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `creditsEarned` on the `GuildMember` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `pointsEarned` on the `GuildMember` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `pricePerHour` on the `GuildShopRoles` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `cooldown` on the `Cooldown` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `creditsMinimumLength` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `creditsRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `creditsTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `creditsWorkRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `creditsWorkTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `pointsMinimumLength` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `pointsRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `pointsTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `shopRolesPricePerHour` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `reputationsEarned` on the `User` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - -*/ + - You are about to alter the column `count` on the `GuildCounter` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `creditsEarned` on the `GuildMember` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `pointsEarned` on the `GuildMember` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `pricePerHour` on the `GuildShopRoles` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `cooldown` on the `Cooldown` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `creditsMinimumLength` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `creditsRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `creditsTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `creditsWorkRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `creditsWorkTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `pointsMinimumLength` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `pointsRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `pointsTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `shopRolesPricePerHour` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `reputationsEarned` on the `User` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + */ -- RedefineTables -PRAGMA foreign_keys=OFF; + +PRAGMA foreign_keys = OFF; + CREATE TABLE "new_GuildCounter" ( "guildId" TEXT NOT NULL, "channelId" TEXT NOT NULL, @@ -29,10 +30,24 @@ CREATE TABLE "new_GuildCounter" ( "updatedAt" DATETIME NOT NULL, CONSTRAINT "GuildCounter_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_GuildCounter" ("channelId", "count", "createdAt", "guildId", "triggerWord", "updatedAt") SELECT "channelId", "count", "createdAt", "guildId", "triggerWord", "updatedAt" FROM "GuildCounter"; + +INSERT INTO "new_GuildCounter" ("channelId", "count", "createdAt", "guildId", "triggerWord", "updatedAt") +SELECT + "channelId", + "count", + "createdAt", + "guildId", + "triggerWord", + "updatedAt" +FROM + "GuildCounter"; + DROP TABLE "GuildCounter"; + ALTER TABLE "new_GuildCounter" RENAME TO "GuildCounter"; -CREATE UNIQUE INDEX "GuildCounter_guildId_channelId_key" ON "GuildCounter"("guildId", "channelId"); + +CREATE UNIQUE INDEX "GuildCounter_guildId_channelId_key" ON "GuildCounter" ("guildId", "channelId"); + CREATE TABLE "new_GuildMember" ( "userId" TEXT NOT NULL, "guildId" TEXT NOT NULL, @@ -43,10 +58,24 @@ CREATE TABLE "new_GuildMember" ( CONSTRAINT "GuildMember_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "GuildMember_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_GuildMember" ("createdAt", "creditsEarned", "guildId", "pointsEarned", "updatedAt", "userId") SELECT "createdAt", "creditsEarned", "guildId", "pointsEarned", "updatedAt", "userId" FROM "GuildMember"; + +INSERT INTO "new_GuildMember" ("createdAt", "creditsEarned", "guildId", "pointsEarned", "updatedAt", "userId") +SELECT + "createdAt", + "creditsEarned", + "guildId", + "pointsEarned", + "updatedAt", + "userId" +FROM + "GuildMember"; + DROP TABLE "GuildMember"; + ALTER TABLE "new_GuildMember" RENAME TO "GuildMember"; -CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember"("userId", "guildId"); + +CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember" ("userId", "guildId"); + CREATE TABLE "new_GuildShopRoles" ( "guildId" TEXT NOT NULL, "roleId" TEXT NOT NULL, @@ -57,12 +86,29 @@ CREATE TABLE "new_GuildShopRoles" ( "updatedAt" DATETIME NOT NULL, CONSTRAINT "GuildShopRoles_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "GuildShopRoles_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "GuildShopRoles_userId_guildId_fkey" FOREIGN KEY ("userId", "guildId") REFERENCES "GuildMember" ("userId", "guildId") ON DELETE RESTRICT ON UPDATE CASCADE + CONSTRAINT "GuildShopRoles_userId_guildId_fkey" FOREIGN KEY ("userId", + "guildId") REFERENCES "GuildMember" ("userId", + "guildId") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") SELECT "createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId" FROM "GuildShopRoles"; + +INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") +SELECT + "createdAt", + "guildId", + "lastPayed", + "pricePerHour", + "roleId", + "updatedAt", + "userId" +FROM + "GuildShopRoles"; + DROP TABLE "GuildShopRoles"; + ALTER TABLE "new_GuildShopRoles" RENAME TO "GuildShopRoles"; -CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles"("guildId", "userId", "roleId"); + +CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles" ("guildId", "userId", "roleId"); + CREATE TABLE "new_Cooldown" ( "guildId" TEXT NOT NULL, "userId" TEXT NOT NULL, @@ -73,10 +119,24 @@ CREATE TABLE "new_Cooldown" ( CONSTRAINT "Cooldown_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "Cooldown_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_Cooldown" ("cooldown", "createdAt", "guildId", "timeoutId", "updatedAt", "userId") SELECT "cooldown", "createdAt", "guildId", "timeoutId", "updatedAt", "userId" FROM "Cooldown"; + +INSERT INTO "new_Cooldown" ("cooldown", "createdAt", "guildId", "timeoutId", "updatedAt", "userId") +SELECT + "cooldown", + "createdAt", + "guildId", + "timeoutId", + "updatedAt", + "userId" +FROM + "Cooldown"; + DROP TABLE "Cooldown"; + ALTER TABLE "new_Cooldown" RENAME TO "Cooldown"; -CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown"("guildId", "userId", "timeoutId"); + +CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown" ("guildId", "userId", "timeoutId"); + CREATE TABLE "new_Guild" ( "id" TEXT NOT NULL, "embedColorSuccess" TEXT NOT NULL DEFAULT '#22bb33', @@ -84,27 +144,27 @@ CREATE TABLE "new_Guild" ( "embedColorError" TEXT NOT NULL DEFAULT '#bb2124', "embedFooterText" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg/xyter', "embedFooterIcon" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg.png', - "creditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "creditsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "creditsRate" BIGINT NOT NULL DEFAULT 1, "creditsTimeout" BIGINT NOT NULL DEFAULT 5, "creditsWorkRate" BIGINT NOT NULL DEFAULT 25, "creditsWorkTimeout" BIGINT NOT NULL DEFAULT 86400, "creditsMinimumLength" BIGINT NOT NULL DEFAULT 5, - "pointsEnabled" BOOLEAN NOT NULL DEFAULT false, + "pointsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "pointsRate" BIGINT NOT NULL DEFAULT 1, "pointsTimeout" BIGINT NOT NULL DEFAULT 5, "pointsMinimumLength" BIGINT NOT NULL DEFAULT 5, - "reputationsEnabled" BOOLEAN NOT NULL DEFAULT false, - "countersEnabled" BOOLEAN NOT NULL DEFAULT false, + "reputationsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, + "countersEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "apiCpggUrlIv" TEXT, "apiCpggUrlContent" TEXT, "apiCpggTokenIv" TEXT, "apiCpggTokenContent" TEXT, - "auditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "auditsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "auditsChannelId" TEXT, - "shopRolesEnabled" BOOLEAN NOT NULL DEFAULT false, + "shopRolesEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "shopRolesPricePerHour" BIGINT NOT NULL DEFAULT 5, - "welcomeEnabled" BOOLEAN NOT NULL DEFAULT false, + "welcomeEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "welcomeJoinChannelId" TEXT, "welcomeJoinChannelMessage" TEXT, "welcomeLeaveChannelId" TEXT, @@ -112,19 +172,74 @@ CREATE TABLE "new_Guild" ( "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" DATETIME NOT NULL ); -INSERT INTO "new_Guild" ("apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt", "welcomeEnabled", "welcomeJoinChannelId", "welcomeJoinChannelMessage", "welcomeLeaveChannelId", "welcomeLeaveChannelMessage") SELECT "apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt", "welcomeEnabled", "welcomeJoinChannelId", "welcomeJoinChannelMessage", "welcomeLeaveChannelId", "welcomeLeaveChannelMessage" FROM "Guild"; + +INSERT INTO "new_Guild" ("apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt", "welcomeEnabled", "welcomeJoinChannelId", "welcomeJoinChannelMessage", "welcomeLeaveChannelId", "welcomeLeaveChannelMessage") +SELECT + "apiCpggTokenContent", + "apiCpggTokenIv", + "apiCpggUrlContent", + "apiCpggUrlIv", + "auditsChannelId", + "auditsEnabled", + "countersEnabled", + "createdAt", + "creditsEnabled", + "creditsMinimumLength", + "creditsRate", + "creditsTimeout", + "creditsWorkRate", + "creditsWorkTimeout", + "embedColorError", + "embedColorSuccess", + "embedColorWait", + "embedFooterIcon", + "embedFooterText", + "id", + "pointsEnabled", + "pointsMinimumLength", + "pointsRate", + "pointsTimeout", + "reputationsEnabled", + "shopRolesEnabled", + "shopRolesPricePerHour", + "updatedAt", + "welcomeEnabled", + "welcomeJoinChannelId", + "welcomeJoinChannelMessage", + "welcomeLeaveChannelId", + "welcomeLeaveChannelMessage" +FROM + "Guild"; + DROP TABLE "Guild"; + ALTER TABLE "new_Guild" RENAME TO "Guild"; -CREATE UNIQUE INDEX "Guild_id_key" ON "Guild"("id"); + +CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); + CREATE TABLE "new_User" ( "id" TEXT NOT NULL, "reputationsEarned" BIGINT NOT NULL DEFAULT 0, "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" DATETIME NOT NULL ); -INSERT INTO "new_User" ("createdAt", "id", "reputationsEarned", "updatedAt") SELECT "createdAt", "id", "reputationsEarned", "updatedAt" FROM "User"; + +INSERT INTO "new_User" ("createdAt", "id", "reputationsEarned", "updatedAt") +SELECT + "createdAt", + "id", + "reputationsEarned", + "updatedAt" +FROM + "User"; + DROP TABLE "User"; + ALTER TABLE "new_User" RENAME TO "User"; -CREATE UNIQUE INDEX "User_id_key" ON "User"("id"); + +CREATE UNIQUE INDEX "User_id_key" ON "User" ("id"); + PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; + +PRAGMA foreign_keys = ON; + diff --git a/prisma/migrations/20221021172345_bigint_to_int/migration.sql b/prisma/migrations/20221021172345_bigint_to_int/migration.sql index 978ac5c..8779a17 100644 --- a/prisma/migrations/20221021172345_bigint_to_int/migration.sql +++ b/prisma/migrations/20221021172345_bigint_to_int/migration.sql @@ -1,35 +1,48 @@ /* - Warnings: + Warnings: - - You are about to alter the column `reputationsEarned` on the `User` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `count` on the `GuildCounter` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `creditsEarned` on the `GuildMember` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `pointsEarned` on the `GuildMember` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `pricePerHour` on the `GuildShopRoles` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `creditsMinimumLength` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `creditsRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `creditsTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `creditsWorkRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `creditsWorkTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `pointsMinimumLength` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `pointsRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `pointsTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `shopRolesPricePerHour` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `cooldown` on the `Cooldown` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - -*/ + - You are about to alter the column `reputationsEarned` on the `User` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `count` on the `GuildCounter` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `creditsEarned` on the `GuildMember` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `pointsEarned` on the `GuildMember` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `pricePerHour` on the `GuildShopRoles` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `creditsMinimumLength` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `creditsRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `creditsTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `creditsWorkRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `creditsWorkTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `pointsMinimumLength` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `pointsRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `pointsTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `shopRolesPricePerHour` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `cooldown` on the `Cooldown` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + */ -- RedefineTables -PRAGMA foreign_keys=OFF; + +PRAGMA foreign_keys = OFF; + CREATE TABLE "new_User" ( "id" TEXT NOT NULL, "reputationsEarned" INTEGER NOT NULL DEFAULT 0, "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" DATETIME NOT NULL ); -INSERT INTO "new_User" ("createdAt", "id", "reputationsEarned", "updatedAt") SELECT "createdAt", "id", "reputationsEarned", "updatedAt" FROM "User"; + +INSERT INTO "new_User" ("createdAt", "id", "reputationsEarned", "updatedAt") +SELECT + "createdAt", + "id", + "reputationsEarned", + "updatedAt" +FROM + "User"; + DROP TABLE "User"; + ALTER TABLE "new_User" RENAME TO "User"; -CREATE UNIQUE INDEX "User_id_key" ON "User"("id"); + +CREATE UNIQUE INDEX "User_id_key" ON "User" ("id"); + CREATE TABLE "new_GuildCounter" ( "guildId" TEXT NOT NULL, "channelId" TEXT NOT NULL, @@ -39,10 +52,24 @@ CREATE TABLE "new_GuildCounter" ( "updatedAt" DATETIME NOT NULL, CONSTRAINT "GuildCounter_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_GuildCounter" ("channelId", "count", "createdAt", "guildId", "triggerWord", "updatedAt") SELECT "channelId", "count", "createdAt", "guildId", "triggerWord", "updatedAt" FROM "GuildCounter"; + +INSERT INTO "new_GuildCounter" ("channelId", "count", "createdAt", "guildId", "triggerWord", "updatedAt") +SELECT + "channelId", + "count", + "createdAt", + "guildId", + "triggerWord", + "updatedAt" +FROM + "GuildCounter"; + DROP TABLE "GuildCounter"; + ALTER TABLE "new_GuildCounter" RENAME TO "GuildCounter"; -CREATE UNIQUE INDEX "GuildCounter_guildId_channelId_key" ON "GuildCounter"("guildId", "channelId"); + +CREATE UNIQUE INDEX "GuildCounter_guildId_channelId_key" ON "GuildCounter" ("guildId", "channelId"); + CREATE TABLE "new_GuildMember" ( "userId" TEXT NOT NULL, "guildId" TEXT NOT NULL, @@ -53,10 +80,24 @@ CREATE TABLE "new_GuildMember" ( CONSTRAINT "GuildMember_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "GuildMember_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_GuildMember" ("createdAt", "creditsEarned", "guildId", "pointsEarned", "updatedAt", "userId") SELECT "createdAt", "creditsEarned", "guildId", "pointsEarned", "updatedAt", "userId" FROM "GuildMember"; + +INSERT INTO "new_GuildMember" ("createdAt", "creditsEarned", "guildId", "pointsEarned", "updatedAt", "userId") +SELECT + "createdAt", + "creditsEarned", + "guildId", + "pointsEarned", + "updatedAt", + "userId" +FROM + "GuildMember"; + DROP TABLE "GuildMember"; + ALTER TABLE "new_GuildMember" RENAME TO "GuildMember"; -CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember"("userId", "guildId"); + +CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember" ("userId", "guildId"); + CREATE TABLE "new_GuildShopRoles" ( "guildId" TEXT NOT NULL, "roleId" TEXT NOT NULL, @@ -67,12 +108,29 @@ CREATE TABLE "new_GuildShopRoles" ( "updatedAt" DATETIME NOT NULL, CONSTRAINT "GuildShopRoles_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "GuildShopRoles_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "GuildShopRoles_userId_guildId_fkey" FOREIGN KEY ("userId", "guildId") REFERENCES "GuildMember" ("userId", "guildId") ON DELETE RESTRICT ON UPDATE CASCADE + CONSTRAINT "GuildShopRoles_userId_guildId_fkey" FOREIGN KEY ("userId", + "guildId") REFERENCES "GuildMember" ("userId", + "guildId") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") SELECT "createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId" FROM "GuildShopRoles"; + +INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") +SELECT + "createdAt", + "guildId", + "lastPayed", + "pricePerHour", + "roleId", + "updatedAt", + "userId" +FROM + "GuildShopRoles"; + DROP TABLE "GuildShopRoles"; + ALTER TABLE "new_GuildShopRoles" RENAME TO "GuildShopRoles"; -CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles"("guildId", "userId", "roleId"); + +CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles" ("guildId", "userId", "roleId"); + CREATE TABLE "new_Guild" ( "id" TEXT NOT NULL, "embedColorSuccess" TEXT NOT NULL DEFAULT '#22bb33', @@ -80,27 +138,27 @@ CREATE TABLE "new_Guild" ( "embedColorError" TEXT NOT NULL DEFAULT '#bb2124', "embedFooterText" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg/xyter', "embedFooterIcon" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg.png', - "creditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "creditsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "creditsRate" INTEGER NOT NULL DEFAULT 1, "creditsTimeout" INTEGER NOT NULL DEFAULT 5, "creditsWorkRate" INTEGER NOT NULL DEFAULT 25, "creditsWorkTimeout" INTEGER NOT NULL DEFAULT 86400, "creditsMinimumLength" INTEGER NOT NULL DEFAULT 5, - "pointsEnabled" BOOLEAN NOT NULL DEFAULT false, + "pointsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "pointsRate" INTEGER NOT NULL DEFAULT 1, "pointsTimeout" INTEGER NOT NULL DEFAULT 5, "pointsMinimumLength" INTEGER NOT NULL DEFAULT 5, - "reputationsEnabled" BOOLEAN NOT NULL DEFAULT false, - "countersEnabled" BOOLEAN NOT NULL DEFAULT false, + "reputationsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, + "countersEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "apiCpggUrlIv" TEXT, "apiCpggUrlContent" TEXT, "apiCpggTokenIv" TEXT, "apiCpggTokenContent" TEXT, - "auditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "auditsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "auditsChannelId" TEXT, - "shopRolesEnabled" BOOLEAN NOT NULL DEFAULT false, + "shopRolesEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "shopRolesPricePerHour" INTEGER NOT NULL DEFAULT 5, - "welcomeEnabled" BOOLEAN NOT NULL DEFAULT false, + "welcomeEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "welcomeJoinChannelId" TEXT, "welcomeJoinChannelMessage" TEXT, "welcomeLeaveChannelId" TEXT, @@ -108,10 +166,51 @@ CREATE TABLE "new_Guild" ( "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" DATETIME NOT NULL ); -INSERT INTO "new_Guild" ("apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt", "welcomeEnabled", "welcomeJoinChannelId", "welcomeJoinChannelMessage", "welcomeLeaveChannelId", "welcomeLeaveChannelMessage") SELECT "apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt", "welcomeEnabled", "welcomeJoinChannelId", "welcomeJoinChannelMessage", "welcomeLeaveChannelId", "welcomeLeaveChannelMessage" FROM "Guild"; + +INSERT INTO "new_Guild" ("apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt", "welcomeEnabled", "welcomeJoinChannelId", "welcomeJoinChannelMessage", "welcomeLeaveChannelId", "welcomeLeaveChannelMessage") +SELECT + "apiCpggTokenContent", + "apiCpggTokenIv", + "apiCpggUrlContent", + "apiCpggUrlIv", + "auditsChannelId", + "auditsEnabled", + "countersEnabled", + "createdAt", + "creditsEnabled", + "creditsMinimumLength", + "creditsRate", + "creditsTimeout", + "creditsWorkRate", + "creditsWorkTimeout", + "embedColorError", + "embedColorSuccess", + "embedColorWait", + "embedFooterIcon", + "embedFooterText", + "id", + "pointsEnabled", + "pointsMinimumLength", + "pointsRate", + "pointsTimeout", + "reputationsEnabled", + "shopRolesEnabled", + "shopRolesPricePerHour", + "updatedAt", + "welcomeEnabled", + "welcomeJoinChannelId", + "welcomeJoinChannelMessage", + "welcomeLeaveChannelId", + "welcomeLeaveChannelMessage" +FROM + "Guild"; + DROP TABLE "Guild"; + ALTER TABLE "new_Guild" RENAME TO "Guild"; -CREATE UNIQUE INDEX "Guild_id_key" ON "Guild"("id"); + +CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); + CREATE TABLE "new_Cooldown" ( "guildId" TEXT NOT NULL, "userId" TEXT NOT NULL, @@ -122,9 +221,25 @@ CREATE TABLE "new_Cooldown" ( CONSTRAINT "Cooldown_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "Cooldown_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_Cooldown" ("cooldown", "createdAt", "guildId", "timeoutId", "updatedAt", "userId") SELECT "cooldown", "createdAt", "guildId", "timeoutId", "updatedAt", "userId" FROM "Cooldown"; + +INSERT INTO "new_Cooldown" ("cooldown", "createdAt", "guildId", "timeoutId", "updatedAt", "userId") +SELECT + "cooldown", + "createdAt", + "guildId", + "timeoutId", + "updatedAt", + "userId" +FROM + "Cooldown"; + DROP TABLE "Cooldown"; + ALTER TABLE "new_Cooldown" RENAME TO "Cooldown"; -CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown"("guildId", "userId", "timeoutId"); + +CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown" ("guildId", "userId", "timeoutId"); + PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; + +PRAGMA foreign_keys = ON; + From 0202ff34620f8ca2db0d4a0064e68b4da2989118 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 21 Oct 2022 18:02:02 +0000 Subject: [PATCH 205/215] Restyled by whitespace --- prisma/.gitignore | 2 +- prisma/migrations/20221019063840_init/migration.sql | 1 - prisma/migrations/20221019064232_init/migration.sql | 1 - prisma/migrations/20221019081114_modules/migration.sql | 1 - prisma/migrations/20221019081816_modules/migration.sql | 1 - prisma/migrations/20221019113258_modules/migration.sql | 1 - prisma/migrations/20221019114543_modules/migration.sql | 1 - prisma/migrations/20221019142757_modules/migration.sql | 1 - prisma/migrations/20221019153247_cooldowns/migration.sql | 1 - prisma/migrations/20221019153652_audit_dates/migration.sql | 1 - prisma/migrations/20221019172846_embedconfig/migration.sql | 1 - prisma/migrations/20221020081238_cpgg_api/migration.sql | 1 - prisma/migrations/20221020084750_cooldown_string/migration.sql | 1 - prisma/migrations/20221020084922_cooldown_int/migration.sql | 1 - prisma/migrations/20221020111948_audits_module/migration.sql | 1 - prisma/migrations/20221020113312_shop_module/migration.sql | 1 - prisma/migrations/20221020113704_welcome_module/migration.sql | 1 - .../20221020113756_welcome_module_correction/migration.sql | 1 - .../20221020113831_welcome_module_correction/migration.sql | 1 - prisma/migrations/20221021150615_shoproles_model/migration.sql | 1 - .../20221021151136_shoproles_model_correction/migration.sql | 1 - .../20221021151337_shoproles_model_correction/migration.sql | 1 - .../20221021153546_shoproles_model_correction/migration.sql | 1 - prisma/migrations/20221021172156_int_to_bigint/migration.sql | 1 - prisma/migrations/20221021172345_bigint_to_int/migration.sql | 1 - prisma/migrations/migration_lock.toml | 2 +- src/handlers/database/index.ts | 2 +- 27 files changed, 3 insertions(+), 27 deletions(-) diff --git a/prisma/.gitignore b/prisma/.gitignore index 03f6f26..87f333a 100644 --- a/prisma/.gitignore +++ b/prisma/.gitignore @@ -1,2 +1,2 @@ *.db -*.db-journal \ No newline at end of file +*.db-journal diff --git a/prisma/migrations/20221019063840_init/migration.sql b/prisma/migrations/20221019063840_init/migration.sql index d69499d..d7577f0 100644 --- a/prisma/migrations/20221019063840_init/migration.sql +++ b/prisma/migrations/20221019063840_init/migration.sql @@ -27,4 +27,3 @@ CREATE UNIQUE INDEX "User_id_key" ON "User" ("id"); -- CreateIndex CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember" ("userId", "guildId"); - diff --git a/prisma/migrations/20221019064232_init/migration.sql b/prisma/migrations/20221019064232_init/migration.sql index 27ed6aa..2028506 100644 --- a/prisma/migrations/20221019064232_init/migration.sql +++ b/prisma/migrations/20221019064232_init/migration.sql @@ -24,4 +24,3 @@ CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember" ("userId", PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; - diff --git a/prisma/migrations/20221019081114_modules/migration.sql b/prisma/migrations/20221019081114_modules/migration.sql index 9ebd925..d20c517 100644 --- a/prisma/migrations/20221019081114_modules/migration.sql +++ b/prisma/migrations/20221019081114_modules/migration.sql @@ -69,4 +69,3 @@ PRAGMA foreign_keys = ON; -- CreateIndex CREATE UNIQUE INDEX "GuildCounter_guildId_channelId_key" ON "GuildCounter" ("guildId", "channelId"); - diff --git a/prisma/migrations/20221019081816_modules/migration.sql b/prisma/migrations/20221019081816_modules/migration.sql index 4cba8c4..d2fcde5 100644 --- a/prisma/migrations/20221019081816_modules/migration.sql +++ b/prisma/migrations/20221019081816_modules/migration.sql @@ -33,4 +33,3 @@ CREATE UNIQUE INDEX "GuildCounter_guildId_channelId_key" ON "GuildCounter" ("gui PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; - diff --git a/prisma/migrations/20221019113258_modules/migration.sql b/prisma/migrations/20221019113258_modules/migration.sql index d88a0fb..a22b2a3 100644 --- a/prisma/migrations/20221019113258_modules/migration.sql +++ b/prisma/migrations/20221019113258_modules/migration.sql @@ -41,4 +41,3 @@ CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; - diff --git a/prisma/migrations/20221019114543_modules/migration.sql b/prisma/migrations/20221019114543_modules/migration.sql index d15916d..0d89d31 100644 --- a/prisma/migrations/20221019114543_modules/migration.sql +++ b/prisma/migrations/20221019114543_modules/migration.sql @@ -43,4 +43,3 @@ CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; - diff --git a/prisma/migrations/20221019142757_modules/migration.sql b/prisma/migrations/20221019142757_modules/migration.sql index e4bccc3..387fb6e 100644 --- a/prisma/migrations/20221019142757_modules/migration.sql +++ b/prisma/migrations/20221019142757_modules/migration.sql @@ -28,4 +28,3 @@ CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember" ("userId", PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; - diff --git a/prisma/migrations/20221019153247_cooldowns/migration.sql b/prisma/migrations/20221019153247_cooldowns/migration.sql index 58b4dff..b85f815 100644 --- a/prisma/migrations/20221019153247_cooldowns/migration.sql +++ b/prisma/migrations/20221019153247_cooldowns/migration.sql @@ -11,4 +11,3 @@ CREATE TABLE "Cooldown" ( -- CreateIndex CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown" ("guildId", "userId", "timeoutId"); - diff --git a/prisma/migrations/20221019153652_audit_dates/migration.sql b/prisma/migrations/20221019153652_audit_dates/migration.sql index 0171217..fd40071 100644 --- a/prisma/migrations/20221019153652_audit_dates/migration.sql +++ b/prisma/migrations/20221019153652_audit_dates/migration.sql @@ -153,4 +153,3 @@ CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember" ("userId", PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; - diff --git a/prisma/migrations/20221019172846_embedconfig/migration.sql b/prisma/migrations/20221019172846_embedconfig/migration.sql index aeea219..f404f36 100644 --- a/prisma/migrations/20221019172846_embedconfig/migration.sql +++ b/prisma/migrations/20221019172846_embedconfig/migration.sql @@ -53,4 +53,3 @@ CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; - diff --git a/prisma/migrations/20221020081238_cpgg_api/migration.sql b/prisma/migrations/20221020081238_cpgg_api/migration.sql index c69d565..6b056d0 100644 --- a/prisma/migrations/20221020081238_cpgg_api/migration.sql +++ b/prisma/migrations/20221020081238_cpgg_api/migration.sql @@ -10,4 +10,3 @@ ALTER TABLE "Guild" ALTER TABLE "Guild" ADD COLUMN "apiCpggUrlIv" TEXT; - diff --git a/prisma/migrations/20221020084750_cooldown_string/migration.sql b/prisma/migrations/20221020084750_cooldown_string/migration.sql index 20f0bf5..a9521a5 100644 --- a/prisma/migrations/20221020084750_cooldown_string/migration.sql +++ b/prisma/migrations/20221020084750_cooldown_string/migration.sql @@ -32,4 +32,3 @@ CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown" ("guil PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; - diff --git a/prisma/migrations/20221020084922_cooldown_int/migration.sql b/prisma/migrations/20221020084922_cooldown_int/migration.sql index 282e7d1..822d410 100644 --- a/prisma/migrations/20221020084922_cooldown_int/migration.sql +++ b/prisma/migrations/20221020084922_cooldown_int/migration.sql @@ -38,4 +38,3 @@ CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown" ("guil PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; - diff --git a/prisma/migrations/20221020111948_audits_module/migration.sql b/prisma/migrations/20221020111948_audits_module/migration.sql index b1b6293..c44d8b6 100644 --- a/prisma/migrations/20221020111948_audits_module/migration.sql +++ b/prisma/migrations/20221020111948_audits_module/migration.sql @@ -68,4 +68,3 @@ CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; - diff --git a/prisma/migrations/20221020113312_shop_module/migration.sql b/prisma/migrations/20221020113312_shop_module/migration.sql index 14cd966..8cdbd73 100644 --- a/prisma/migrations/20221020113312_shop_module/migration.sql +++ b/prisma/migrations/20221020113312_shop_module/migration.sql @@ -72,4 +72,3 @@ CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; - diff --git a/prisma/migrations/20221020113704_welcome_module/migration.sql b/prisma/migrations/20221020113704_welcome_module/migration.sql index 0c55776..7d5c6c5 100644 --- a/prisma/migrations/20221020113704_welcome_module/migration.sql +++ b/prisma/migrations/20221020113704_welcome_module/migration.sql @@ -77,4 +77,3 @@ CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; - diff --git a/prisma/migrations/20221020113756_welcome_module_correction/migration.sql b/prisma/migrations/20221020113756_welcome_module_correction/migration.sql index d2e95ac..1035421 100644 --- a/prisma/migrations/20221020113756_welcome_module_correction/migration.sql +++ b/prisma/migrations/20221020113756_welcome_module_correction/migration.sql @@ -87,4 +87,3 @@ CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; - diff --git a/prisma/migrations/20221020113831_welcome_module_correction/migration.sql b/prisma/migrations/20221020113831_welcome_module_correction/migration.sql index 191112f..0c05518 100644 --- a/prisma/migrations/20221020113831_welcome_module_correction/migration.sql +++ b/prisma/migrations/20221020113831_welcome_module_correction/migration.sql @@ -89,4 +89,3 @@ CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; - diff --git a/prisma/migrations/20221021150615_shoproles_model/migration.sql b/prisma/migrations/20221021150615_shoproles_model/migration.sql index 545a454..3d9bab2 100644 --- a/prisma/migrations/20221021150615_shoproles_model/migration.sql +++ b/prisma/migrations/20221021150615_shoproles_model/migration.sql @@ -15,4 +15,3 @@ CREATE TABLE "GuildShopRoles" ( -- CreateIndex CREATE UNIQUE INDEX "GuildShopRoles_guildId_channelId_key" ON "GuildShopRoles" ("guildId", "channelId"); - diff --git a/prisma/migrations/20221021151136_shoproles_model_correction/migration.sql b/prisma/migrations/20221021151136_shoproles_model_correction/migration.sql index 970dead..f3a4e3a 100644 --- a/prisma/migrations/20221021151136_shoproles_model_correction/migration.sql +++ b/prisma/migrations/20221021151136_shoproles_model_correction/migration.sql @@ -40,4 +40,3 @@ CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRole PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; - diff --git a/prisma/migrations/20221021151337_shoproles_model_correction/migration.sql b/prisma/migrations/20221021151337_shoproles_model_correction/migration.sql index 35824ff..52dc513 100644 --- a/prisma/migrations/20221021151337_shoproles_model_correction/migration.sql +++ b/prisma/migrations/20221021151337_shoproles_model_correction/migration.sql @@ -37,4 +37,3 @@ CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRole PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; - diff --git a/prisma/migrations/20221021153546_shoproles_model_correction/migration.sql b/prisma/migrations/20221021153546_shoproles_model_correction/migration.sql index f7d31ff..555cf58 100644 --- a/prisma/migrations/20221021153546_shoproles_model_correction/migration.sql +++ b/prisma/migrations/20221021153546_shoproles_model_correction/migration.sql @@ -37,4 +37,3 @@ CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRole PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; - diff --git a/prisma/migrations/20221021172156_int_to_bigint/migration.sql b/prisma/migrations/20221021172156_int_to_bigint/migration.sql index aee4d93..8ba2555 100644 --- a/prisma/migrations/20221021172156_int_to_bigint/migration.sql +++ b/prisma/migrations/20221021172156_int_to_bigint/migration.sql @@ -242,4 +242,3 @@ CREATE UNIQUE INDEX "User_id_key" ON "User" ("id"); PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; - diff --git a/prisma/migrations/20221021172345_bigint_to_int/migration.sql b/prisma/migrations/20221021172345_bigint_to_int/migration.sql index 8779a17..29f4f08 100644 --- a/prisma/migrations/20221021172345_bigint_to_int/migration.sql +++ b/prisma/migrations/20221021172345_bigint_to_int/migration.sql @@ -242,4 +242,3 @@ CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown" ("guil PRAGMA foreign_key_check; PRAGMA foreign_keys = ON; - diff --git a/prisma/migrations/migration_lock.toml b/prisma/migrations/migration_lock.toml index e5e5c47..6fcf33d 100644 --- a/prisma/migrations/migration_lock.toml +++ b/prisma/migrations/migration_lock.toml @@ -1,3 +1,3 @@ # Please do not edit this file manually # It should be added in your version-control system (i.e. Git) -provider = "sqlite" \ No newline at end of file +provider = "sqlite" diff --git a/src/handlers/database/index.ts b/src/handlers/database/index.ts index 287669a..c4e22e4 100644 --- a/src/handlers/database/index.ts +++ b/src/handlers/database/index.ts @@ -1,3 +1,3 @@ import { PrismaClient } from '@prisma/client' -export default new PrismaClient() \ No newline at end of file +export default new PrismaClient() From 4d8b2fa2df003c4f22704a7b59dfeac54fa9f687 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 20:08:20 +0200 Subject: [PATCH 206/215] =?UTF-8?q?=E2=9A=B0=EF=B8=8F=20move=20examples=20?= =?UTF-8?q?to=20docs=20in=20future?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/addGuildAndGuildOwner.ts | 37 ------------------------- examples/createGuildCounter.ts | 24 ----------------- examples/createGuildMember.ts | 40 ---------------------------- examples/deleteGuildCounter.ts | 6 ----- examples/deleteGuildMember.ts | 11 -------- examples/dropGuild.ts | 18 ------------- examples/findUniqueChannelCounter.ts | 8 ------ examples/getGuildMember.ts | 11 -------- examples/updateGuildCounter.ts | 13 --------- 9 files changed, 168 deletions(-) delete mode 100644 examples/addGuildAndGuildOwner.ts delete mode 100644 examples/createGuildCounter.ts delete mode 100644 examples/createGuildMember.ts delete mode 100644 examples/deleteGuildCounter.ts delete mode 100644 examples/deleteGuildMember.ts delete mode 100644 examples/dropGuild.ts delete mode 100644 examples/findUniqueChannelCounter.ts delete mode 100644 examples/getGuildMember.ts delete mode 100644 examples/updateGuildCounter.ts diff --git a/examples/addGuildAndGuildOwner.ts b/examples/addGuildAndGuildOwner.ts deleted file mode 100644 index 153ce38..0000000 --- a/examples/addGuildAndGuildOwner.ts +++ /dev/null @@ -1,37 +0,0 @@ -const ownerId = "SNOWFLAKE"; -const guildId = "SNOWFLAKE"; - -// Create guildMember object -const createGuildMember = await prisma.guildMember.upsert({ - where: { - userId_guildId: { - userId: ownerId, - guildId, - }, - }, - update: {}, - create: { - user: { - connectOrCreate: { - create: { - id: ownerId, - }, - where: { - id: ownerId, - }, - }, - }, - guild: { - connectOrCreate: { - create: { - id: guildId, - }, - where: { - id: guildId, - }, - }, - }, - }, -}); - -logger.silly(createGuildMember); diff --git a/examples/createGuildCounter.ts b/examples/createGuildCounter.ts deleted file mode 100644 index 0f87938..0000000 --- a/examples/createGuildCounter.ts +++ /dev/null @@ -1,24 +0,0 @@ -const createGuildCounter = await prisma.guildCounter.upsert({ - where: { - guildId_channelId: { - guildId: guild.id, - channelId: discordChannel.id, - }, - }, - update: {}, - create: { - channelId: discordChannel.id, - triggerWord, - count: startValue || 0, - guild: { - connectOrCreate: { - create: { - id: guild.id, - }, - where: { - id: guild.id, - }, - }, - }, - }, -}); diff --git a/examples/createGuildMember.ts b/examples/createGuildMember.ts deleted file mode 100644 index 9522981..0000000 --- a/examples/createGuildMember.ts +++ /dev/null @@ -1,40 +0,0 @@ -const userId = "SNOWFLKAE"; -const guildId = "SNOWFLAKE"; - -const createGuildMember = await prisma.guildMember.upsert({ - where: { - userId_guildId: { - userId, - guildId, - }, - }, - update: {}, - create: { - user: { - connectOrCreate: { - create: { - id: userId, - }, - where: { - id: userId, - }, - }, - }, - guild: { - connectOrCreate: { - create: { - id: guildId, - }, - where: { - id: guildId, - }, - }, - }, - }, - include: { - user: true, - guild: true, - }, -}); - -console.log(createGuildMember); diff --git a/examples/deleteGuildCounter.ts b/examples/deleteGuildCounter.ts deleted file mode 100644 index c004152..0000000 --- a/examples/deleteGuildCounter.ts +++ /dev/null @@ -1,6 +0,0 @@ -const deleteGuildCounter = await prisma.guildCounter.deleteMany({ - where: { - guildId: guild.id, - channelId: discordChannel.id, - }, -}); diff --git a/examples/deleteGuildMember.ts b/examples/deleteGuildMember.ts deleted file mode 100644 index c3e2fd0..0000000 --- a/examples/deleteGuildMember.ts +++ /dev/null @@ -1,11 +0,0 @@ -const userId = "SNOWFLAKE"; -const guildId = "SNOWFLAKE"; - -const deleteGuildMember = await prisma.guildMember.deleteMany({ - where: { - userId, - guildId, - }, -}); - -console.log(deleteGuildMember); diff --git a/examples/dropGuild.ts b/examples/dropGuild.ts deleted file mode 100644 index 0e23066..0000000 --- a/examples/dropGuild.ts +++ /dev/null @@ -1,18 +0,0 @@ -const guildId = "SNOWFLAKE"; - -// Delete guildMember objects -const deleteGuildMembers = prisma.guildMember.deleteMany({ - where: { - guildId, - }, -}); - -// Delete guild object -const deleteGuild = prisma.guild.deleteMany({ - where: { - id: guildId, - }, -}); - -// The transaction runs synchronously so deleteUsers must run last. -await prisma.$transaction([deleteGuildMembers, deleteGuild]); diff --git a/examples/findUniqueChannelCounter.ts b/examples/findUniqueChannelCounter.ts deleted file mode 100644 index 2639bce..0000000 --- a/examples/findUniqueChannelCounter.ts +++ /dev/null @@ -1,8 +0,0 @@ -const channelCounter = await prisma.guildCounter.findUnique({ - where: { - guildId_channelId: { - guildId: guild.id, - channelId: discordChannel.id, - }, - }, -}); diff --git a/examples/getGuildMember.ts b/examples/getGuildMember.ts deleted file mode 100644 index a60c21a..0000000 --- a/examples/getGuildMember.ts +++ /dev/null @@ -1,11 +0,0 @@ -const getGuildMember = await prisma.guildMember.findUnique({ - where: { - userId_guildId: { - userId: author.id, - guildId: guild.id, - }, - }, - include: { - guild: true, - }, -}); diff --git a/examples/updateGuildCounter.ts b/examples/updateGuildCounter.ts deleted file mode 100644 index 2f53489..0000000 --- a/examples/updateGuildCounter.ts +++ /dev/null @@ -1,13 +0,0 @@ -const updateGuildCounter = await prisma.guildCounter.update({ - where: { - guildId_channelId: { - guildId: guild.id, - channelId: channel.id, - }, - }, - data: { - count: { - increment: 1, - }, - }, -}); From 3ba9b204d4b1d75565acabb207df85344edad982 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 20:09:50 +0200 Subject: [PATCH 207/215] =?UTF-8?q?=F0=9F=9A=A8=20Fixed=20JS-0066?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/helpers/transferCredits/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/transferCredits/index.ts b/src/helpers/transferCredits/index.ts index f349b4b..46dcf8e 100644 --- a/src/helpers/transferCredits/index.ts +++ b/src/helpers/transferCredits/index.ts @@ -91,7 +91,7 @@ export default async (guild: Guild, from: User, to: User, amount: number) => { }, }, }, - creditsEarned: +amount, + creditsEarned: amount, }, where: { userId_guildId: { From 810fabc79481c220fe7e976f08216c708b00fe09 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 20:14:14 +0200 Subject: [PATCH 208/215] =?UTF-8?q?=F0=9F=9A=A8=20Fixed=20some=20JS-C1003?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.ts | 12 ++++++------ src/schedules/shop/index.ts | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/index.ts b/src/index.ts index b65b076..3d1cefe 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,8 @@ import { Client, Collection, GatewayIntentBits } from "discord.js"; // discord.js import "dotenv/config"; -import * as command from "./handlers/command"; -import * as event from "./handlers/event"; -import * as schedule from "./handlers/schedule"; +import { register as commandRegister } from "./handlers/command"; +import { register as eventRegister } from "./handlers/event"; +import { start as scheduleStart } from "./handlers/schedule"; // Main process that starts all other sub processes const main = async () => { @@ -19,9 +19,9 @@ const main = async () => { // Create command collection client.commands = new Collection(); - await schedule.start(client); - await event.register(client); - await command.register(client); + await scheduleStart(client); + await eventRegister(client); + await commandRegister(client); // Authorize with Discord's API await client.login(process.env.DISCORD_TOKEN); diff --git a/src/schedules/shop/index.ts b/src/schedules/shop/index.ts index b2ef366..b1782c2 100644 --- a/src/schedules/shop/index.ts +++ b/src/schedules/shop/index.ts @@ -1,12 +1,12 @@ // Dependencies import { Client } from "discord.js"; -import * as roles from "./modules/roles"; +import { execute as RolesExecute } from "./modules/roles"; export const options = { schedule: "*/5 * * * *", // https://crontab.guru/ }; export const execute = async (client: Client) => { - await roles.execute(client); + await RolesExecute(client); }; From 6be605a8e3413fe1dea79525d8e5906faa033ed3 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 20:19:04 +0200 Subject: [PATCH 209/215] =?UTF-8?q?=F0=9F=9A=A8=20Fixed=20some=20JS-0116?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/events/guildCreate/index.ts | 2 +- src/events/guildDelete/index.ts | 2 +- src/events/guildMemberAdd/index.ts | 2 +- src/events/guildMemberRemove/index.ts | 2 +- src/events/ready/index.ts | 2 +- src/handlers/cooldown/index.ts | 6 +++--- src/handlers/deployCommands/index.ts | 8 +------- src/handlers/devMode/index.ts | 4 ++-- src/handlers/updatePresence/index.ts | 2 +- src/helpers/addSeconds/index.ts | 2 +- src/helpers/checkDirectory/index.ts | 3 ++- src/schedules/timeouts/index.ts | 2 +- 12 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/events/guildCreate/index.ts b/src/events/guildCreate/index.ts index 7250535..3d69ad2 100644 --- a/src/events/guildCreate/index.ts +++ b/src/events/guildCreate/index.ts @@ -11,7 +11,7 @@ export const options: IEventOptions = { export const execute = async (guild: Guild) => { const { client } = guild; - await updatePresence(client); + updatePresence(client); // Create guildMember object const createGuildMember = await prisma.guildMember.upsert({ diff --git a/src/events/guildDelete/index.ts b/src/events/guildDelete/index.ts index 3258d70..dee5dc2 100644 --- a/src/events/guildDelete/index.ts +++ b/src/events/guildDelete/index.ts @@ -12,7 +12,7 @@ export const options: IEventOptions = { export const execute = async (guild: Guild) => { const { client } = guild; - await updatePresence(client); + updatePresence(client); // Delete guildMember objects const deleteGuildMembers = prisma.guildMember.deleteMany({ diff --git a/src/events/guildMemberAdd/index.ts b/src/events/guildMemberAdd/index.ts index 2777b78..9296d4f 100644 --- a/src/events/guildMemberAdd/index.ts +++ b/src/events/guildMemberAdd/index.ts @@ -20,7 +20,7 @@ export const execute = async (member: GuildMember) => { await audits.execute(member); await joinMessage.execute(member); - await updatePresence(client); + updatePresence(client); // Create guildMember object const createGuildMember = await prisma.guildMember.upsert({ diff --git a/src/events/guildMemberRemove/index.ts b/src/events/guildMemberRemove/index.ts index 7306b25..da262ba 100644 --- a/src/events/guildMemberRemove/index.ts +++ b/src/events/guildMemberRemove/index.ts @@ -20,7 +20,7 @@ export const execute = async (member: GuildMember) => { await audits.execute(member); await leaveMessage.execute(member); - await updatePresence(client); + updatePresence(client); // Delete guildMember object const deleteGuildMember = await prisma.guildMember.deleteMany({ diff --git a/src/events/ready/index.ts b/src/events/ready/index.ts index d292d43..efb0c36 100644 --- a/src/events/ready/index.ts +++ b/src/events/ready/index.ts @@ -14,7 +14,7 @@ export const options: IEventOptions = { export const execute = async (client: Client) => { logger.info("Discord's API client is ready!"); - await updatePresence(client); + updatePresence(client); await devMode(client); await deployCommands(client); }; diff --git a/src/handlers/cooldown/index.ts b/src/handlers/cooldown/index.ts index cf443cb..e9b705c 100644 --- a/src/handlers/cooldown/index.ts +++ b/src/handlers/cooldown/index.ts @@ -25,7 +25,7 @@ export const command = async (i: CommandInteraction, cooldown: number) => { // If user is not on timeout if (hasTimeout) { const { userId, timeoutId, createdAt } = hasTimeout; - const overDue = (await addSeconds(cooldown, createdAt)) < new Date(); + const overDue = addSeconds(cooldown, createdAt) < new Date(); if (!overDue) { const diff = Math.round( @@ -115,7 +115,7 @@ export const button = async (i: ButtonInteraction, cooldown: number) => { // If user is not on timeout if (hasTimeout) { const { userId, timeoutId, createdAt } = hasTimeout; - const overDue = (await addSeconds(cooldown, createdAt)) < new Date(); + const overDue = addSeconds(cooldown, createdAt) < new Date(); if (!overDue) { const diff = Math.round( @@ -206,7 +206,7 @@ export const message = async (msg: Message, cooldown: number, id: string) => { // If user is not on timeout if (hasTimeout) { const { userId, timeoutId, createdAt } = hasTimeout; - const overDue = (await addSeconds(cooldown, createdAt)) < new Date(); + const overDue = addSeconds(cooldown, createdAt) < new Date(); if (!overDue) { const diff = Math.round( diff --git a/src/handlers/deployCommands/index.ts b/src/handlers/deployCommands/index.ts index c8d175e..da16d33 100644 --- a/src/handlers/deployCommands/index.ts +++ b/src/handlers/deployCommands/index.ts @@ -30,17 +30,11 @@ export default async (client: Client) => { .set(commandList, process.env.DISCORD_GUILD_ID) .then(async () => { logger.info(`Finished updating command list.`); - }) - .catch(async (error) => { - logger.error(`${error}`); }); if (process.env.NODE_ENV !== "production") { await client.application?.commands .set(commandList) - .then(async () => logger.info(`Finished updating guild command list.`)) - .catch(async (error) => { - logger.error(`${error}`); - }); + .then(async () => logger.info(`Finished updating guild command list.`)); } }; diff --git a/src/handlers/devMode/index.ts b/src/handlers/devMode/index.ts index 6757156..1c69b66 100644 --- a/src/handlers/devMode/index.ts +++ b/src/handlers/devMode/index.ts @@ -3,9 +3,9 @@ import logger from "../../middlewares/logger"; export default async (client: Client) => { if (process.env.NODE_ENV !== "production") { - return client?.application?.commands + await client?.application?.commands ?.set([], process.env.DISCORD_GUILD_ID) - .then(async () => { + .then(() => { return logger.verbose(`Development mode is disabled.`); }); } diff --git a/src/handlers/updatePresence/index.ts b/src/handlers/updatePresence/index.ts index e3fbe34..55a7d95 100644 --- a/src/handlers/updatePresence/index.ts +++ b/src/handlers/updatePresence/index.ts @@ -3,7 +3,7 @@ import { ActivityType, Client } from "discord.js"; import logger from "../../middlewares/logger"; // Function -export default async (client: Client) => { +export default (client: Client) => { if (!client?.user) throw new Error("Client's user is undefined."); const { guilds } = client; diff --git a/src/helpers/addSeconds/index.ts b/src/helpers/addSeconds/index.ts index 6c47b18..baa7d83 100644 --- a/src/helpers/addSeconds/index.ts +++ b/src/helpers/addSeconds/index.ts @@ -1,4 +1,4 @@ -export default async (seconds: number, date: Date) => { +export default (seconds: number, date: Date) => { date.setSeconds(date.getSeconds() + seconds); return date; }; diff --git a/src/helpers/checkDirectory/index.ts b/src/helpers/checkDirectory/index.ts index d70afc5..30fa6bc 100644 --- a/src/helpers/checkDirectory/index.ts +++ b/src/helpers/checkDirectory/index.ts @@ -2,5 +2,6 @@ import fs from "fs"; const fsPromises = fs.promises; export default async (path: string) => { - return fsPromises.readdir(path); + const result = fsPromises.readdir(path); + return result; }; diff --git a/src/schedules/timeouts/index.ts b/src/schedules/timeouts/index.ts index 764d825..9964892 100644 --- a/src/schedules/timeouts/index.ts +++ b/src/schedules/timeouts/index.ts @@ -16,7 +16,7 @@ export const execute = async () => { for await (const timeout of getCooldown) { const { guildId, userId, timeoutId, cooldown, createdAt } = timeout; - const overDue = (await addSeconds(cooldown, createdAt)) < new Date(); + const overDue = addSeconds(cooldown, createdAt) < new Date(); if (overDue) { logger.info(timeout); From f34cf8dd91f093807c21c6d899779ee7e7fcf867 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 20:21:15 +0200 Subject: [PATCH 210/215] =?UTF-8?q?=F0=9F=9A=A8=20Fixed=20more=20JS-0116?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/handlers/deployCommands/index.ts | 10 +++++----- src/helpers/checkDirectory/index.ts | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/handlers/deployCommands/index.ts b/src/handlers/deployCommands/index.ts index da16d33..4b30c96 100644 --- a/src/handlers/deployCommands/index.ts +++ b/src/handlers/deployCommands/index.ts @@ -13,28 +13,28 @@ export default async (client: Client) => { logger.info("Gathering command list"); await Promise.all( - client.commands.map(async (commandData: ICommand) => { + client.commands.map((commandData: ICommand) => { commandList.push(commandData.builder.toJSON()); logger.verbose(`${commandData.builder.name} pushed to list`); }) ) - .then(async () => { + .then(() => { logger.info(`Finished gathering command list.`); }) - .catch(async (error) => { + .catch((error) => { throw new Error(`Could not gather command list: ${error}`); }); await client.application?.commands .set(commandList, process.env.DISCORD_GUILD_ID) - .then(async () => { + .then(() => { logger.info(`Finished updating command list.`); }); if (process.env.NODE_ENV !== "production") { await client.application?.commands .set(commandList) - .then(async () => logger.info(`Finished updating guild command list.`)); + .then(() => logger.info(`Finished updating guild command list.`)); } }; diff --git a/src/helpers/checkDirectory/index.ts b/src/helpers/checkDirectory/index.ts index 30fa6bc..de33ba1 100644 --- a/src/helpers/checkDirectory/index.ts +++ b/src/helpers/checkDirectory/index.ts @@ -2,6 +2,6 @@ import fs from "fs"; const fsPromises = fs.promises; export default async (path: string) => { - const result = fsPromises.readdir(path); + const result = await fsPromises.readdir(path); return result; }; From 426eb7a85c1e7164d0840928d878e7988db04c48 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 20:24:05 +0200 Subject: [PATCH 211/215] =?UTF-8?q?=F0=9F=9A=A8=20Fixed=20more=20code=20sm?= =?UTF-8?q?ells=20(JS-D1001)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/events/guildCreate/index.ts | 1 + src/events/guildDelete/index.ts | 1 + src/events/guildMemberAdd/index.ts | 1 + src/events/guildMemberRemove/index.ts | 1 + src/events/ready/index.ts | 1 + src/handlers/cooldown/index.ts | 3 +++ src/schedules/shop/index.ts | 1 + 7 files changed, 9 insertions(+) diff --git a/src/events/guildCreate/index.ts b/src/events/guildCreate/index.ts index 3d69ad2..42653b0 100644 --- a/src/events/guildCreate/index.ts +++ b/src/events/guildCreate/index.ts @@ -8,6 +8,7 @@ export const options: IEventOptions = { type: "on", }; +// Execute the function export const execute = async (guild: Guild) => { const { client } = guild; diff --git a/src/events/guildDelete/index.ts b/src/events/guildDelete/index.ts index dee5dc2..3bac8bd 100644 --- a/src/events/guildDelete/index.ts +++ b/src/events/guildDelete/index.ts @@ -9,6 +9,7 @@ export const options: IEventOptions = { type: "on", }; +// Execute the function export const execute = async (guild: Guild) => { const { client } = guild; diff --git a/src/events/guildMemberAdd/index.ts b/src/events/guildMemberAdd/index.ts index 9296d4f..fc71e62 100644 --- a/src/events/guildMemberAdd/index.ts +++ b/src/events/guildMemberAdd/index.ts @@ -11,6 +11,7 @@ export const options: IEventOptions = { type: "on", }; +// Execute the function export const execute = async (member: GuildMember) => { const { client, user, guild } = member; diff --git a/src/events/guildMemberRemove/index.ts b/src/events/guildMemberRemove/index.ts index da262ba..bbe61ad 100644 --- a/src/events/guildMemberRemove/index.ts +++ b/src/events/guildMemberRemove/index.ts @@ -11,6 +11,7 @@ export const options: IEventOptions = { type: "on", }; +// Execute the function export const execute = async (member: GuildMember) => { const { client, user, guild } = member; diff --git a/src/events/ready/index.ts b/src/events/ready/index.ts index efb0c36..b91a36a 100644 --- a/src/events/ready/index.ts +++ b/src/events/ready/index.ts @@ -11,6 +11,7 @@ export const options: IEventOptions = { type: "once", }; +// Execute the event export const execute = async (client: Client) => { logger.info("Discord's API client is ready!"); diff --git a/src/handlers/cooldown/index.ts b/src/handlers/cooldown/index.ts index e9b705c..6721ccd 100644 --- a/src/handlers/cooldown/index.ts +++ b/src/handlers/cooldown/index.ts @@ -4,6 +4,7 @@ import addSeconds from "../../helpers/addSeconds"; import logger from "../../middlewares/logger"; import prisma from "../database"; +// Command cooldown export const command = async (i: CommandInteraction, cooldown: number) => { const { guild, user, commandId } = i; @@ -94,6 +95,7 @@ export const command = async (i: CommandInteraction, cooldown: number) => { logger.silly(createCooldown); }; +// Button cooldown export const button = async (i: ButtonInteraction, cooldown: number) => { const { guild, user, customId } = i; @@ -184,6 +186,7 @@ export const button = async (i: ButtonInteraction, cooldown: number) => { logger.silly(createCooldown); }; +// Message cooldown export const message = async (msg: Message, cooldown: number, id: string) => { const { guild, member } = msg; diff --git a/src/schedules/shop/index.ts b/src/schedules/shop/index.ts index b1782c2..c99a542 100644 --- a/src/schedules/shop/index.ts +++ b/src/schedules/shop/index.ts @@ -7,6 +7,7 @@ export const options = { schedule: "*/5 * * * *", // https://crontab.guru/ }; +// Execute the function export const execute = async (client: Client) => { await RolesExecute(client); }; From 9f107b280dd7178cbf3735c6cb13d5824d2cdb09 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 20:30:50 +0200 Subject: [PATCH 212/215] =?UTF-8?q?=F0=9F=9A=A8=20Fixed=20some=20code=20sm?= =?UTF-8?q?ells=20for=20JS-0116=20&=20JS-D1001?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/buttons/primary/index.ts | 3 ++- src/events/messageCreate/index.ts | 1 + src/events/messageDelete/index.ts | 1 + src/events/messageUpdate/index.ts | 1 + src/handlers/schedule/index.ts | 1 + src/helpers/encryption/index.ts | 2 ++ 6 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/buttons/primary/index.ts b/src/buttons/primary/index.ts index d80ddb3..6e95e0e 100644 --- a/src/buttons/primary/index.ts +++ b/src/buttons/primary/index.ts @@ -3,6 +3,7 @@ import logger from "../../middlewares/logger"; export const metadata = { guildOnly: false, ephemeral: false }; -export const execute = async (interaction: ButtonInteraction) => { +// Execute the function +export const execute = (interaction: ButtonInteraction) => { logger.debug(interaction.customId, "primary button clicked!"); }; diff --git a/src/events/messageCreate/index.ts b/src/events/messageCreate/index.ts index 0cacfc8..6a745cc 100644 --- a/src/events/messageCreate/index.ts +++ b/src/events/messageCreate/index.ts @@ -6,6 +6,7 @@ export const options: IEventOptions = { type: "on", }; +// Execute the function export const execute = async (message: Message) => { await modules.credits.execute(message); await modules.points.execute(message); diff --git a/src/events/messageDelete/index.ts b/src/events/messageDelete/index.ts index 9e3b973..53ccb2d 100644 --- a/src/events/messageDelete/index.ts +++ b/src/events/messageDelete/index.ts @@ -7,6 +7,7 @@ export const options: IEventOptions = { type: "on", }; +// Execute the function export const execute = async (message: Message) => { await audits.execute(message); await counter(message); diff --git a/src/events/messageUpdate/index.ts b/src/events/messageUpdate/index.ts index 07f5297..80d3c06 100644 --- a/src/events/messageUpdate/index.ts +++ b/src/events/messageUpdate/index.ts @@ -12,6 +12,7 @@ export const options: IEventOptions = { type: "on", }; +// Execute the function export const execute = async (oldMessage: Message, newMessage: Message) => { const { author, guild } = newMessage; diff --git a/src/handlers/schedule/index.ts b/src/handlers/schedule/index.ts index b3b3e2f..da2c37d 100644 --- a/src/handlers/schedule/index.ts +++ b/src/handlers/schedule/index.ts @@ -4,6 +4,7 @@ import checkDirectory from "../../helpers/checkDirectory"; import { IJob } from "../../interfaces/Job"; import logger from "../../middlewares/logger"; +// Start all jobs that are in the schedules directory export const start = async (client: Client) => { logger.info("⏰ Started job management"); diff --git a/src/helpers/encryption/index.ts b/src/helpers/encryption/index.ts index 0e1c027..1b9fc34 100644 --- a/src/helpers/encryption/index.ts +++ b/src/helpers/encryption/index.ts @@ -3,6 +3,7 @@ import { IEncryptionData } from "../../interfaces/EncryptionData"; const iv = crypto.randomBytes(16); +// Encrypts a string const encrypt = (text: crypto.BinaryLike): IEncryptionData => { const cipher = crypto.createCipheriv( process.env.ENCRYPTION_ALGORITHM, @@ -17,6 +18,7 @@ const encrypt = (text: crypto.BinaryLike): IEncryptionData => { }; }; +// Decrypts a string const decrypt = (hash: IEncryptionData) => { const decipher = crypto.createDecipheriv( process.env.ENCRYPTION_ALGORITHM, From 877bdbdb1d6a51e56a0cf54b8b76592b4dbcd4a2 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 20:31:32 +0200 Subject: [PATCH 213/215] Merge branch 'dev' of https://github.com/vermiumsifell/xyter into dev --- prisma/.gitignore | 2 +- .../migration.sql | 3 +- .../migration.sql | 33 ++- .../migration.sql | 29 ++- .../migration.sql | 29 ++- .../migration.sql | 194 ++++++++++++++---- .../migration.sql | 194 ++++++++++++++---- prisma/migrations/migration_lock.toml | 2 +- src/handlers/database/index.ts | 2 +- 9 files changed, 386 insertions(+), 102 deletions(-) diff --git a/prisma/.gitignore b/prisma/.gitignore index 03f6f26..87f333a 100644 --- a/prisma/.gitignore +++ b/prisma/.gitignore @@ -1,2 +1,2 @@ *.db -*.db-journal \ No newline at end of file +*.db-journal diff --git a/prisma/migrations/20221021150615_shoproles_model/migration.sql b/prisma/migrations/20221021150615_shoproles_model/migration.sql index 1859cc1..3d9bab2 100644 --- a/prisma/migrations/20221021150615_shoproles_model/migration.sql +++ b/prisma/migrations/20221021150615_shoproles_model/migration.sql @@ -13,4 +13,5 @@ CREATE TABLE "GuildShopRoles" ( ); -- CreateIndex -CREATE UNIQUE INDEX "GuildShopRoles_guildId_channelId_key" ON "GuildShopRoles"("guildId", "channelId"); + +CREATE UNIQUE INDEX "GuildShopRoles_guildId_channelId_key" ON "GuildShopRoles" ("guildId", "channelId"); diff --git a/prisma/migrations/20221021151136_shoproles_model_correction/migration.sql b/prisma/migrations/20221021151136_shoproles_model_correction/migration.sql index 5631656..f3a4e3a 100644 --- a/prisma/migrations/20221021151136_shoproles_model_correction/migration.sql +++ b/prisma/migrations/20221021151136_shoproles_model_correction/migration.sql @@ -1,11 +1,12 @@ /* - Warnings: + Warnings: - - You are about to drop the column `channelId` on the `GuildShopRoles` table. All the data in the column will be lost. - -*/ + - You are about to drop the column `channelId` on the `GuildShopRoles` table. All the data in the column will be lost. + */ -- RedefineTables -PRAGMA foreign_keys=OFF; + +PRAGMA foreign_keys = OFF; + CREATE TABLE "new_GuildShopRoles" ( "guildId" TEXT NOT NULL, "roleId" TEXT NOT NULL, @@ -17,9 +18,25 @@ CREATE TABLE "new_GuildShopRoles" ( CONSTRAINT "GuildShopRoles_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "GuildShopRoles_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") SELECT "createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId" FROM "GuildShopRoles"; + +INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") +SELECT + "createdAt", + "guildId", + "lastPayed", + "pricePerHour", + "roleId", + "updatedAt", + "userId" +FROM + "GuildShopRoles"; + DROP TABLE "GuildShopRoles"; + ALTER TABLE "new_GuildShopRoles" RENAME TO "GuildShopRoles"; -CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles"("guildId", "userId", "roleId"); + +CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles" ("guildId", "userId", "roleId"); + PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; + +PRAGMA foreign_keys = ON; diff --git a/prisma/migrations/20221021151337_shoproles_model_correction/migration.sql b/prisma/migrations/20221021151337_shoproles_model_correction/migration.sql index 8a3fe75..52dc513 100644 --- a/prisma/migrations/20221021151337_shoproles_model_correction/migration.sql +++ b/prisma/migrations/20221021151337_shoproles_model_correction/migration.sql @@ -1,5 +1,6 @@ -- RedefineTables -PRAGMA foreign_keys=OFF; +PRAGMA foreign_keys = OFF; + CREATE TABLE "new_GuildShopRoles" ( "guildId" TEXT NOT NULL, "roleId" TEXT NOT NULL, @@ -10,11 +11,29 @@ CREATE TABLE "new_GuildShopRoles" ( "updatedAt" DATETIME NOT NULL, CONSTRAINT "GuildShopRoles_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "GuildShopRoles_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "GuildShopRoles_guildId_userId_fkey" FOREIGN KEY ("guildId", "userId") REFERENCES "GuildMember" ("guildId", "userId") ON DELETE RESTRICT ON UPDATE CASCADE + CONSTRAINT "GuildShopRoles_guildId_userId_fkey" FOREIGN KEY ("guildId", + "userId") REFERENCES "GuildMember" ("guildId", + "userId") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") SELECT "createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId" FROM "GuildShopRoles"; + +INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") +SELECT + "createdAt", + "guildId", + "lastPayed", + "pricePerHour", + "roleId", + "updatedAt", + "userId" +FROM + "GuildShopRoles"; + DROP TABLE "GuildShopRoles"; + ALTER TABLE "new_GuildShopRoles" RENAME TO "GuildShopRoles"; -CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles"("guildId", "userId", "roleId"); + +CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles" ("guildId", "userId", "roleId"); + PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; + +PRAGMA foreign_keys = ON; diff --git a/prisma/migrations/20221021153546_shoproles_model_correction/migration.sql b/prisma/migrations/20221021153546_shoproles_model_correction/migration.sql index 88d1d66..555cf58 100644 --- a/prisma/migrations/20221021153546_shoproles_model_correction/migration.sql +++ b/prisma/migrations/20221021153546_shoproles_model_correction/migration.sql @@ -1,5 +1,6 @@ -- RedefineTables -PRAGMA foreign_keys=OFF; +PRAGMA foreign_keys = OFF; + CREATE TABLE "new_GuildShopRoles" ( "guildId" TEXT NOT NULL, "roleId" TEXT NOT NULL, @@ -10,11 +11,29 @@ CREATE TABLE "new_GuildShopRoles" ( "updatedAt" DATETIME NOT NULL, CONSTRAINT "GuildShopRoles_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "GuildShopRoles_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "GuildShopRoles_userId_guildId_fkey" FOREIGN KEY ("userId", "guildId") REFERENCES "GuildMember" ("userId", "guildId") ON DELETE RESTRICT ON UPDATE CASCADE + CONSTRAINT "GuildShopRoles_userId_guildId_fkey" FOREIGN KEY ("userId", + "guildId") REFERENCES "GuildMember" ("userId", + "guildId") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") SELECT "createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId" FROM "GuildShopRoles"; + +INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") +SELECT + "createdAt", + "guildId", + "lastPayed", + "pricePerHour", + "roleId", + "updatedAt", + "userId" +FROM + "GuildShopRoles"; + DROP TABLE "GuildShopRoles"; + ALTER TABLE "new_GuildShopRoles" RENAME TO "GuildShopRoles"; -CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles"("guildId", "userId", "roleId"); + +CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles" ("guildId", "userId", "roleId"); + PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; + +PRAGMA foreign_keys = ON; diff --git a/prisma/migrations/20221021172156_int_to_bigint/migration.sql b/prisma/migrations/20221021172156_int_to_bigint/migration.sql index 187923d..8ba2555 100644 --- a/prisma/migrations/20221021172156_int_to_bigint/migration.sql +++ b/prisma/migrations/20221021172156_int_to_bigint/migration.sql @@ -1,25 +1,26 @@ /* - Warnings: + Warnings: - - You are about to alter the column `count` on the `GuildCounter` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `creditsEarned` on the `GuildMember` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `pointsEarned` on the `GuildMember` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `pricePerHour` on the `GuildShopRoles` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `cooldown` on the `Cooldown` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `creditsMinimumLength` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `creditsRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `creditsTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `creditsWorkRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `creditsWorkTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `pointsMinimumLength` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `pointsRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `pointsTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `shopRolesPricePerHour` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - - You are about to alter the column `reputationsEarned` on the `User` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. - -*/ + - You are about to alter the column `count` on the `GuildCounter` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `creditsEarned` on the `GuildMember` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `pointsEarned` on the `GuildMember` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `pricePerHour` on the `GuildShopRoles` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `cooldown` on the `Cooldown` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `creditsMinimumLength` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `creditsRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `creditsTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `creditsWorkRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `creditsWorkTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `pointsMinimumLength` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `pointsRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `pointsTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `shopRolesPricePerHour` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + - You are about to alter the column `reputationsEarned` on the `User` table. The data in that column could be lost. The data in that column will be cast from `Int` to `BigInt`. + */ -- RedefineTables -PRAGMA foreign_keys=OFF; + +PRAGMA foreign_keys = OFF; + CREATE TABLE "new_GuildCounter" ( "guildId" TEXT NOT NULL, "channelId" TEXT NOT NULL, @@ -29,10 +30,24 @@ CREATE TABLE "new_GuildCounter" ( "updatedAt" DATETIME NOT NULL, CONSTRAINT "GuildCounter_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_GuildCounter" ("channelId", "count", "createdAt", "guildId", "triggerWord", "updatedAt") SELECT "channelId", "count", "createdAt", "guildId", "triggerWord", "updatedAt" FROM "GuildCounter"; + +INSERT INTO "new_GuildCounter" ("channelId", "count", "createdAt", "guildId", "triggerWord", "updatedAt") +SELECT + "channelId", + "count", + "createdAt", + "guildId", + "triggerWord", + "updatedAt" +FROM + "GuildCounter"; + DROP TABLE "GuildCounter"; + ALTER TABLE "new_GuildCounter" RENAME TO "GuildCounter"; -CREATE UNIQUE INDEX "GuildCounter_guildId_channelId_key" ON "GuildCounter"("guildId", "channelId"); + +CREATE UNIQUE INDEX "GuildCounter_guildId_channelId_key" ON "GuildCounter" ("guildId", "channelId"); + CREATE TABLE "new_GuildMember" ( "userId" TEXT NOT NULL, "guildId" TEXT NOT NULL, @@ -43,10 +58,24 @@ CREATE TABLE "new_GuildMember" ( CONSTRAINT "GuildMember_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "GuildMember_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_GuildMember" ("createdAt", "creditsEarned", "guildId", "pointsEarned", "updatedAt", "userId") SELECT "createdAt", "creditsEarned", "guildId", "pointsEarned", "updatedAt", "userId" FROM "GuildMember"; + +INSERT INTO "new_GuildMember" ("createdAt", "creditsEarned", "guildId", "pointsEarned", "updatedAt", "userId") +SELECT + "createdAt", + "creditsEarned", + "guildId", + "pointsEarned", + "updatedAt", + "userId" +FROM + "GuildMember"; + DROP TABLE "GuildMember"; + ALTER TABLE "new_GuildMember" RENAME TO "GuildMember"; -CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember"("userId", "guildId"); + +CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember" ("userId", "guildId"); + CREATE TABLE "new_GuildShopRoles" ( "guildId" TEXT NOT NULL, "roleId" TEXT NOT NULL, @@ -57,12 +86,29 @@ CREATE TABLE "new_GuildShopRoles" ( "updatedAt" DATETIME NOT NULL, CONSTRAINT "GuildShopRoles_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "GuildShopRoles_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "GuildShopRoles_userId_guildId_fkey" FOREIGN KEY ("userId", "guildId") REFERENCES "GuildMember" ("userId", "guildId") ON DELETE RESTRICT ON UPDATE CASCADE + CONSTRAINT "GuildShopRoles_userId_guildId_fkey" FOREIGN KEY ("userId", + "guildId") REFERENCES "GuildMember" ("userId", + "guildId") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") SELECT "createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId" FROM "GuildShopRoles"; + +INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") +SELECT + "createdAt", + "guildId", + "lastPayed", + "pricePerHour", + "roleId", + "updatedAt", + "userId" +FROM + "GuildShopRoles"; + DROP TABLE "GuildShopRoles"; + ALTER TABLE "new_GuildShopRoles" RENAME TO "GuildShopRoles"; -CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles"("guildId", "userId", "roleId"); + +CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles" ("guildId", "userId", "roleId"); + CREATE TABLE "new_Cooldown" ( "guildId" TEXT NOT NULL, "userId" TEXT NOT NULL, @@ -73,10 +119,24 @@ CREATE TABLE "new_Cooldown" ( CONSTRAINT "Cooldown_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "Cooldown_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_Cooldown" ("cooldown", "createdAt", "guildId", "timeoutId", "updatedAt", "userId") SELECT "cooldown", "createdAt", "guildId", "timeoutId", "updatedAt", "userId" FROM "Cooldown"; + +INSERT INTO "new_Cooldown" ("cooldown", "createdAt", "guildId", "timeoutId", "updatedAt", "userId") +SELECT + "cooldown", + "createdAt", + "guildId", + "timeoutId", + "updatedAt", + "userId" +FROM + "Cooldown"; + DROP TABLE "Cooldown"; + ALTER TABLE "new_Cooldown" RENAME TO "Cooldown"; -CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown"("guildId", "userId", "timeoutId"); + +CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown" ("guildId", "userId", "timeoutId"); + CREATE TABLE "new_Guild" ( "id" TEXT NOT NULL, "embedColorSuccess" TEXT NOT NULL DEFAULT '#22bb33', @@ -84,27 +144,27 @@ CREATE TABLE "new_Guild" ( "embedColorError" TEXT NOT NULL DEFAULT '#bb2124', "embedFooterText" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg/xyter', "embedFooterIcon" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg.png', - "creditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "creditsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "creditsRate" BIGINT NOT NULL DEFAULT 1, "creditsTimeout" BIGINT NOT NULL DEFAULT 5, "creditsWorkRate" BIGINT NOT NULL DEFAULT 25, "creditsWorkTimeout" BIGINT NOT NULL DEFAULT 86400, "creditsMinimumLength" BIGINT NOT NULL DEFAULT 5, - "pointsEnabled" BOOLEAN NOT NULL DEFAULT false, + "pointsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "pointsRate" BIGINT NOT NULL DEFAULT 1, "pointsTimeout" BIGINT NOT NULL DEFAULT 5, "pointsMinimumLength" BIGINT NOT NULL DEFAULT 5, - "reputationsEnabled" BOOLEAN NOT NULL DEFAULT false, - "countersEnabled" BOOLEAN NOT NULL DEFAULT false, + "reputationsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, + "countersEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "apiCpggUrlIv" TEXT, "apiCpggUrlContent" TEXT, "apiCpggTokenIv" TEXT, "apiCpggTokenContent" TEXT, - "auditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "auditsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "auditsChannelId" TEXT, - "shopRolesEnabled" BOOLEAN NOT NULL DEFAULT false, + "shopRolesEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "shopRolesPricePerHour" BIGINT NOT NULL DEFAULT 5, - "welcomeEnabled" BOOLEAN NOT NULL DEFAULT false, + "welcomeEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "welcomeJoinChannelId" TEXT, "welcomeJoinChannelMessage" TEXT, "welcomeLeaveChannelId" TEXT, @@ -112,19 +172,73 @@ CREATE TABLE "new_Guild" ( "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" DATETIME NOT NULL ); -INSERT INTO "new_Guild" ("apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt", "welcomeEnabled", "welcomeJoinChannelId", "welcomeJoinChannelMessage", "welcomeLeaveChannelId", "welcomeLeaveChannelMessage") SELECT "apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt", "welcomeEnabled", "welcomeJoinChannelId", "welcomeJoinChannelMessage", "welcomeLeaveChannelId", "welcomeLeaveChannelMessage" FROM "Guild"; + +INSERT INTO "new_Guild" ("apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt", "welcomeEnabled", "welcomeJoinChannelId", "welcomeJoinChannelMessage", "welcomeLeaveChannelId", "welcomeLeaveChannelMessage") +SELECT + "apiCpggTokenContent", + "apiCpggTokenIv", + "apiCpggUrlContent", + "apiCpggUrlIv", + "auditsChannelId", + "auditsEnabled", + "countersEnabled", + "createdAt", + "creditsEnabled", + "creditsMinimumLength", + "creditsRate", + "creditsTimeout", + "creditsWorkRate", + "creditsWorkTimeout", + "embedColorError", + "embedColorSuccess", + "embedColorWait", + "embedFooterIcon", + "embedFooterText", + "id", + "pointsEnabled", + "pointsMinimumLength", + "pointsRate", + "pointsTimeout", + "reputationsEnabled", + "shopRolesEnabled", + "shopRolesPricePerHour", + "updatedAt", + "welcomeEnabled", + "welcomeJoinChannelId", + "welcomeJoinChannelMessage", + "welcomeLeaveChannelId", + "welcomeLeaveChannelMessage" +FROM + "Guild"; + DROP TABLE "Guild"; + ALTER TABLE "new_Guild" RENAME TO "Guild"; -CREATE UNIQUE INDEX "Guild_id_key" ON "Guild"("id"); + +CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); + CREATE TABLE "new_User" ( "id" TEXT NOT NULL, "reputationsEarned" BIGINT NOT NULL DEFAULT 0, "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" DATETIME NOT NULL ); -INSERT INTO "new_User" ("createdAt", "id", "reputationsEarned", "updatedAt") SELECT "createdAt", "id", "reputationsEarned", "updatedAt" FROM "User"; + +INSERT INTO "new_User" ("createdAt", "id", "reputationsEarned", "updatedAt") +SELECT + "createdAt", + "id", + "reputationsEarned", + "updatedAt" +FROM + "User"; + DROP TABLE "User"; + ALTER TABLE "new_User" RENAME TO "User"; -CREATE UNIQUE INDEX "User_id_key" ON "User"("id"); + +CREATE UNIQUE INDEX "User_id_key" ON "User" ("id"); + PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; + +PRAGMA foreign_keys = ON; diff --git a/prisma/migrations/20221021172345_bigint_to_int/migration.sql b/prisma/migrations/20221021172345_bigint_to_int/migration.sql index 978ac5c..29f4f08 100644 --- a/prisma/migrations/20221021172345_bigint_to_int/migration.sql +++ b/prisma/migrations/20221021172345_bigint_to_int/migration.sql @@ -1,35 +1,48 @@ /* - Warnings: + Warnings: - - You are about to alter the column `reputationsEarned` on the `User` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `count` on the `GuildCounter` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `creditsEarned` on the `GuildMember` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `pointsEarned` on the `GuildMember` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `pricePerHour` on the `GuildShopRoles` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `creditsMinimumLength` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `creditsRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `creditsTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `creditsWorkRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `creditsWorkTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `pointsMinimumLength` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `pointsRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `pointsTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `shopRolesPricePerHour` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - - You are about to alter the column `cooldown` on the `Cooldown` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. - -*/ + - You are about to alter the column `reputationsEarned` on the `User` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `count` on the `GuildCounter` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `creditsEarned` on the `GuildMember` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `pointsEarned` on the `GuildMember` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `pricePerHour` on the `GuildShopRoles` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `creditsMinimumLength` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `creditsRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `creditsTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `creditsWorkRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `creditsWorkTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `pointsMinimumLength` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `pointsRate` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `pointsTimeout` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `shopRolesPricePerHour` on the `Guild` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + - You are about to alter the column `cooldown` on the `Cooldown` table. The data in that column could be lost. The data in that column will be cast from `BigInt` to `Int`. + */ -- RedefineTables -PRAGMA foreign_keys=OFF; + +PRAGMA foreign_keys = OFF; + CREATE TABLE "new_User" ( "id" TEXT NOT NULL, "reputationsEarned" INTEGER NOT NULL DEFAULT 0, "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" DATETIME NOT NULL ); -INSERT INTO "new_User" ("createdAt", "id", "reputationsEarned", "updatedAt") SELECT "createdAt", "id", "reputationsEarned", "updatedAt" FROM "User"; + +INSERT INTO "new_User" ("createdAt", "id", "reputationsEarned", "updatedAt") +SELECT + "createdAt", + "id", + "reputationsEarned", + "updatedAt" +FROM + "User"; + DROP TABLE "User"; + ALTER TABLE "new_User" RENAME TO "User"; -CREATE UNIQUE INDEX "User_id_key" ON "User"("id"); + +CREATE UNIQUE INDEX "User_id_key" ON "User" ("id"); + CREATE TABLE "new_GuildCounter" ( "guildId" TEXT NOT NULL, "channelId" TEXT NOT NULL, @@ -39,10 +52,24 @@ CREATE TABLE "new_GuildCounter" ( "updatedAt" DATETIME NOT NULL, CONSTRAINT "GuildCounter_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_GuildCounter" ("channelId", "count", "createdAt", "guildId", "triggerWord", "updatedAt") SELECT "channelId", "count", "createdAt", "guildId", "triggerWord", "updatedAt" FROM "GuildCounter"; + +INSERT INTO "new_GuildCounter" ("channelId", "count", "createdAt", "guildId", "triggerWord", "updatedAt") +SELECT + "channelId", + "count", + "createdAt", + "guildId", + "triggerWord", + "updatedAt" +FROM + "GuildCounter"; + DROP TABLE "GuildCounter"; + ALTER TABLE "new_GuildCounter" RENAME TO "GuildCounter"; -CREATE UNIQUE INDEX "GuildCounter_guildId_channelId_key" ON "GuildCounter"("guildId", "channelId"); + +CREATE UNIQUE INDEX "GuildCounter_guildId_channelId_key" ON "GuildCounter" ("guildId", "channelId"); + CREATE TABLE "new_GuildMember" ( "userId" TEXT NOT NULL, "guildId" TEXT NOT NULL, @@ -53,10 +80,24 @@ CREATE TABLE "new_GuildMember" ( CONSTRAINT "GuildMember_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "GuildMember_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_GuildMember" ("createdAt", "creditsEarned", "guildId", "pointsEarned", "updatedAt", "userId") SELECT "createdAt", "creditsEarned", "guildId", "pointsEarned", "updatedAt", "userId" FROM "GuildMember"; + +INSERT INTO "new_GuildMember" ("createdAt", "creditsEarned", "guildId", "pointsEarned", "updatedAt", "userId") +SELECT + "createdAt", + "creditsEarned", + "guildId", + "pointsEarned", + "updatedAt", + "userId" +FROM + "GuildMember"; + DROP TABLE "GuildMember"; + ALTER TABLE "new_GuildMember" RENAME TO "GuildMember"; -CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember"("userId", "guildId"); + +CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember" ("userId", "guildId"); + CREATE TABLE "new_GuildShopRoles" ( "guildId" TEXT NOT NULL, "roleId" TEXT NOT NULL, @@ -67,12 +108,29 @@ CREATE TABLE "new_GuildShopRoles" ( "updatedAt" DATETIME NOT NULL, CONSTRAINT "GuildShopRoles_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "GuildShopRoles_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "GuildShopRoles_userId_guildId_fkey" FOREIGN KEY ("userId", "guildId") REFERENCES "GuildMember" ("userId", "guildId") ON DELETE RESTRICT ON UPDATE CASCADE + CONSTRAINT "GuildShopRoles_userId_guildId_fkey" FOREIGN KEY ("userId", + "guildId") REFERENCES "GuildMember" ("userId", + "guildId") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") SELECT "createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId" FROM "GuildShopRoles"; + +INSERT INTO "new_GuildShopRoles" ("createdAt", "guildId", "lastPayed", "pricePerHour", "roleId", "updatedAt", "userId") +SELECT + "createdAt", + "guildId", + "lastPayed", + "pricePerHour", + "roleId", + "updatedAt", + "userId" +FROM + "GuildShopRoles"; + DROP TABLE "GuildShopRoles"; + ALTER TABLE "new_GuildShopRoles" RENAME TO "GuildShopRoles"; -CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles"("guildId", "userId", "roleId"); + +CREATE UNIQUE INDEX "GuildShopRoles_guildId_userId_roleId_key" ON "GuildShopRoles" ("guildId", "userId", "roleId"); + CREATE TABLE "new_Guild" ( "id" TEXT NOT NULL, "embedColorSuccess" TEXT NOT NULL DEFAULT '#22bb33', @@ -80,27 +138,27 @@ CREATE TABLE "new_Guild" ( "embedColorError" TEXT NOT NULL DEFAULT '#bb2124', "embedFooterText" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg/xyter', "embedFooterIcon" TEXT NOT NULL DEFAULT 'https://github.com/ZynerOrg.png', - "creditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "creditsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "creditsRate" INTEGER NOT NULL DEFAULT 1, "creditsTimeout" INTEGER NOT NULL DEFAULT 5, "creditsWorkRate" INTEGER NOT NULL DEFAULT 25, "creditsWorkTimeout" INTEGER NOT NULL DEFAULT 86400, "creditsMinimumLength" INTEGER NOT NULL DEFAULT 5, - "pointsEnabled" BOOLEAN NOT NULL DEFAULT false, + "pointsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "pointsRate" INTEGER NOT NULL DEFAULT 1, "pointsTimeout" INTEGER NOT NULL DEFAULT 5, "pointsMinimumLength" INTEGER NOT NULL DEFAULT 5, - "reputationsEnabled" BOOLEAN NOT NULL DEFAULT false, - "countersEnabled" BOOLEAN NOT NULL DEFAULT false, + "reputationsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, + "countersEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "apiCpggUrlIv" TEXT, "apiCpggUrlContent" TEXT, "apiCpggTokenIv" TEXT, "apiCpggTokenContent" TEXT, - "auditsEnabled" BOOLEAN NOT NULL DEFAULT false, + "auditsEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "auditsChannelId" TEXT, - "shopRolesEnabled" BOOLEAN NOT NULL DEFAULT false, + "shopRolesEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "shopRolesPricePerHour" INTEGER NOT NULL DEFAULT 5, - "welcomeEnabled" BOOLEAN NOT NULL DEFAULT false, + "welcomeEnabled" BOOLEAN NOT NULL DEFAULT FALSE, "welcomeJoinChannelId" TEXT, "welcomeJoinChannelMessage" TEXT, "welcomeLeaveChannelId" TEXT, @@ -108,10 +166,51 @@ CREATE TABLE "new_Guild" ( "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" DATETIME NOT NULL ); -INSERT INTO "new_Guild" ("apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt", "welcomeEnabled", "welcomeJoinChannelId", "welcomeJoinChannelMessage", "welcomeLeaveChannelId", "welcomeLeaveChannelMessage") SELECT "apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt", "welcomeEnabled", "welcomeJoinChannelId", "welcomeJoinChannelMessage", "welcomeLeaveChannelId", "welcomeLeaveChannelMessage" FROM "Guild"; + +INSERT INTO "new_Guild" ("apiCpggTokenContent", "apiCpggTokenIv", "apiCpggUrlContent", "apiCpggUrlIv", "auditsChannelId", "auditsEnabled", "countersEnabled", "createdAt", "creditsEnabled", "creditsMinimumLength", "creditsRate", "creditsTimeout", "creditsWorkRate", "creditsWorkTimeout", "embedColorError", "embedColorSuccess", "embedColorWait", "embedFooterIcon", "embedFooterText", "id", "pointsEnabled", "pointsMinimumLength", "pointsRate", "pointsTimeout", "reputationsEnabled", "shopRolesEnabled", "shopRolesPricePerHour", "updatedAt", "welcomeEnabled", "welcomeJoinChannelId", "welcomeJoinChannelMessage", "welcomeLeaveChannelId", "welcomeLeaveChannelMessage") +SELECT + "apiCpggTokenContent", + "apiCpggTokenIv", + "apiCpggUrlContent", + "apiCpggUrlIv", + "auditsChannelId", + "auditsEnabled", + "countersEnabled", + "createdAt", + "creditsEnabled", + "creditsMinimumLength", + "creditsRate", + "creditsTimeout", + "creditsWorkRate", + "creditsWorkTimeout", + "embedColorError", + "embedColorSuccess", + "embedColorWait", + "embedFooterIcon", + "embedFooterText", + "id", + "pointsEnabled", + "pointsMinimumLength", + "pointsRate", + "pointsTimeout", + "reputationsEnabled", + "shopRolesEnabled", + "shopRolesPricePerHour", + "updatedAt", + "welcomeEnabled", + "welcomeJoinChannelId", + "welcomeJoinChannelMessage", + "welcomeLeaveChannelId", + "welcomeLeaveChannelMessage" +FROM + "Guild"; + DROP TABLE "Guild"; + ALTER TABLE "new_Guild" RENAME TO "Guild"; -CREATE UNIQUE INDEX "Guild_id_key" ON "Guild"("id"); + +CREATE UNIQUE INDEX "Guild_id_key" ON "Guild" ("id"); + CREATE TABLE "new_Cooldown" ( "guildId" TEXT NOT NULL, "userId" TEXT NOT NULL, @@ -122,9 +221,24 @@ CREATE TABLE "new_Cooldown" ( CONSTRAINT "Cooldown_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "Cooldown_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); -INSERT INTO "new_Cooldown" ("cooldown", "createdAt", "guildId", "timeoutId", "updatedAt", "userId") SELECT "cooldown", "createdAt", "guildId", "timeoutId", "updatedAt", "userId" FROM "Cooldown"; + +INSERT INTO "new_Cooldown" ("cooldown", "createdAt", "guildId", "timeoutId", "updatedAt", "userId") +SELECT + "cooldown", + "createdAt", + "guildId", + "timeoutId", + "updatedAt", + "userId" +FROM + "Cooldown"; + DROP TABLE "Cooldown"; + ALTER TABLE "new_Cooldown" RENAME TO "Cooldown"; -CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown"("guildId", "userId", "timeoutId"); + +CREATE UNIQUE INDEX "Cooldown_guildId_userId_timeoutId_key" ON "Cooldown" ("guildId", "userId", "timeoutId"); + PRAGMA foreign_key_check; -PRAGMA foreign_keys=ON; + +PRAGMA foreign_keys = ON; diff --git a/prisma/migrations/migration_lock.toml b/prisma/migrations/migration_lock.toml index e5e5c47..6fcf33d 100644 --- a/prisma/migrations/migration_lock.toml +++ b/prisma/migrations/migration_lock.toml @@ -1,3 +1,3 @@ # Please do not edit this file manually # It should be added in your version-control system (i.e. Git) -provider = "sqlite" \ No newline at end of file +provider = "sqlite" diff --git a/src/handlers/database/index.ts b/src/handlers/database/index.ts index 287669a..c4e22e4 100644 --- a/src/handlers/database/index.ts +++ b/src/handlers/database/index.ts @@ -1,3 +1,3 @@ import { PrismaClient } from '@prisma/client' -export default new PrismaClient() \ No newline at end of file +export default new PrismaClient() From bef79d427e6ed75716951a25b071279fca2485f8 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 20:36:23 +0200 Subject: [PATCH 214/215] =?UTF-8?q?=F0=9F=92=A1=20Start=20critical=20handl?= =?UTF-8?q?ers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/index.ts b/src/index.ts index 3d1cefe..57a693b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -19,6 +19,7 @@ const main = async () => { // Create command collection client.commands = new Collection(); + // Start critical handlers await scheduleStart(client); await eventRegister(client); await commandRegister(client); From bf80a4e50fd970996fc4d1f941cd4551440e04c2 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Fri, 21 Oct 2022 20:40:08 +0200 Subject: [PATCH 215/215] =?UTF-8?q?=F0=9F=92=A1=20Start=20main=20process?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/index.ts b/src/index.ts index 57a693b..b6d54c9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -28,4 +28,5 @@ const main = async () => { await client.login(process.env.DISCORD_TOKEN); }; +// Start main process main();