fix megis command and add cascade to onremove
This commit is contained in:
parent
cce8746181
commit
897eb650d2
|
@ -40,15 +40,13 @@ const command = {
|
|||
});
|
||||
}
|
||||
|
||||
const timeMs = new Date().getTime();
|
||||
const timeoutMs = new Date(user.megis.updatedAt).getTime() + timeout;
|
||||
if (user) {
|
||||
const timeMs = new Date().getTime();
|
||||
const timeoutMs = new Date(user.megis.updatedAt).getTime() + timeout;
|
||||
if (timeMs < timeoutMs) {
|
||||
await client.say(
|
||||
msg.channelName,
|
||||
`${
|
||||
msg.displayName
|
||||
}, remember kids, only one megis per hour! (on timeout for ${Math.floor(
|
||||
`${msg.displayName}, Two cans per day... (on timeout for ${Math.floor(
|
||||
Math.abs(timeoutMs - timeMs) / 1000 / 60
|
||||
)} minutes 🕒 ) `
|
||||
);
|
||||
|
@ -76,7 +74,7 @@ const command = {
|
|||
|
||||
await client.say(
|
||||
msg.channelName,
|
||||
`${msg.displayName}, +${megis}! ${megisTypes[megis]} Total megis: ${updateUser.megis.megis}`
|
||||
`${msg.displayName}, +${megis} megis! ${megisTypes[megis]} Total megis: ${updateUser.megis.megis}`
|
||||
);
|
||||
},
|
||||
};
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
-- CreateTable
|
||||
CREATE TABLE "User" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"userId" TEXT NOT NULL,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" DATETIME NOT NULL
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Megis" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"userId" TEXT NOT NULL,
|
||||
"megis" INTEGER NOT NULL,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" DATETIME NOT NULL,
|
||||
CONSTRAINT "Megis_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "User_userId_key" ON "User"("userId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Megis_userId_key" ON "Megis"("userId");
|
|
@ -0,0 +1,3 @@
|
|||
# Please do not edit this file manually
|
||||
# It should be added in your version-control system (i.e. Git)
|
||||
provider = "sqlite"
|
|
@ -21,7 +21,7 @@ model User {
|
|||
|
||||
model Megis {
|
||||
id String @id @default(uuid())
|
||||
User User @relation(fields: [userId], references: [id])
|
||||
User User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
userId String @unique
|
||||
megis Int
|
||||
|
||||
|
|
Loading…
Reference in New Issue