commit
a896a03966
50 changed files with 14057 additions and 2124 deletions
32
.env.example
32
.env.example
|
@ -1,30 +1,30 @@
|
|||
# THIS FILE SHOULD BE INSIDE OF build/
|
||||
# Do not use "around your text" ("")
|
||||
|
||||
# Discord
|
||||
DISCORD_TOKEN=""
|
||||
DISCORD_CLIENT_ID=""
|
||||
DISCORD_GUILD_ID=""
|
||||
DISCORD_TOKEN=
|
||||
DISCORD_CLIENT_ID=
|
||||
DISCORD_GUILD_ID=
|
||||
|
||||
# Database
|
||||
DATABASE_URL="file:./production.db"
|
||||
DATABASE_URL=mysql://username:password@mariadb:3306/database
|
||||
|
||||
# Encryption
|
||||
ENCRYPTION_ALGORITHM="aes-256-ctr"
|
||||
ENCRYPTION_SECRET="A RANDOM STRING WITH LENGTH OF 32"
|
||||
ENCRYPTION_ALGORITHM=aes-256-ctr
|
||||
ENCRYPTION_SECRET=RANDOM STRING WITH STRICTLY 32 IN LENGTH
|
||||
|
||||
#Embed
|
||||
EMBED_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"
|
||||
EMBED_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"
|
||||
LOG_LEVEL=info
|
||||
|
||||
# Reputation
|
||||
REPUTATION_TIMEOUT="86400"
|
||||
REPUTATION_TIMEOUT=86400
|
||||
|
||||
# Bot Hoster
|
||||
BOT_HOSTER_NAME="Zyner"
|
||||
BOT_HOSTER_URL="https://xyter.zyner.org/customization/change-hoster"
|
||||
BOT_HOSTER_NAME=Zyner
|
||||
BOT_HOSTER_URL=https://xyter.zyner.org/customization/change-hoster
|
51
.github/workflows/docker-image.yml
vendored
Normal file
51
.github/workflows/docker-image.yml
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
name: Docker Image CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- dev
|
||||
|
||||
jobs:
|
||||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
-
|
||||
name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
# list of Docker images to use as base name for tags
|
||||
images: |
|
||||
zyner/xyter
|
||||
# generate Docker tags based on the following events/attributes
|
||||
tags: |
|
||||
type=schedule
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=semver,pattern={{major}}
|
||||
type=sha
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
-
|
||||
name: Login to Docker Hub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
-
|
||||
name: Build and push
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -1,10 +1,7 @@
|
|||
json.sqlite
|
||||
node_modules
|
||||
.env
|
||||
config.json
|
||||
package-lock.json
|
||||
|
||||
src/config/
|
||||
db/
|
||||
|
||||
# Build
|
||||
build/
|
||||
|
|
24
Dockerfile
24
Dockerfile
|
@ -1,19 +1,25 @@
|
|||
FROM node:19
|
||||
FROM node:19 AS builder
|
||||
|
||||
LABEL maintainer="xyter@zyner.org"
|
||||
# Create app directory
|
||||
WORKDIR /app
|
||||
|
||||
WORKDIR /build
|
||||
# A wildcard is used to ensure both package.json AND package-lock.json are copied
|
||||
COPY package*.json ./
|
||||
COPY prisma ./prisma/
|
||||
|
||||
COPY package* .
|
||||
# Install app dependencies
|
||||
RUN npm install
|
||||
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN npx -y tsc
|
||||
RUN npm run build
|
||||
|
||||
WORKDIR /app
|
||||
FROM node:19
|
||||
|
||||
RUN cp -r /build/build/* .
|
||||
RUN cp -r /build/node_modules .
|
||||
COPY --from=builder /app/node_modules ./node_modules
|
||||
COPY --from=builder /app/package*.json ./
|
||||
COPY --from=builder /app/dist ./dist
|
||||
COPY --from=builder /app/prisma ./prisma
|
||||
|
||||
CMD [ "node", "." ]
|
||||
CMD [ "npm", "run", "start:migrate:prod" ]
|
|
@ -1,39 +1,27 @@
|
|||
version: "3"
|
||||
version: "3.7"
|
||||
|
||||
services:
|
||||
app:
|
||||
image: zyner/xyter:latest
|
||||
container_name: app
|
||||
image: vermiumwastaken/xyter
|
||||
restart: unless-stopped
|
||||
# build: .
|
||||
stdin_open: true
|
||||
tty: true
|
||||
env_file:
|
||||
- .env
|
||||
volumes:
|
||||
- ./logs:/app/logs
|
||||
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=production
|
||||
depends_on:
|
||||
- mongodb
|
||||
- ./logs:/logs
|
||||
|
||||
mongodb:
|
||||
image: mongo:latest
|
||||
mariadb:
|
||||
container_name: mariadb
|
||||
image: lscr.io/linuxserver/mariadb:latest
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
MONGO_INITDB_ROOT_USERNAME: MONGO_USER
|
||||
MONGO_INITDB_ROOT_PASSWORD: MONGO_PASS
|
||||
- PUID=1000
|
||||
- PGID=1000
|
||||
- TZ=Region/City
|
||||
- MYSQL_DATABASE=database
|
||||
- MYSQL_USER=username
|
||||
- MYSQL_PASSWORD=password
|
||||
volumes:
|
||||
- ./database:/data/db
|
||||
- ./db:/config
|
||||
ports:
|
||||
- 3306:3306
|
||||
|
|
13381
package-lock.json
generated
Normal file
13381
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
11
package.json
11
package.json
|
@ -2,13 +2,16 @@
|
|||
"name": "xyter",
|
||||
"version": "3.1.0",
|
||||
"description": "Earn credits while chatting! And more",
|
||||
"main": "src/index.ts",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"dev": "tsc --watch & nodemon dist",
|
||||
"build": "tsc -p .",
|
||||
"prisma:generate": "prisma generate",
|
||||
"test": "jest",
|
||||
"start": "nodemon src/index.ts",
|
||||
"start": "node dist",
|
||||
"start:migrate:prod": "prisma migrate deploy && npm run start",
|
||||
"prettier-format": "prettier \"src/**/*.ts\" --write",
|
||||
"lint": "eslint ./src --ext .ts",
|
||||
"prepare": "husky install"
|
||||
"lint": "eslint ./src --ext .ts"
|
||||
},
|
||||
"keywords": [
|
||||
"Zyner",
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
-- 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");
|
|
@ -1,26 +0,0 @@
|
|||
-- 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;
|
|
@ -1,71 +0,0 @@
|
|||
-- 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");
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
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;
|
|
@ -1,43 +0,0 @@
|
|||
-- 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;
|
|
@ -1,45 +0,0 @@
|
|||
-- 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;
|
|
@ -1,30 +0,0 @@
|
|||
-- 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;
|
|
@ -1,13 +0,0 @@
|
|||
-- 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");
|
|
@ -1,155 +0,0 @@
|
|||
/*
|
||||
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;
|
|
@ -1,55 +0,0 @@
|
|||
-- 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;
|
|
@ -1,12 +0,0 @@
|
|||
-- 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;
|
|
@ -1,34 +0,0 @@
|
|||
-- 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;
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
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;
|
|
@ -1,70 +0,0 @@
|
|||
-- 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;
|
|
@ -1,74 +0,0 @@
|
|||
-- 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;
|
|
@ -1,79 +0,0 @@
|
|||
-- 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;
|
|
@ -1,89 +0,0 @@
|
|||
/*
|
||||
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;
|
|
@ -1,91 +0,0 @@
|
|||
/*
|
||||
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;
|
|
@ -1,17 +0,0 @@
|
|||
-- 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");
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
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;
|
|
@ -1,39 +0,0 @@
|
|||
-- 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;
|
|
@ -1,39 +0,0 @@
|
|||
-- 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;
|
|
@ -1,244 +0,0 @@
|
|||
/*
|
||||
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;
|
|
@ -1,244 +0,0 @@
|
|||
/*
|
||||
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;
|
121
prisma/migrations/20221023164351_init/migration.sql
Normal file
121
prisma/migrations/20221023164351_init/migration.sql
Normal file
|
@ -0,0 +1,121 @@
|
|||
-- CreateTable
|
||||
CREATE TABLE `Guild` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`embedColorSuccess` VARCHAR(191) NOT NULL DEFAULT '#22bb33',
|
||||
`embedColorWait` VARCHAR(191) NOT NULL DEFAULT '#f0ad4e',
|
||||
`embedColorError` VARCHAR(191) NOT NULL DEFAULT '#bb2124',
|
||||
`embedFooterText` VARCHAR(191) NOT NULL DEFAULT 'https://github.com/ZynerOrg/xyter',
|
||||
`embedFooterIcon` VARCHAR(191) 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` VARCHAR(191) NULL,
|
||||
`apiCpggUrlContent` VARCHAR(191) NULL,
|
||||
`apiCpggTokenIv` VARCHAR(191) NULL,
|
||||
`apiCpggTokenContent` VARCHAR(191) NULL,
|
||||
`auditsEnabled` BOOLEAN NOT NULL DEFAULT false,
|
||||
`auditsChannelId` VARCHAR(191) NULL,
|
||||
`shopRolesEnabled` BOOLEAN NOT NULL DEFAULT false,
|
||||
`shopRolesPricePerHour` INTEGER NOT NULL DEFAULT 5,
|
||||
`welcomeEnabled` BOOLEAN NOT NULL DEFAULT false,
|
||||
`welcomeJoinChannelId` VARCHAR(191) NULL,
|
||||
`welcomeJoinChannelMessage` VARCHAR(191) NULL,
|
||||
`welcomeLeaveChannelId` VARCHAR(191) NULL,
|
||||
`welcomeLeaveChannelMessage` VARCHAR(191) NULL,
|
||||
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updatedAt` DATETIME(3) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `Guild_id_key`(`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `User` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`reputationsEarned` INTEGER NOT NULL DEFAULT 0,
|
||||
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updatedAt` DATETIME(3) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `User_id_key`(`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `GuildMember` (
|
||||
`userId` VARCHAR(191) NOT NULL,
|
||||
`guildId` VARCHAR(191) NOT NULL,
|
||||
`creditsEarned` INTEGER NOT NULL DEFAULT 0,
|
||||
`pointsEarned` INTEGER NOT NULL DEFAULT 0,
|
||||
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updatedAt` DATETIME(3) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `GuildMember_userId_guildId_key`(`userId`, `guildId`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `GuildCounter` (
|
||||
`guildId` VARCHAR(191) NOT NULL,
|
||||
`channelId` VARCHAR(191) NOT NULL,
|
||||
`triggerWord` VARCHAR(191) NOT NULL,
|
||||
`count` INTEGER NOT NULL DEFAULT 0,
|
||||
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updatedAt` DATETIME(3) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `GuildCounter_guildId_channelId_key`(`guildId`, `channelId`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `Cooldown` (
|
||||
`guildId` VARCHAR(191) NOT NULL,
|
||||
`userId` VARCHAR(191) NOT NULL,
|
||||
`cooldown` INTEGER NOT NULL,
|
||||
`timeoutId` VARCHAR(191) NOT NULL,
|
||||
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updatedAt` DATETIME(3) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `Cooldown_guildId_userId_timeoutId_key`(`guildId`, `userId`, `timeoutId`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `GuildShopRoles` (
|
||||
`guildId` VARCHAR(191) NOT NULL,
|
||||
`roleId` VARCHAR(191) NOT NULL,
|
||||
`userId` VARCHAR(191) NOT NULL,
|
||||
`pricePerHour` INTEGER NOT NULL DEFAULT 5,
|
||||
`lastPayed` DATETIME(3) NOT NULL,
|
||||
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updatedAt` DATETIME(3) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `GuildShopRoles_guildId_userId_roleId_key`(`guildId`, `userId`, `roleId`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `GuildMember` ADD CONSTRAINT `GuildMember_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `User`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `GuildMember` ADD CONSTRAINT `GuildMember_guildId_fkey` FOREIGN KEY (`guildId`) REFERENCES `Guild`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `GuildCounter` ADD CONSTRAINT `GuildCounter_guildId_fkey` FOREIGN KEY (`guildId`) REFERENCES `Guild`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `Cooldown` ADD CONSTRAINT `Cooldown_guildId_fkey` FOREIGN KEY (`guildId`) REFERENCES `Guild`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `Cooldown` ADD CONSTRAINT `Cooldown_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `User`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `GuildShopRoles` ADD CONSTRAINT `GuildShopRoles_guildId_fkey` FOREIGN KEY (`guildId`) REFERENCES `Guild`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `GuildShopRoles` ADD CONSTRAINT `GuildShopRoles_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `User`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `GuildShopRoles` ADD CONSTRAINT `GuildShopRoles_userId_guildId_fkey` FOREIGN KEY (`userId`, `guildId`) REFERENCES `GuildMember`(`userId`, `guildId`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
@ -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 = "mysql"
|
|
@ -7,7 +7,7 @@ generator client {
|
|||
}
|
||||
|
||||
datasource db {
|
||||
provider = "sqlite"
|
||||
provider = "mysql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
import { SlashCommandBuilder } from "@discordjs/builders";
|
||||
import { ChatInputCommandInteraction } from "discord.js";
|
||||
import { ChatInputCommandInteraction, SlashCommandBuilder } from "discord.js";
|
||||
|
||||
// Modules
|
||||
import moduleView from "./modules/view";
|
||||
import { builder as ViewBuilder, execute as ViewExecute } from "./modules/view";
|
||||
|
||||
//
|
||||
export const builder = new SlashCommandBuilder()
|
||||
.setName("counters")
|
||||
.setDescription("View guild counters")
|
||||
.setDMPermission(false)
|
||||
|
||||
// Modules
|
||||
.addSubcommand(moduleView.builder);
|
||||
.addSubcommand(ViewBuilder);
|
||||
|
||||
// Execute function
|
||||
export const execute = async (interaction: ChatInputCommandInteraction) => {
|
||||
switch (interaction.options.getSubcommand()) {
|
||||
case "view":
|
||||
await moduleView.execute(interaction);
|
||||
await ViewExecute(interaction);
|
||||
break;
|
||||
default:
|
||||
throw new Error("No module found for that command.");
|
||||
|
|
|
@ -1,67 +1,63 @@
|
|||
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
||||
import { ChannelType } from "discord-api-types/v10";
|
||||
import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js";
|
||||
import {
|
||||
ChannelType,
|
||||
ChatInputCommandInteraction,
|
||||
SlashCommandSubcommandBuilder,
|
||||
} from "discord.js";
|
||||
|
||||
import prisma from "../../../../handlers/database";
|
||||
import deferReply from "../../../../handlers/deferReply";
|
||||
import getEmbedConfig from "../../../../helpers/getEmbedData";
|
||||
import { success as BaseEmbedSuccess } from "../../../../helpers/baseEmbeds";
|
||||
|
||||
export default {
|
||||
builder: (command: SlashCommandSubcommandBuilder) => {
|
||||
return command
|
||||
.setName("view")
|
||||
.setDescription(`View a guild counter`)
|
||||
.addChannelOption((option) =>
|
||||
option
|
||||
.setName("channel")
|
||||
.setDescription(
|
||||
`The channel that contains the counter you want to view`
|
||||
)
|
||||
.setRequired(true)
|
||||
.addChannelTypes(ChannelType.GuildText)
|
||||
);
|
||||
},
|
||||
|
||||
execute: async (interaction: ChatInputCommandInteraction) => {
|
||||
await deferReply(interaction, false);
|
||||
|
||||
const { successColor, footerText, footerIcon } = await getEmbedConfig(
|
||||
interaction.guild
|
||||
// 1. Create builder function.
|
||||
export const builder = (command: SlashCommandSubcommandBuilder) => {
|
||||
return command
|
||||
.setName("view")
|
||||
.setDescription(`View a guild counter`)
|
||||
.addChannelOption((option) =>
|
||||
option
|
||||
.setName("channel")
|
||||
.setDescription(
|
||||
`The channel that contains the counter you want to view`
|
||||
)
|
||||
.setRequired(true)
|
||||
.addChannelTypes(ChannelType.GuildText)
|
||||
);
|
||||
const { options, guild } = interaction;
|
||||
|
||||
const discordChannel = options.getChannel("channel");
|
||||
|
||||
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({
|
||||
text: footerText,
|
||||
iconURL: footerIcon,
|
||||
});
|
||||
|
||||
const channelCounter = await prisma.guildCounter.findUnique({
|
||||
where: {
|
||||
guildId_channelId: {
|
||||
guildId: guild.id,
|
||||
channelId: discordChannel.id,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (!channelCounter) throw new Error("No counter found for channel");
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
embed
|
||||
.setDescription(
|
||||
`Viewing counter for channel ${discordChannel}: ${channelCounter.count}!`
|
||||
)
|
||||
.setColor(successColor),
|
||||
],
|
||||
});
|
||||
return;
|
||||
},
|
||||
};
|
||||
|
||||
// 2. Create execute function.
|
||||
export const execute = async (interaction: ChatInputCommandInteraction) => {
|
||||
// 1. Defer reply as permanent.
|
||||
await deferReply(interaction, false);
|
||||
|
||||
// 2. Destructure interaction object
|
||||
const { options, guild } = interaction;
|
||||
if (!guild) throw new Error(`Guild not found`);
|
||||
if (!options) throw new Error(`Options not found`);
|
||||
|
||||
// 3. Get options
|
||||
const discordChannel = options.getChannel("channel");
|
||||
if (!discordChannel) throw new Error(`Channel not found`);
|
||||
|
||||
// 4. Create base embeds.
|
||||
const EmbedSuccess = await BaseEmbedSuccess(guild, "[:1234:] View");
|
||||
|
||||
// 5. Get counter from database.
|
||||
const channelCounter = await prisma.guildCounter.findUnique({
|
||||
where: {
|
||||
guildId_channelId: {
|
||||
guildId: guild.id,
|
||||
channelId: discordChannel.id,
|
||||
},
|
||||
},
|
||||
});
|
||||
if (!channelCounter) throw new Error("No counter found for channel");
|
||||
|
||||
// 6. Send embed.
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
EmbedSuccess.setDescription(
|
||||
`Viewing counter for channel ${discordChannel}: ${channelCounter.count}!`
|
||||
),
|
||||
],
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1,42 +1,42 @@
|
|||
import { SlashCommandBuilder } from "@discordjs/builders";
|
||||
import { ChatInputCommandInteraction } from "discord.js";
|
||||
import logger from "../../middlewares/logger";
|
||||
import { ChatInputCommandInteraction, SlashCommandBuilder } from "discord.js";
|
||||
|
||||
// Modules
|
||||
import moduleBalance from "./modules/balance";
|
||||
import moduleGift from "./modules/gift";
|
||||
import moduleTop from "./modules/top";
|
||||
import moduleWork from "./modules/work";
|
||||
import {
|
||||
builder as BalanceBuilder,
|
||||
execute as BalanceExecute,
|
||||
} from "./modules/balance";
|
||||
import { builder as GiftBuilder, execute as GiftExecute } from "./modules/gift";
|
||||
import { builder as TopBuilder, execute as TopExecute } from "./modules/top";
|
||||
import { builder as WorkBuilder, execute as WorkExecute } from "./modules/work";
|
||||
|
||||
// 1. Export a builder function.
|
||||
export const builder = new SlashCommandBuilder()
|
||||
.setName("credits")
|
||||
.setDescription("Manage your credits.")
|
||||
.setDMPermission(false)
|
||||
|
||||
// Modules
|
||||
.addSubcommand(moduleBalance.builder)
|
||||
.addSubcommand(moduleGift.builder)
|
||||
.addSubcommand(moduleTop.builder)
|
||||
.addSubcommand(moduleWork.builder);
|
||||
.addSubcommand(BalanceBuilder)
|
||||
.addSubcommand(GiftBuilder)
|
||||
.addSubcommand(TopBuilder)
|
||||
.addSubcommand(WorkBuilder);
|
||||
|
||||
// Execute function
|
||||
// 2. Export an execute function.
|
||||
export const execute = async (interaction: ChatInputCommandInteraction) => {
|
||||
const { options } = interaction;
|
||||
|
||||
switch (options.getSubcommand()) {
|
||||
switch (interaction.options.getSubcommand()) {
|
||||
case "balance":
|
||||
await moduleBalance.execute(interaction);
|
||||
await BalanceExecute(interaction);
|
||||
break;
|
||||
case "gift":
|
||||
await moduleGift.execute(interaction);
|
||||
await GiftExecute(interaction);
|
||||
break;
|
||||
case "top":
|
||||
await moduleTop.execute(interaction);
|
||||
await TopExecute(interaction);
|
||||
break;
|
||||
case "work":
|
||||
await moduleWork.execute(interaction);
|
||||
await WorkExecute(interaction);
|
||||
break;
|
||||
default:
|
||||
logger.silly(`Unknown subcommand ${options.getSubcommand()}`);
|
||||
throw new Error("Subcommand not found");
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,95 +1,86 @@
|
|||
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
||||
import { CommandInteraction, EmbedBuilder } from "discord.js";
|
||||
import { CommandInteraction, SlashCommandSubcommandBuilder } from "discord.js";
|
||||
|
||||
import prisma from "../../../../handlers/database";
|
||||
import deferReply from "../../../../handlers/deferReply";
|
||||
import getEmbedConfig from "../../../../helpers/getEmbedData";
|
||||
import { success as BaseEmbedSuccess } from "../../../../helpers/baseEmbeds";
|
||||
import logger from "../../../../middlewares/logger";
|
||||
|
||||
export default {
|
||||
builder: (command: SlashCommandSubcommandBuilder) => {
|
||||
return command
|
||||
.setName("balance")
|
||||
.setDescription(`View a user's balance`)
|
||||
.addUserOption((option) =>
|
||||
option
|
||||
.setName("user")
|
||||
.setDescription(`The user whose balance you want to view`)
|
||||
);
|
||||
},
|
||||
execute: async (interaction: CommandInteraction) => {
|
||||
await deferReply(interaction, true);
|
||||
|
||||
const { errorColor, successColor, footerText, footerIcon } =
|
||||
await getEmbedConfig(interaction.guild);
|
||||
const { options, user, guild } = interaction;
|
||||
|
||||
const discordUser = options.getUser("user");
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle("[:dollar:] Balance")
|
||||
.setTimestamp(new Date())
|
||||
.setFooter({ text: footerText, iconURL: footerIcon });
|
||||
|
||||
if (guild === null) {
|
||||
logger.silly(`Guild is null`);
|
||||
|
||||
return interaction.editReply({
|
||||
embeds: [
|
||||
embed.setDescription("Guild is not found").setColor(errorColor),
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
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,
|
||||
},
|
||||
});
|
||||
|
||||
logger.silly(createGuildMember);
|
||||
|
||||
if (!createGuildMember) throw new Error("No guild member exists.");
|
||||
|
||||
return interaction.editReply({
|
||||
embeds: [
|
||||
embed
|
||||
.setDescription(
|
||||
`${discordUser || user} currently has ${
|
||||
createGuildMember.creditsEarned
|
||||
} credits.`
|
||||
)
|
||||
.setColor(successColor),
|
||||
],
|
||||
});
|
||||
},
|
||||
// 1. Export a builder function.
|
||||
export const builder = (command: SlashCommandSubcommandBuilder) => {
|
||||
return command
|
||||
.setName("balance")
|
||||
.setDescription(`View a user's balance`)
|
||||
.addUserOption((option) =>
|
||||
option
|
||||
.setName("target")
|
||||
.setDescription(`The user whose balance you want to view`)
|
||||
);
|
||||
};
|
||||
|
||||
// 2. Export an execute function.
|
||||
export const execute = async (interaction: CommandInteraction) => {
|
||||
// 1. Defer reply as ephemeral.
|
||||
await deferReply(interaction, true);
|
||||
|
||||
// 2. Destructure interaction object.
|
||||
const { options, user, guild } = interaction;
|
||||
if (!guild) throw new Error("Guild not found");
|
||||
if (!user) throw new Error("User not found");
|
||||
if (!options) throw new Error("Options not found");
|
||||
|
||||
// 3. Get options from interaction.
|
||||
const target = options.getUser("target");
|
||||
|
||||
// 4. Create base embeds.
|
||||
const EmbedSuccess = await BaseEmbedSuccess(guild, "[:dollar:] Balance");
|
||||
|
||||
// 5. Upsert the user in the database.
|
||||
const createGuildMember = await prisma.guildMember.upsert({
|
||||
where: {
|
||||
userId_guildId: {
|
||||
userId: (target || user).id,
|
||||
guildId: guild.id,
|
||||
},
|
||||
},
|
||||
update: {},
|
||||
create: {
|
||||
user: {
|
||||
connectOrCreate: {
|
||||
create: {
|
||||
id: (target || user).id,
|
||||
},
|
||||
where: {
|
||||
id: (target || 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("No guild member exists.");
|
||||
|
||||
// 6. Send embed.
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
EmbedSuccess.setDescription(
|
||||
target
|
||||
? `${target} has ${createGuildMember.creditsEarned} credits.`
|
||||
: `You have ${createGuildMember.creditsEarned} credits.`
|
||||
),
|
||||
],
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1,89 +1,81 @@
|
|||
// Dependencies
|
||||
// Models
|
||||
import {
|
||||
ChatInputCommandInteraction,
|
||||
EmbedBuilder,
|
||||
SlashCommandSubcommandBuilder,
|
||||
} from "discord.js";
|
||||
import transferCredits from "../../../../helpers/transferCredits";
|
||||
// Configurations
|
||||
|
||||
import deferReply from "../../../../handlers/deferReply";
|
||||
import getEmbedConfig from "../../../../helpers/getEmbedData";
|
||||
// Handlers
|
||||
import { success as BaseEmbedSuccess } from "../../../../helpers/baseEmbeds";
|
||||
import { transfer as CreditsTransfer } from "../../../../helpers/credits";
|
||||
|
||||
// Function
|
||||
export default {
|
||||
builder: (command: SlashCommandSubcommandBuilder) => {
|
||||
return command
|
||||
.setName("gift")
|
||||
.setDescription(`Gift a user credits`)
|
||||
.addUserOption((option) =>
|
||||
option
|
||||
.setName("user")
|
||||
.setDescription("The user you want to gift credits to.")
|
||||
.setRequired(true)
|
||||
)
|
||||
.addIntegerOption((option) =>
|
||||
option
|
||||
.setName("amount")
|
||||
.setDescription("The amount of credits you want to gift.")
|
||||
.setRequired(true)
|
||||
)
|
||||
.addStringOption((option) =>
|
||||
option.setName("reason").setDescription("Your reason.")
|
||||
);
|
||||
},
|
||||
execute: async (interaction: ChatInputCommandInteraction) => {
|
||||
await deferReply(interaction, true);
|
||||
|
||||
const { successColor, footerText, footerIcon } = await getEmbedConfig(
|
||||
interaction.guild
|
||||
// 1. Export a builder function.
|
||||
export const builder = (command: SlashCommandSubcommandBuilder) => {
|
||||
return command
|
||||
.setName("gift")
|
||||
.setDescription(`Gift a user credits`)
|
||||
.addUserOption((option) =>
|
||||
option
|
||||
.setName("target")
|
||||
.setDescription("The user you want to gift credits to.")
|
||||
.setRequired(true)
|
||||
)
|
||||
.addIntegerOption((option) =>
|
||||
option
|
||||
.setName("credits")
|
||||
.setDescription("The amount of credits you want to gift.")
|
||||
.setRequired(true)
|
||||
.setMinValue(1)
|
||||
.setMaxValue(100000000)
|
||||
)
|
||||
.addStringOption((option) =>
|
||||
option.setName("reason").setDescription("Your reason.")
|
||||
);
|
||||
const { options, user, guild, client } = interaction;
|
||||
|
||||
const optionUser = options.getUser("user");
|
||||
const optionAmount = options.getInteger("amount");
|
||||
const optionReason = options.getString("reason");
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle("[:dollar:] Gift")
|
||||
.setTimestamp(new Date())
|
||||
.setFooter({ text: footerText, iconURL: footerIcon });
|
||||
|
||||
if (!guild) throw new Error("Guild not found");
|
||||
if (!optionUser) throw new Error("No receiver found");
|
||||
if (optionAmount === null) throw new Error("Amount not found");
|
||||
|
||||
await transferCredits(guild, user, optionUser, optionAmount);
|
||||
|
||||
// Get DM user object
|
||||
const dmUser = client.users.cache.get(optionUser.id);
|
||||
|
||||
if (!dmUser) throw new Error("User not found");
|
||||
|
||||
// Send DM to user
|
||||
await dmUser.send({
|
||||
embeds: [
|
||||
embed
|
||||
.setDescription(
|
||||
`${user.tag} has gifted you ${optionAmount} credits with reason: ${
|
||||
optionReason || "unspecified"
|
||||
}`
|
||||
)
|
||||
.setColor(successColor),
|
||||
],
|
||||
});
|
||||
|
||||
return interaction.editReply({
|
||||
embeds: [
|
||||
embed
|
||||
.setDescription(
|
||||
`Successfully gifted ${optionAmount} credits to ${optionUser} with reason: ${
|
||||
optionReason || "unspecified"
|
||||
}`
|
||||
)
|
||||
.setColor(successColor),
|
||||
],
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
// 2. Export an execute function.
|
||||
export const execute = async (interaction: ChatInputCommandInteraction) => {
|
||||
// 1. Defer reply as ephemeral.
|
||||
await deferReply(interaction, true);
|
||||
|
||||
// 2. Destructure interaction object.
|
||||
const { options, user, guild, client } = interaction;
|
||||
if (!guild) throw new Error("Guild not found");
|
||||
if (!user) throw new Error("User not found");
|
||||
if (!client) throw new Error("Client not found");
|
||||
if (!options) throw new Error("Options not found");
|
||||
|
||||
// 3. Get options from interaction.
|
||||
const target = options.getUser("target");
|
||||
const credits = options.getInteger("credits");
|
||||
const reason = options.getString("reason");
|
||||
if (!target) throw new Error("Target user not found");
|
||||
if (typeof credits !== "number")
|
||||
throw new Error("You need to specify a number of credits you want to gift");
|
||||
|
||||
// 4. Create base embeds.
|
||||
const EmbedSuccess = await BaseEmbedSuccess(guild, "[:dollar:] Gift");
|
||||
|
||||
// 5. Start an transaction of the credits.
|
||||
await CreditsTransfer(guild, user, target, credits);
|
||||
|
||||
// 6. Tell the target that they have been gifted credits.
|
||||
await target.send({
|
||||
embeds: [
|
||||
EmbedSuccess.setDescription(
|
||||
reason
|
||||
? `You received ${credits} credits from ${user} for the reason: ${reason}.`
|
||||
: `You received ${credits} credits from ${user}.`
|
||||
),
|
||||
],
|
||||
});
|
||||
|
||||
// 7. Tell the sender that they have gifted the credits.
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
EmbedSuccess.setDescription(
|
||||
reason
|
||||
? `You have successfully gifted ${credits} credits to ${target} with reason: ${reason}.`
|
||||
: `You have successfully gifted ${credits} credits to ${target}.`
|
||||
),
|
||||
],
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1,73 +1,59 @@
|
|||
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
||||
import { GuildMember } from "@prisma/client";
|
||||
import { CommandInteraction, EmbedBuilder } from "discord.js";
|
||||
import {
|
||||
CommandInteraction,
|
||||
SlashCommandSubcommandBuilder,
|
||||
userMention,
|
||||
} from "discord.js";
|
||||
|
||||
import prisma from "../../../../handlers/database";
|
||||
import deferReply from "../../../../handlers/deferReply";
|
||||
import getEmbedConfig from "../../../../helpers/getEmbedData";
|
||||
import { success as BaseEmbedSuccess } from "../../../../helpers/baseEmbeds";
|
||||
import logger from "../../../../middlewares/logger";
|
||||
|
||||
export default {
|
||||
metadata: { guildOnly: true, ephemeral: false },
|
||||
|
||||
builder: (command: SlashCommandSubcommandBuilder) => {
|
||||
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;
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle("[:dollar:] Top")
|
||||
.setTimestamp(new Date())
|
||||
.setFooter({ text: footerText, iconURL: footerIcon });
|
||||
|
||||
if (guild === null) {
|
||||
logger.silly(`Guild is null`);
|
||||
|
||||
return interaction.editReply({
|
||||
embeds: [
|
||||
embed
|
||||
.setDescription(
|
||||
"Guild is not found. Please try again with a valid guild."
|
||||
)
|
||||
.setColor(errorColor),
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
// const usersDB = await userSchema.find({ guildId: guild.id });
|
||||
|
||||
const topTen = await prisma.guildMember.findMany({
|
||||
where: {
|
||||
guildId: guild.id,
|
||||
},
|
||||
orderBy: {
|
||||
creditsEarned: "desc",
|
||||
},
|
||||
take: 10,
|
||||
});
|
||||
|
||||
logger.silly(topTen);
|
||||
|
||||
// Create entry object
|
||||
const entry = (guildMember: GuildMember, index: number) =>
|
||||
`${index + 1}. <@${guildMember.userId}> - ${
|
||||
guildMember.creditsEarned
|
||||
} credits`;
|
||||
|
||||
return interaction.editReply({
|
||||
embeds: [
|
||||
embed
|
||||
.setDescription(
|
||||
`Below are the top ten members in this guild.
|
||||
|
||||
${topTen.map(entry).join("\n")}`
|
||||
)
|
||||
.setColor(successColor),
|
||||
],
|
||||
});
|
||||
},
|
||||
// 1. Export a builder function.
|
||||
export const builder = (command: SlashCommandSubcommandBuilder) => {
|
||||
return command.setName("top").setDescription(`View the top users`);
|
||||
};
|
||||
|
||||
// 2. Export an execute function.
|
||||
export const execute = async (interaction: CommandInteraction) => {
|
||||
// 1. Defer reply as permanent.
|
||||
await deferReply(interaction, false);
|
||||
|
||||
// 2. Destructure interaction object.
|
||||
const { guild, client } = interaction;
|
||||
if (!guild) throw new Error("Guild not found");
|
||||
if (!client) throw new Error("Client not found");
|
||||
|
||||
// 3. Create base embeds.
|
||||
const EmbedSuccess = await BaseEmbedSuccess(guild, "[:dollar:] Top");
|
||||
|
||||
// 4. Get the top 10 users.
|
||||
const topTen = await prisma.guildMember.findMany({
|
||||
where: {
|
||||
guildId: guild.id,
|
||||
},
|
||||
orderBy: {
|
||||
creditsEarned: "desc",
|
||||
},
|
||||
take: 10,
|
||||
});
|
||||
logger.silly(topTen);
|
||||
|
||||
// 5. Create the top 10 list.
|
||||
const entry = (guildMember: GuildMember, index: number) =>
|
||||
`${index + 1}. ${userMention(guildMember.userId)} | :coin: ${
|
||||
guildMember.creditsEarned
|
||||
}`;
|
||||
|
||||
// 6. Send embed
|
||||
return interaction.editReply({
|
||||
embeds: [
|
||||
EmbedSuccess.setDescription(
|
||||
`The top 10 users in this server are:\n\n${topTen
|
||||
.map(entry)
|
||||
.join("\n")}`
|
||||
),
|
||||
],
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1,108 +1,102 @@
|
|||
// Dependencies
|
||||
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
||||
import Chance from "chance";
|
||||
import { CommandInteraction, EmbedBuilder } from "discord.js";
|
||||
// Models
|
||||
import { CommandInteraction } from "discord.js";
|
||||
|
||||
import { command as CooldownCommand } from "../../../../handlers/cooldown";
|
||||
// Configurations
|
||||
import getEmbedConfig from "../../../../helpers/getEmbedData";
|
||||
// Helpers
|
||||
// Handlers
|
||||
import prisma from "../../../../handlers/database";
|
||||
import deferReply from "../../../../handlers/deferReply";
|
||||
import { success as BaseEmbedSuccess } from "../../../../helpers/baseEmbeds";
|
||||
import logger from "../../../../middlewares/logger";
|
||||
|
||||
export default {
|
||||
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
|
||||
const { guild, user } = interaction;
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle("[:dollar:] Work")
|
||||
.setTimestamp(new Date())
|
||||
.setFooter({
|
||||
text: footerText,
|
||||
iconURL: footerIcon,
|
||||
});
|
||||
|
||||
// Chance module
|
||||
const chance = new Chance();
|
||||
|
||||
if (guild === null) {
|
||||
return logger?.silly(`Guild is null`);
|
||||
}
|
||||
|
||||
const createGuild = await prisma.guild.upsert({
|
||||
where: {
|
||||
id: guild.id,
|
||||
},
|
||||
update: {},
|
||||
create: {
|
||||
id: guild.id,
|
||||
},
|
||||
});
|
||||
|
||||
logger.silly(createGuild);
|
||||
|
||||
await CooldownCommand(interaction, createGuild.creditsWorkTimeout);
|
||||
|
||||
const creditsEarned = chance.integer({
|
||||
min: 0,
|
||||
max: createGuild.creditsWorkRate,
|
||||
});
|
||||
|
||||
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,
|
||||
},
|
||||
});
|
||||
|
||||
logger.silly(createGuildMember);
|
||||
|
||||
return interaction.editReply({
|
||||
embeds: [
|
||||
embed
|
||||
.setDescription(`You worked and earned ${creditsEarned} credits.`)
|
||||
.setColor(successColor),
|
||||
],
|
||||
});
|
||||
},
|
||||
// 1. Export a builder function.
|
||||
export const builder = (command: SlashCommandSubcommandBuilder) => {
|
||||
return command.setName("work").setDescription(`Work to earn credits`);
|
||||
};
|
||||
|
||||
// 2. Export an execute function.
|
||||
export const execute = async (interaction: CommandInteraction) => {
|
||||
// 1. Defer reply as ephemeral.
|
||||
await deferReply(interaction, true);
|
||||
|
||||
// 2. Destructure interaction object.
|
||||
const { guild, user } = interaction;
|
||||
if (!guild) throw new Error("Guild not found");
|
||||
if (!user) throw new Error("User not found");
|
||||
|
||||
// 3. Create base embeds.
|
||||
const EmbedSuccess = await BaseEmbedSuccess(guild, "[:dollar:] Work");
|
||||
|
||||
// 4. Create new Chance instance.
|
||||
const chance = new Chance();
|
||||
|
||||
// 5. Upsert the guild in the database.
|
||||
const createGuild = await prisma.guild.upsert({
|
||||
where: {
|
||||
id: guild.id,
|
||||
},
|
||||
update: {},
|
||||
create: {
|
||||
id: guild.id,
|
||||
},
|
||||
});
|
||||
logger.silly(createGuild);
|
||||
if (!createGuild) throw new Error("Guild not found");
|
||||
|
||||
// 6. Create a cooldown for the user.
|
||||
await CooldownCommand(interaction, createGuild.creditsWorkTimeout);
|
||||
|
||||
// 6. Generate a random number between 0 and creditsWorkRate.
|
||||
const creditsEarned = chance.integer({
|
||||
min: 0,
|
||||
max: createGuild.creditsWorkRate,
|
||||
});
|
||||
|
||||
// 7. Upsert the guildMember in the database.
|
||||
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,
|
||||
},
|
||||
});
|
||||
logger.silly(createGuildMember);
|
||||
if (!createGuildMember) throw new Error("GuildMember not found");
|
||||
|
||||
// 8. Send embed.
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
EmbedSuccess.setDescription(
|
||||
`You worked and earned **${creditsEarned}** credits! You now have **${createGuildMember.creditsEarned}** credits. :tada:`
|
||||
),
|
||||
],
|
||||
});
|
||||
};
|
||||
|
|
|
@ -6,7 +6,7 @@ import {
|
|||
EmbedBuilder,
|
||||
PermissionsBitField,
|
||||
} from "discord.js";
|
||||
import transferCredits from "../../../../../../helpers/transferCredits";
|
||||
import { transfer as CreditsTransfer } from "../../../../../../helpers/credits";
|
||||
// Configurations
|
||||
import deferReply from "../../../../../../handlers/deferReply";
|
||||
import checkPermission from "../../../../../../helpers/checkPermission";
|
||||
|
@ -65,7 +65,7 @@ export default {
|
|||
if (!optionToUser)
|
||||
throw new Error("You must provide a user to transfer to.");
|
||||
|
||||
await transferCredits(guild, optionFromUser, optionToUser, optionAmount);
|
||||
await CreditsTransfer(guild, optionFromUser, optionToUser, optionAmount);
|
||||
|
||||
return interaction?.editReply({
|
||||
embeds: [
|
||||
|
|
|
@ -22,7 +22,7 @@ export default {
|
|||
},
|
||||
});
|
||||
|
||||
if (!channelCounter) throw new Error("No counters found in channel.");
|
||||
if (!channelCounter) return logger.debug("No counters found in channel.");
|
||||
|
||||
if (
|
||||
lastMessage?.author.id === author.id &&
|
||||
|
|
|
@ -20,7 +20,7 @@ export default async (message: Message) => {
|
|||
},
|
||||
});
|
||||
|
||||
if (!channelCounter) throw new Error("No counters found in channel.");
|
||||
if (!channelCounter) return logger.debug("No counters found in channel.");
|
||||
|
||||
if (content === channelCounter.triggerWord)
|
||||
return logger?.silly(
|
||||
|
|
|
@ -26,15 +26,13 @@ export default async (client: Client) => {
|
|||
throw new Error(`Could not gather command list: ${error}`);
|
||||
});
|
||||
|
||||
await client.application?.commands
|
||||
.set(commandList, process.env.DISCORD_GUILD_ID)
|
||||
.then(() => {
|
||||
logger.info(`Finished updating command list.`);
|
||||
});
|
||||
await client.application?.commands.set(commandList).then(() => {
|
||||
logger.info(`Finished updating command list.`);
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
await client.application?.commands
|
||||
.set(commandList)
|
||||
.set(commandList, process.env.DISCORD_GUILD_ID)
|
||||
.then(() => logger.info(`Finished updating guild command list.`));
|
||||
}
|
||||
};
|
||||
|
|
35
src/helpers/baseEmbeds/index.ts
Normal file
35
src/helpers/baseEmbeds/index.ts
Normal file
|
@ -0,0 +1,35 @@
|
|||
import { EmbedBuilder, Guild } from "discord.js";
|
||||
import getEmbedData from "../getEmbedData";
|
||||
|
||||
// Construct a base embed for success messages
|
||||
export const success = async (guild: Guild | null, title: string) => {
|
||||
const { successColor, footerText, footerIcon } = await getEmbedData(guild);
|
||||
|
||||
return new EmbedBuilder()
|
||||
.setTimestamp(new Date())
|
||||
.setTitle(title)
|
||||
.setColor(successColor)
|
||||
.setFooter({ text: footerText, iconURL: footerIcon });
|
||||
};
|
||||
|
||||
// Construct a base embed for wait messages
|
||||
export const wait = async (guild: Guild | null, title: string) => {
|
||||
const { waitColor, footerText, footerIcon } = await getEmbedData(guild);
|
||||
|
||||
return new EmbedBuilder()
|
||||
.setTimestamp(new Date())
|
||||
.setTitle(title)
|
||||
.setColor(waitColor)
|
||||
.setFooter({ text: footerText, iconURL: footerIcon });
|
||||
};
|
||||
|
||||
// Construct a base embed for error messages
|
||||
export const error = async (guild: Guild | null, title: string) => {
|
||||
const { errorColor, footerText, footerIcon } = await getEmbedData(guild);
|
||||
|
||||
return new EmbedBuilder()
|
||||
.setTimestamp(new Date())
|
||||
.setTitle(title)
|
||||
.setColor(errorColor)
|
||||
.setFooter({ text: footerText, iconURL: footerIcon });
|
||||
};
|
|
@ -2,6 +2,6 @@ import fs from "fs";
|
|||
const fsPromises = fs.promises;
|
||||
|
||||
export default async (path: string) => {
|
||||
const result = await fsPromises.readdir(path);
|
||||
const result = await fsPromises.readdir(`${__dirname}/../../${path}`);
|
||||
return result;
|
||||
};
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
import { Guild, User } from "discord.js";
|
||||
import prisma from "../../handlers/database";
|
||||
|
||||
export default async (guild: Guild, from: User, to: User, amount: number) => {
|
||||
export const transfer = 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({
|
||||
|
@ -57,13 +62,18 @@ export default async (guild: Guild, from: User, to: User, amount: number) => {
|
|||
throw new Error("You can't transfer below one credit.");
|
||||
}
|
||||
|
||||
// 6. Verify that recipient are not an bot.
|
||||
// 6. Verify that the sender is not trying to send more than 100.000.000 credits.
|
||||
if (amount > 100000000) {
|
||||
throw new Error("You can't transfer more than 100.000.000 credits.");
|
||||
}
|
||||
|
||||
// 7. 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.
|
||||
// 8. 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.
|
||||
// 9. Increment the recipient's balance by amount.
|
||||
const recipient = await tx.guildMember.upsert({
|
||||
update: {
|
||||
creditsEarned: {
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2022",
|
||||
"target": "es6",
|
||||
"module": "CommonJS",
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
|
@ -11,9 +11,9 @@
|
|||
"noFallthroughCasesInSwitch": true,
|
||||
"moduleResolution": "node",
|
||||
"isolatedModules": true,
|
||||
"outDir": "./build",
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src",
|
||||
"resolveJsonModule": true,
|
||||
"baseUrl": "./src",
|
||||
"typeRoots": ["/types/common", "./node_modules/@types"]
|
||||
},
|
||||
"include": ["./src"],
|
||||
|
|
Loading…
Add table
Reference in a new issue