SpicyJungle
SpicyJungle
Explore posts from servers
PPrisma
Created by SpicyJungle on 7/9/2024 in #help-and-questions
Typescript one to many relation
I'm trying to create a record like this:
await db.limits.create({
data: {
...limit,
id: undefined,
trimorders: allTrimorders
},
});
await db.limits.create({
data: {
...limit,
id: undefined,
trimorders: allTrimorders
},
});
However, typescript complains about the trimorders field: Type '{ id: number; ticker: string; price: number; dir: string; shares: number; userid: number; }[]' is not assignable to type 'TrimOrdersUncheckedCreateNestedManyWithoutLimitInput | TrimOrdersCreateNestedManyWithoutLimitInput | undefined'. These are the schemas:
model limits {
ticker String
price Float
stoploss Float?
takeprofit Float?
id Int @id @default(autoincrement())
userid Int
amount Int
style String
dir String
type String

trimorders TrimOrders[]
}


model TrimOrders {
id Int @id @default(autoincrement())
ticker String
price Float
dir String
shares Int
userid Int

user users @relation(fields: [userid], references: [id])
limit limits? @relation(fields: [id], references: [id])
}
model limits {
ticker String
price Float
stoploss Float?
takeprofit Float?
id Int @id @default(autoincrement())
userid Int
amount Int
style String
dir String
type String

trimorders TrimOrders[]
}


model TrimOrders {
id Int @id @default(autoincrement())
ticker String
price Float
dir String
shares Int
userid Int

user users @relation(fields: [userid], references: [id])
limit limits? @relation(fields: [id], references: [id])
}
3 replies
DIAdiscord.js - Imagine an app
Created by SpicyJungle on 7/2/2023 in #djs-questions
Not recieving heartbeats, killed after ~50 seconds, zombie connection, do recieve guildCreate event
Hey, I'm having a really annoying issue. I have a ubuntu server on a digitalocean droplet where I try to host a djs 14 bot made with typescript. I have ran a djs 13 bot with javascript on the same server, with no issues. For some reason, when I run it, the bot status changes to "Online" but I never recieve the ready event, nor recieve commands. After about 50 seconds, it's killed (maybe after recieving all ~650 guilds?). This is the output from client.on("debug"):
Preparing to connect to the gateway...
[WS => Manager] Fetched Gateway Information
URL: wss://gateway.discord.gg
Recommended Shards: 1
[WS => Manager] Session Limit Information
Total: 1000
Remaining: 998
[WS => Shard 0] Connecting to wss://gateway.discord.gg?v=10&encoding=json
[WS => Shard 0] Waiting for event hello for 60000ms
[WS => Shard 0] Preparing first heartbeat of the connection with a jitter of 0.3886729184365818; waiting 16032ms
[WS => Shard 0] Waiting for identify throttle
[WS => Shard 0] Identifying
shard id: 0
shard count: 1
intents: 1
compression: none
[WS => Shard 0] Waiting for event ready for 15000ms
[WS => Shard 0] First heartbeat sent, starting to beat every 41250ms
[WS => Shard 0] Destroying shard
Reason: Zombie connection
Code: 4200
Recover: Resume
[WS => Shard 0] Connection status during destroy
Needs closing: true
Ready state: 1
Killed
Preparing to connect to the gateway...
[WS => Manager] Fetched Gateway Information
URL: wss://gateway.discord.gg
Recommended Shards: 1
[WS => Manager] Session Limit Information
Total: 1000
Remaining: 998
[WS => Shard 0] Connecting to wss://gateway.discord.gg?v=10&encoding=json
[WS => Shard 0] Waiting for event hello for 60000ms
[WS => Shard 0] Preparing first heartbeat of the connection with a jitter of 0.3886729184365818; waiting 16032ms
[WS => Shard 0] Waiting for identify throttle
[WS => Shard 0] Identifying
shard id: 0
shard count: 1
intents: 1
compression: none
[WS => Shard 0] Waiting for event ready for 15000ms
[WS => Shard 0] First heartbeat sent, starting to beat every 41250ms
[WS => Shard 0] Destroying shard
Reason: Zombie connection
Code: 4200
Recover: Resume
[WS => Shard 0] Connection status during destroy
Needs closing: true
Ready state: 1
Killed
It takes about 40-50 seconds from the "First heartbeat sent" until "Destroying shard". Using the raw event I got a lot of my guilds logged, not sure if i recieved every guild. Node version: 20.3.1 Djs: 14.11.0 Ubuntu 22.10 Please let me know if any more info is needed 🙂
41 replies