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; }